You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

axios+0.19.2.patch 2.1 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. diff --git a/node_modules/axios/lib/adapters/http.js b/node_modules/axios/lib/adapters/http.js
  2. index 16dad12..0330430 100644
  3. --- a/node_modules/axios/lib/adapters/http.js
  4. +++ b/node_modules/axios/lib/adapters/http.js
  5. @@ -16,6 +16,31 @@ var enhanceError = require('../core/enhanceError');
  6. var isHttps = /https:?/;
  7. +/**
  8. + *
  9. + * @param {http.ClientRequestArgs} options
  10. + * @param {AxiosProxyConfig} proxy
  11. + * @param {string} location
  12. + */
  13. +function setProxy(options, proxy, location) {
  14. + options.hostname = proxy.host;
  15. + options.host = proxy.host;
  16. + options.port = proxy.port;
  17. + options.path = location;
  18. +
  19. + // Basic proxy authorization
  20. + if (proxy.auth) {
  21. + var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
  22. + options.headers['Proxy-Authorization'] = 'Basic ' + base64;
  23. + }
  24. +
  25. + // If a proxy is used, any redirects must also pass through the proxy
  26. + options.beforeRedirect = function beforeRedirect(redirection) {
  27. + redirection.headers.host = redirection.host;
  28. + setProxy(redirection, proxy, redirection.href);
  29. + };
  30. +}
  31. +
  32. /*eslint consistent-return:0*/
  33. module.exports = function httpAdapter(config) {
  34. return new Promise(function dispatchHttpRequest(resolvePromise, rejectPromise) {
  35. @@ -145,17 +170,8 @@ module.exports = function httpAdapter(config) {
  36. }
  37. if (proxy) {
  38. - options.hostname = proxy.host;
  39. - options.host = proxy.host;
  40. options.headers.host = parsed.hostname + (parsed.port ? ':' + parsed.port : '');
  41. - options.port = proxy.port;
  42. - options.path = protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path;
  43. -
  44. - // Basic proxy authorization
  45. - if (proxy.auth) {
  46. - var base64 = Buffer.from(proxy.auth.username + ':' + proxy.auth.password, 'utf8').toString('base64');
  47. - options.headers['Proxy-Authorization'] = 'Basic ' + base64;
  48. - }
  49. + setProxy(options, proxy, protocol + '//' + parsed.hostname + (parsed.port ? ':' + parsed.port : '') + options.path);
  50. }
  51. var transport;