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

22 lines
476 B

4 years ago
  1. var url = require('url');
  2. var override = require('../utils/override');
  3. function inlineRequestFrom(option) {
  4. return override(
  5. /* jshint camelcase: false */
  6. proxyOptionsFrom(process.env.HTTP_PROXY || process.env.http_proxy),
  7. option || {}
  8. );
  9. }
  10. function proxyOptionsFrom(httpProxy) {
  11. return httpProxy ?
  12. {
  13. hostname: url.parse(httpProxy).hostname,
  14. port: parseInt(url.parse(httpProxy).port)
  15. } :
  16. {};
  17. }
  18. module.exports = inlineRequestFrom;