// @flow import Module from './Module' import { httpReq as uninstrumentedHttpReq, httpReq2 as uninstrumentedHttpReq2 } from './uninstrumentedHttpUtils' import type { HttpReqOptions, HttpReqOptions2, HttpReqResponse } from './uninstrumentedHttpUtils' const { MODULE_NAME, log, warn, error, noteGauge, noteCount, trackOp } = new Module(__filename) // eslint-disable-line no-unused-vars export async function httpReq(url: string, options: HttpReqOptions = {}): Promise { return await trackOp(async () => { return await uninstrumentedHttpReq(url, options) }, options && options.trackingName ? `httpReq.${options.trackingName}` : null) } export async function httpReq2(url: string, options: HttpReqOptions2 = {}): Promise { return await trackOp(async () => { return await uninstrumentedHttpReq2(url, options) }, options && options.trackingName ? `httpReq.${options.trackingName}` : null) } // TODO: move to stringUtils export function objToQuery(obj: ?Object, pairSep: ?string, keyValueSep: ?string): string { obj = obj || {} pairSep = typeof pairSep === 'string' ? pairSep : '&' keyValueSep = typeof keyValueSep === 'string' ? keyValueSep : '=' // $FlowIgnore return Object.keys(obj).map(k => `${k}${keyValueSep}${encodeURIComponent(obj[k])}`).join(pairSep) }