Buckets:
| const url = require('url') | |
| const tunnel = require('tunnel-agent') | |
| const util = require('./util') | |
| function applyProxy (reqOpts, opts) { | |
| const log = opts.log || util.noopLogger | |
| const proxy = opts['https-proxy'] || opts.proxy | |
| if (proxy) { | |
| // eslint-disable-next-line node/no-deprecated-api | |
| const parsedDownloadUrl = url.parse(reqOpts.url) | |
| // eslint-disable-next-line node/no-deprecated-api | |
| const parsedProxy = url.parse(proxy) | |
| const uriProtocol = (parsedDownloadUrl.protocol === 'https:' ? 'https' : 'http') | |
| const proxyProtocol = (parsedProxy.protocol === 'https:' ? 'Https' : 'Http') | |
| const tunnelFnName = [uriProtocol, proxyProtocol].join('Over') | |
| reqOpts.agent = tunnel[tunnelFnName]({ | |
| proxy: { | |
| host: parsedProxy.hostname, | |
| port: +parsedProxy.port, | |
| proxyAuth: parsedProxy.auth | |
| } | |
| }) | |
| log.http('request', 'Proxy setup detected (Host: ' + | |
| parsedProxy.hostname + ', Port: ' + | |
| parsedProxy.port + ', Authentication: ' + | |
| (parsedProxy.auth ? 'Yes' : 'No') + ')' + | |
| ' Tunneling with ' + tunnelFnName) | |
| } | |
| return reqOpts | |
| } | |
| module.exports = applyProxy | |
Xet Storage Details
- Size:
- 1.15 kB
- Xet hash:
- de06afc227b51db406db5a78d49a99120d62dc77ae3e087227170bf21dfc57b2
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.