inline-request.js 476 B

12345678910111213141516171819202122
  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;