(origin, {
path,
method,
body,
headers,
query,
idempotent,
blocking,
upgrade,
headersTimeout,
bodyTimeout,
reset,
expectContinue,
servername,
throwOnError,
maxRedirections,
typeOfService
}, handler)
| 96 | |
| 97 | class Request { |
| 98 | constructor (origin, { |
| 99 | path, |
| 100 | method, |
| 101 | body, |
| 102 | headers, |
| 103 | query, |
| 104 | idempotent, |
| 105 | blocking, |
| 106 | upgrade, |
| 107 | headersTimeout, |
| 108 | bodyTimeout, |
| 109 | reset, |
| 110 | expectContinue, |
| 111 | servername, |
| 112 | throwOnError, |
| 113 | maxRedirections, |
| 114 | typeOfService |
| 115 | }, handler) { |
| 116 | if (typeof path !== 'string') { |
| 117 | throw new InvalidArgumentError('path must be a string') |
| 118 | } else if ( |
| 119 | path[0] !== '/' && |
| 120 | !(path.startsWith('http://') || path.startsWith('https://')) && |
| 121 | method !== 'CONNECT' |
| 122 | ) { |
| 123 | throw new InvalidArgumentError('path must be an absolute URL or start with a slash') |
| 124 | } else if (invalidPathRegex.test(path)) { |
| 125 | throw new InvalidArgumentError('invalid request path') |
| 126 | } |
| 127 | |
| 128 | if (typeof method !== 'string') { |
| 129 | throw new InvalidArgumentError('method must be a string') |
| 130 | } else if (normalizedMethodRecords[method] === undefined && !isValidHTTPToken(method)) { |
| 131 | throw new InvalidArgumentError('invalid request method') |
| 132 | } |
| 133 | |
| 134 | if (upgrade && typeof upgrade !== 'string') { |
| 135 | throw new InvalidArgumentError('upgrade must be a string') |
| 136 | } |
| 137 | |
| 138 | if (upgrade && !isValidHeaderValue(upgrade)) { |
| 139 | throw new InvalidArgumentError('invalid upgrade header') |
| 140 | } |
| 141 | |
| 142 | if (headersTimeout != null && (!Number.isFinite(headersTimeout) || headersTimeout < 0)) { |
| 143 | throw new InvalidArgumentError('invalid headersTimeout') |
| 144 | } |
| 145 | |
| 146 | if (bodyTimeout != null && (!Number.isFinite(bodyTimeout) || bodyTimeout < 0)) { |
| 147 | throw new InvalidArgumentError('invalid bodyTimeout') |
| 148 | } |
| 149 | |
| 150 | if (reset != null && typeof reset !== 'boolean') { |
| 151 | throw new InvalidArgumentError('invalid reset') |
| 152 | } |
| 153 | |
| 154 | if (expectContinue != null && typeof expectContinue !== 'boolean') { |
| 155 | throw new InvalidArgumentError('invalid expectContinue') |
nothing calls this directly
no test coverage detected