Lines Matching defs:opts
22 function buildProxyOptions (opts) {
23 if (typeof opts === 'string') {
24 opts = { uri: opts }
27 if (!opts || !opts.uri) {
28 throw new InvalidArgumentError('Proxy opts.uri is mandatory')
32 uri: opts.uri,
33 protocol: opts.protocol || 'https'
37 function defaultFactory (origin, opts) {
38 return new Pool(origin, opts)
42 constructor (opts) {
43 super(opts)
44 this[kProxy] = buildProxyOptions(opts)
45 this[kAgent] = new Agent(opts)
46 this[kInterceptors] = opts.interceptors && opts.interceptors.ProxyAgent && Array.isArray(opts.interceptors.ProxyAgent)
47 ? opts.interceptors.ProxyAgent
50 if (typeof opts === 'string') {
51 opts = { uri: opts }
54 if (!opts || !opts.uri) {
55 throw new InvalidArgumentError('Proxy opts.uri is mandatory')
58 const { clientFactory = defaultFactory } = opts
61 throw new InvalidArgumentError('Proxy opts.clientFactory must be a function.')
64 this[kRequestTls] = opts.requestTls
65 this[kProxyTls] = opts.proxyTls
66 this[kProxyHeaders] = opts.headers || {}
68 const resolvedUrl = new URL(opts.uri)
71 if (opts.auth && opts.token) {
72 throw new InvalidArgumentError('opts.auth cannot be used in combination with opts.token')
73 } else if (opts.auth) {
74 /* @deprecated in favour of opts.token */
75 this[kProxyHeaders]['proxy-authorization'] = `Basic ${opts.auth}`
76 } else if (opts.token) {
77 this[kProxyHeaders]['proxy-authorization'] = opts.token
82 const connect = buildConnector({ ...opts.proxyTls })
83 this[kConnectEndpoint] = buildConnector({ ...opts.requestTls })
86 ...opts,
87 connect: async (opts, callback) => {
88 let requestedHost = opts.host
89 if (!opts.port) {
90 requestedHost += `:${defaultProtocolPort(opts.protocol)}`
97 signal: opts.signal,
107 if (opts.protocol !== 'https:') {
115 servername = opts.servername
117 this[kConnectEndpoint]({ ...opts, servername, httpSocket: socket }, callback)
125 dispatch (opts, handler) {
126 const { host } = new URL(opts.origin)
127 const headers = buildHeaders(opts.headers)
131 ...opts,