http.js 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. 'use strict';
  2. import utils from './../utils.js';
  3. import settle from './../core/settle.js';
  4. import buildFullPath from '../core/buildFullPath.js';
  5. import buildURL from './../helpers/buildURL.js';
  6. import {getProxyForUrl} from 'proxy-from-env';
  7. import http from 'http';
  8. import https from 'https';
  9. import util from 'util';
  10. import followRedirects from 'follow-redirects';
  11. import zlib from 'zlib';
  12. import {VERSION} from '../env/data.js';
  13. import transitionalDefaults from '../defaults/transitional.js';
  14. import AxiosError from '../core/AxiosError.js';
  15. import CanceledError from '../cancel/CanceledError.js';
  16. import platform from '../platform/index.js';
  17. import fromDataURI from '../helpers/fromDataURI.js';
  18. import stream from 'stream';
  19. import AxiosHeaders from '../core/AxiosHeaders.js';
  20. import AxiosTransformStream from '../helpers/AxiosTransformStream.js';
  21. import {EventEmitter} from 'events';
  22. import formDataToStream from "../helpers/formDataToStream.js";
  23. import readBlob from "../helpers/readBlob.js";
  24. import ZlibHeaderTransformStream from '../helpers/ZlibHeaderTransformStream.js';
  25. import callbackify from "../helpers/callbackify.js";
  26. const zlibOptions = {
  27. flush: zlib.constants.Z_SYNC_FLUSH,
  28. finishFlush: zlib.constants.Z_SYNC_FLUSH
  29. };
  30. const brotliOptions = {
  31. flush: zlib.constants.BROTLI_OPERATION_FLUSH,
  32. finishFlush: zlib.constants.BROTLI_OPERATION_FLUSH
  33. }
  34. const isBrotliSupported = utils.isFunction(zlib.createBrotliDecompress);
  35. const {http: httpFollow, https: httpsFollow} = followRedirects;
  36. const isHttps = /https:?/;
  37. const supportedProtocols = platform.protocols.map(protocol => {
  38. return protocol + ':';
  39. });
  40. /**
  41. * If the proxy or config beforeRedirects functions are defined, call them with the options
  42. * object.
  43. *
  44. * @param {Object<string, any>} options - The options object that was passed to the request.
  45. *
  46. * @returns {Object<string, any>}
  47. */
  48. function dispatchBeforeRedirect(options, responseDetails) {
  49. if (options.beforeRedirects.proxy) {
  50. options.beforeRedirects.proxy(options);
  51. }
  52. if (options.beforeRedirects.config) {
  53. options.beforeRedirects.config(options, responseDetails);
  54. }
  55. }
  56. /**
  57. * If the proxy or config afterRedirects functions are defined, call them with the options
  58. *
  59. * @param {http.ClientRequestArgs} options
  60. * @param {AxiosProxyConfig} configProxy configuration from Axios options object
  61. * @param {string} location
  62. *
  63. * @returns {http.ClientRequestArgs}
  64. */
  65. function setProxy(options, configProxy, location) {
  66. let proxy = configProxy;
  67. if (!proxy && proxy !== false) {
  68. const proxyUrl = getProxyForUrl(location);
  69. if (proxyUrl) {
  70. proxy = new URL(proxyUrl);
  71. }
  72. }
  73. if (proxy) {
  74. // Basic proxy authorization
  75. if (proxy.username) {
  76. proxy.auth = (proxy.username || '') + ':' + (proxy.password || '');
  77. }
  78. if (proxy.auth) {
  79. // Support proxy auth object form
  80. if (proxy.auth.username || proxy.auth.password) {
  81. proxy.auth = (proxy.auth.username || '') + ':' + (proxy.auth.password || '');
  82. }
  83. const base64 = Buffer
  84. .from(proxy.auth, 'utf8')
  85. .toString('base64');
  86. options.headers['Proxy-Authorization'] = 'Basic ' + base64;
  87. }
  88. options.headers.host = options.hostname + (options.port ? ':' + options.port : '');
  89. const proxyHost = proxy.hostname || proxy.host;
  90. options.hostname = proxyHost;
  91. // Replace 'host' since options is not a URL object
  92. options.host = proxyHost;
  93. options.port = proxy.port;
  94. options.path = location;
  95. if (proxy.protocol) {
  96. options.protocol = proxy.protocol.includes(':') ? proxy.protocol : `${proxy.protocol}:`;
  97. }
  98. }
  99. options.beforeRedirects.proxy = function beforeRedirect(redirectOptions) {
  100. // Configure proxy for redirected request, passing the original config proxy to apply
  101. // the exact same logic as if the redirected request was performed by axios directly.
  102. setProxy(redirectOptions, configProxy, redirectOptions.href);
  103. };
  104. }
  105. const isHttpAdapterSupported = typeof process !== 'undefined' && utils.kindOf(process) === 'process';
  106. // temporary hotfix
  107. const wrapAsync = (asyncExecutor) => {
  108. return new Promise((resolve, reject) => {
  109. let onDone;
  110. let isDone;
  111. const done = (value, isRejected) => {
  112. if (isDone) return;
  113. isDone = true;
  114. onDone && onDone(value, isRejected);
  115. }
  116. const _resolve = (value) => {
  117. done(value);
  118. resolve(value);
  119. };
  120. const _reject = (reason) => {
  121. done(reason, true);
  122. reject(reason);
  123. }
  124. asyncExecutor(_resolve, _reject, (onDoneHandler) => (onDone = onDoneHandler)).catch(_reject);
  125. })
  126. };
  127. const resolveFamily = ({address, family}) => {
  128. if (!utils.isString(address)) {
  129. throw TypeError('address must be a string');
  130. }
  131. return ({
  132. address,
  133. family: family || (address.indexOf('.') < 0 ? 6 : 4)
  134. });
  135. }
  136. const buildAddressEntry = (address, family) => resolveFamily(utils.isObject(address) ? address : {address, family});
  137. /*eslint consistent-return:0*/
  138. export default isHttpAdapterSupported && function httpAdapter(config) {
  139. return wrapAsync(async function dispatchHttpRequest(resolve, reject, onDone) {
  140. let {data, lookup, family} = config;
  141. const {responseType, responseEncoding} = config;
  142. const method = config.method.toUpperCase();
  143. let isDone;
  144. let rejected = false;
  145. let req;
  146. if (lookup) {
  147. const _lookup = callbackify(lookup, (value) => utils.isArray(value) ? value : [value]);
  148. // hotfix to support opt.all option which is required for node 20.x
  149. lookup = (hostname, opt, cb) => {
  150. _lookup(hostname, opt, (err, arg0, arg1) => {
  151. if (err) {
  152. return cb(err);
  153. }
  154. const addresses = utils.isArray(arg0) ? arg0.map(addr => buildAddressEntry(addr)) : [buildAddressEntry(arg0, arg1)];
  155. opt.all ? cb(err, addresses) : cb(err, addresses[0].address, addresses[0].family);
  156. });
  157. }
  158. }
  159. // temporary internal emitter until the AxiosRequest class will be implemented
  160. const emitter = new EventEmitter();
  161. const onFinished = () => {
  162. if (config.cancelToken) {
  163. config.cancelToken.unsubscribe(abort);
  164. }
  165. if (config.signal) {
  166. config.signal.removeEventListener('abort', abort);
  167. }
  168. emitter.removeAllListeners();
  169. }
  170. onDone((value, isRejected) => {
  171. isDone = true;
  172. if (isRejected) {
  173. rejected = true;
  174. onFinished();
  175. }
  176. });
  177. function abort(reason) {
  178. emitter.emit('abort', !reason || reason.type ? new CanceledError(null, config, req) : reason);
  179. }
  180. emitter.once('abort', reject);
  181. if (config.cancelToken || config.signal) {
  182. config.cancelToken && config.cancelToken.subscribe(abort);
  183. if (config.signal) {
  184. config.signal.aborted ? abort() : config.signal.addEventListener('abort', abort);
  185. }
  186. }
  187. // Parse url
  188. const fullPath = buildFullPath(config.baseURL, config.url);
  189. const parsed = new URL(fullPath, 'http://localhost');
  190. const protocol = parsed.protocol || supportedProtocols[0];
  191. if (protocol === 'data:') {
  192. let convertedData;
  193. if (method !== 'GET') {
  194. return settle(resolve, reject, {
  195. status: 405,
  196. statusText: 'method not allowed',
  197. headers: {},
  198. config
  199. });
  200. }
  201. try {
  202. convertedData = fromDataURI(config.url, responseType === 'blob', {
  203. Blob: config.env && config.env.Blob
  204. });
  205. } catch (err) {
  206. throw AxiosError.from(err, AxiosError.ERR_BAD_REQUEST, config);
  207. }
  208. if (responseType === 'text') {
  209. convertedData = convertedData.toString(responseEncoding);
  210. if (!responseEncoding || responseEncoding === 'utf8') {
  211. convertedData = utils.stripBOM(convertedData);
  212. }
  213. } else if (responseType === 'stream') {
  214. convertedData = stream.Readable.from(convertedData);
  215. }
  216. return settle(resolve, reject, {
  217. data: convertedData,
  218. status: 200,
  219. statusText: 'OK',
  220. headers: new AxiosHeaders(),
  221. config
  222. });
  223. }
  224. if (supportedProtocols.indexOf(protocol) === -1) {
  225. return reject(new AxiosError(
  226. 'Unsupported protocol ' + protocol,
  227. AxiosError.ERR_BAD_REQUEST,
  228. config
  229. ));
  230. }
  231. const headers = AxiosHeaders.from(config.headers).normalize();
  232. // Set User-Agent (required by some servers)
  233. // See https://github.com/axios/axios/issues/69
  234. // User-Agent is specified; handle case where no UA header is desired
  235. // Only set header if it hasn't been set in config
  236. headers.set('User-Agent', 'axios/' + VERSION, false);
  237. const onDownloadProgress = config.onDownloadProgress;
  238. const onUploadProgress = config.onUploadProgress;
  239. const maxRate = config.maxRate;
  240. let maxUploadRate = undefined;
  241. let maxDownloadRate = undefined;
  242. // support for spec compliant FormData objects
  243. if (utils.isSpecCompliantForm(data)) {
  244. const userBoundary = headers.getContentType(/boundary=([-_\w\d]{10,70})/i);
  245. data = formDataToStream(data, (formHeaders) => {
  246. headers.set(formHeaders);
  247. }, {
  248. tag: `axios-${VERSION}-boundary`,
  249. boundary: userBoundary && userBoundary[1] || undefined
  250. });
  251. // support for https://www.npmjs.com/package/form-data api
  252. } else if (utils.isFormData(data) && utils.isFunction(data.getHeaders)) {
  253. headers.set(data.getHeaders());
  254. if (!headers.hasContentLength()) {
  255. try {
  256. const knownLength = await util.promisify(data.getLength).call(data);
  257. Number.isFinite(knownLength) && knownLength >= 0 && headers.setContentLength(knownLength);
  258. /*eslint no-empty:0*/
  259. } catch (e) {
  260. }
  261. }
  262. } else if (utils.isBlob(data)) {
  263. data.size && headers.setContentType(data.type || 'application/octet-stream');
  264. headers.setContentLength(data.size || 0);
  265. data = stream.Readable.from(readBlob(data));
  266. } else if (data && !utils.isStream(data)) {
  267. if (Buffer.isBuffer(data)) {
  268. // Nothing to do...
  269. } else if (utils.isArrayBuffer(data)) {
  270. data = Buffer.from(new Uint8Array(data));
  271. } else if (utils.isString(data)) {
  272. data = Buffer.from(data, 'utf-8');
  273. } else {
  274. return reject(new AxiosError(
  275. 'Data after transformation must be a string, an ArrayBuffer, a Buffer, or a Stream',
  276. AxiosError.ERR_BAD_REQUEST,
  277. config
  278. ));
  279. }
  280. // Add Content-Length header if data exists
  281. headers.setContentLength(data.length, false);
  282. if (config.maxBodyLength > -1 && data.length > config.maxBodyLength) {
  283. return reject(new AxiosError(
  284. 'Request body larger than maxBodyLength limit',
  285. AxiosError.ERR_BAD_REQUEST,
  286. config
  287. ));
  288. }
  289. }
  290. const contentLength = utils.toFiniteNumber(headers.getContentLength());
  291. if (utils.isArray(maxRate)) {
  292. maxUploadRate = maxRate[0];
  293. maxDownloadRate = maxRate[1];
  294. } else {
  295. maxUploadRate = maxDownloadRate = maxRate;
  296. }
  297. if (data && (onUploadProgress || maxUploadRate)) {
  298. if (!utils.isStream(data)) {
  299. data = stream.Readable.from(data, {objectMode: false});
  300. }
  301. data = stream.pipeline([data, new AxiosTransformStream({
  302. length: contentLength,
  303. maxRate: utils.toFiniteNumber(maxUploadRate)
  304. })], utils.noop);
  305. onUploadProgress && data.on('progress', progress => {
  306. onUploadProgress(Object.assign(progress, {
  307. upload: true
  308. }));
  309. });
  310. }
  311. // HTTP basic authentication
  312. let auth = undefined;
  313. if (config.auth) {
  314. const username = config.auth.username || '';
  315. const password = config.auth.password || '';
  316. auth = username + ':' + password;
  317. }
  318. if (!auth && parsed.username) {
  319. const urlUsername = parsed.username;
  320. const urlPassword = parsed.password;
  321. auth = urlUsername + ':' + urlPassword;
  322. }
  323. auth && headers.delete('authorization');
  324. let path;
  325. try {
  326. path = buildURL(
  327. parsed.pathname + parsed.search,
  328. config.params,
  329. config.paramsSerializer
  330. ).replace(/^\?/, '');
  331. } catch (err) {
  332. const customErr = new Error(err.message);
  333. customErr.config = config;
  334. customErr.url = config.url;
  335. customErr.exists = true;
  336. return reject(customErr);
  337. }
  338. headers.set(
  339. 'Accept-Encoding',
  340. 'gzip, compress, deflate' + (isBrotliSupported ? ', br' : ''), false
  341. );
  342. const options = {
  343. path,
  344. method: method,
  345. headers: headers.toJSON(),
  346. agents: { http: config.httpAgent, https: config.httpsAgent },
  347. auth,
  348. protocol,
  349. family,
  350. beforeRedirect: dispatchBeforeRedirect,
  351. beforeRedirects: {}
  352. };
  353. // cacheable-lookup integration hotfix
  354. !utils.isUndefined(lookup) && (options.lookup = lookup);
  355. if (config.socketPath) {
  356. options.socketPath = config.socketPath;
  357. } else {
  358. options.hostname = parsed.hostname;
  359. options.port = parsed.port;
  360. setProxy(options, config.proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
  361. }
  362. let transport;
  363. const isHttpsRequest = isHttps.test(options.protocol);
  364. options.agent = isHttpsRequest ? config.httpsAgent : config.httpAgent;
  365. if (config.transport) {
  366. transport = config.transport;
  367. } else if (config.maxRedirects === 0) {
  368. transport = isHttpsRequest ? https : http;
  369. } else {
  370. if (config.maxRedirects) {
  371. options.maxRedirects = config.maxRedirects;
  372. }
  373. if (config.beforeRedirect) {
  374. options.beforeRedirects.config = config.beforeRedirect;
  375. }
  376. transport = isHttpsRequest ? httpsFollow : httpFollow;
  377. }
  378. if (config.maxBodyLength > -1) {
  379. options.maxBodyLength = config.maxBodyLength;
  380. } else {
  381. // follow-redirects does not skip comparison, so it should always succeed for axios -1 unlimited
  382. options.maxBodyLength = Infinity;
  383. }
  384. if (config.insecureHTTPParser) {
  385. options.insecureHTTPParser = config.insecureHTTPParser;
  386. }
  387. // Create the request
  388. req = transport.request(options, function handleResponse(res) {
  389. if (req.destroyed) return;
  390. const streams = [res];
  391. const responseLength = +res.headers['content-length'];
  392. if (onDownloadProgress) {
  393. const transformStream = new AxiosTransformStream({
  394. length: utils.toFiniteNumber(responseLength),
  395. maxRate: utils.toFiniteNumber(maxDownloadRate)
  396. });
  397. onDownloadProgress && transformStream.on('progress', progress => {
  398. onDownloadProgress(Object.assign(progress, {
  399. download: true
  400. }));
  401. });
  402. streams.push(transformStream);
  403. }
  404. // decompress the response body transparently if required
  405. let responseStream = res;
  406. // return the last request in case of redirects
  407. const lastRequest = res.req || req;
  408. // if decompress disabled we should not decompress
  409. if (config.decompress !== false && res.headers['content-encoding']) {
  410. // if no content, but headers still say that it is encoded,
  411. // remove the header not confuse downstream operations
  412. if (method === 'HEAD' || res.statusCode === 204) {
  413. delete res.headers['content-encoding'];
  414. }
  415. switch ((res.headers['content-encoding'] || '').toLowerCase()) {
  416. /*eslint default-case:0*/
  417. case 'gzip':
  418. case 'x-gzip':
  419. case 'compress':
  420. case 'x-compress':
  421. // add the unzipper to the body stream processing pipeline
  422. streams.push(zlib.createUnzip(zlibOptions));
  423. // remove the content-encoding in order to not confuse downstream operations
  424. delete res.headers['content-encoding'];
  425. break;
  426. case 'deflate':
  427. streams.push(new ZlibHeaderTransformStream());
  428. // add the unzipper to the body stream processing pipeline
  429. streams.push(zlib.createUnzip(zlibOptions));
  430. // remove the content-encoding in order to not confuse downstream operations
  431. delete res.headers['content-encoding'];
  432. break;
  433. case 'br':
  434. if (isBrotliSupported) {
  435. streams.push(zlib.createBrotliDecompress(brotliOptions));
  436. delete res.headers['content-encoding'];
  437. }
  438. }
  439. }
  440. responseStream = streams.length > 1 ? stream.pipeline(streams, utils.noop) : streams[0];
  441. const offListeners = stream.finished(responseStream, () => {
  442. offListeners();
  443. onFinished();
  444. });
  445. const response = {
  446. status: res.statusCode,
  447. statusText: res.statusMessage,
  448. headers: new AxiosHeaders(res.headers),
  449. config,
  450. request: lastRequest
  451. };
  452. if (responseType === 'stream') {
  453. response.data = responseStream;
  454. settle(resolve, reject, response);
  455. } else {
  456. const responseBuffer = [];
  457. let totalResponseBytes = 0;
  458. responseStream.on('data', function handleStreamData(chunk) {
  459. responseBuffer.push(chunk);
  460. totalResponseBytes += chunk.length;
  461. // make sure the content length is not over the maxContentLength if specified
  462. if (config.maxContentLength > -1 && totalResponseBytes > config.maxContentLength) {
  463. // stream.destroy() emit aborted event before calling reject() on Node.js v16
  464. rejected = true;
  465. responseStream.destroy();
  466. reject(new AxiosError('maxContentLength size of ' + config.maxContentLength + ' exceeded',
  467. AxiosError.ERR_BAD_RESPONSE, config, lastRequest));
  468. }
  469. });
  470. responseStream.on('aborted', function handlerStreamAborted() {
  471. if (rejected) {
  472. return;
  473. }
  474. const err = new AxiosError(
  475. 'maxContentLength size of ' + config.maxContentLength + ' exceeded',
  476. AxiosError.ERR_BAD_RESPONSE,
  477. config,
  478. lastRequest
  479. );
  480. responseStream.destroy(err);
  481. reject(err);
  482. });
  483. responseStream.on('error', function handleStreamError(err) {
  484. if (req.destroyed) return;
  485. reject(AxiosError.from(err, null, config, lastRequest));
  486. });
  487. responseStream.on('end', function handleStreamEnd() {
  488. try {
  489. let responseData = responseBuffer.length === 1 ? responseBuffer[0] : Buffer.concat(responseBuffer);
  490. if (responseType !== 'arraybuffer') {
  491. responseData = responseData.toString(responseEncoding);
  492. if (!responseEncoding || responseEncoding === 'utf8') {
  493. responseData = utils.stripBOM(responseData);
  494. }
  495. }
  496. response.data = responseData;
  497. } catch (err) {
  498. return reject(AxiosError.from(err, null, config, response.request, response));
  499. }
  500. settle(resolve, reject, response);
  501. });
  502. }
  503. emitter.once('abort', err => {
  504. if (!responseStream.destroyed) {
  505. responseStream.emit('error', err);
  506. responseStream.destroy();
  507. }
  508. });
  509. });
  510. emitter.once('abort', err => {
  511. reject(err);
  512. req.destroy(err);
  513. });
  514. // Handle errors
  515. req.on('error', function handleRequestError(err) {
  516. // @todo remove
  517. // if (req.aborted && err.code !== AxiosError.ERR_FR_TOO_MANY_REDIRECTS) return;
  518. reject(AxiosError.from(err, null, config, req));
  519. });
  520. // set tcp keep alive to prevent drop connection by peer
  521. req.on('socket', function handleRequestSocket(socket) {
  522. // default interval of sending ack packet is 1 minute
  523. socket.setKeepAlive(true, 1000 * 60);
  524. });
  525. // Handle request timeout
  526. if (config.timeout) {
  527. // This is forcing a int timeout to avoid problems if the `req` interface doesn't handle other types.
  528. const timeout = parseInt(config.timeout, 10);
  529. if (Number.isNaN(timeout)) {
  530. reject(new AxiosError(
  531. 'error trying to parse `config.timeout` to int',
  532. AxiosError.ERR_BAD_OPTION_VALUE,
  533. config,
  534. req
  535. ));
  536. return;
  537. }
  538. // Sometime, the response will be very slow, and does not respond, the connect event will be block by event loop system.
  539. // And timer callback will be fired, and abort() will be invoked before connection, then get "socket hang up" and code ECONNRESET.
  540. // At this time, if we have a large number of request, nodejs will hang up some socket on background. and the number will up and up.
  541. // And then these socket which be hang up will devouring CPU little by little.
  542. // ClientRequest.setTimeout will be fired on the specify milliseconds, and can make sure that abort() will be fired after connect.
  543. req.setTimeout(timeout, function handleRequestTimeout() {
  544. if (isDone) return;
  545. let timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
  546. const transitional = config.transitional || transitionalDefaults;
  547. if (config.timeoutErrorMessage) {
  548. timeoutErrorMessage = config.timeoutErrorMessage;
  549. }
  550. reject(new AxiosError(
  551. timeoutErrorMessage,
  552. transitional.clarifyTimeoutError ? AxiosError.ETIMEDOUT : AxiosError.ECONNABORTED,
  553. config,
  554. req
  555. ));
  556. abort();
  557. });
  558. }
  559. // Send the request
  560. if (utils.isStream(data)) {
  561. let ended = false;
  562. let errored = false;
  563. data.on('end', () => {
  564. ended = true;
  565. });
  566. data.once('error', err => {
  567. errored = true;
  568. req.destroy(err);
  569. });
  570. data.on('close', () => {
  571. if (!ended && !errored) {
  572. abort(new CanceledError('Request stream has been aborted', config, req));
  573. }
  574. });
  575. data.pipe(req);
  576. } else {
  577. req.end(data);
  578. }
  579. });
  580. }
  581. export const __setProxy = setProxy;