MCPcopy
hub / github.com/nodejs/undici / constructor

Method constructor

lib/core/request.js:98–280  ·  view source on GitHub ↗
(origin, {
    path,
    method,
    body,
    headers,
    query,
    idempotent,
    blocking,
    upgrade,
    headersTimeout,
    bodyTimeout,
    reset,
    expectContinue,
    servername,
    throwOnError,
    maxRedirections,
    typeOfService
  }, handler)

Source from the content-addressed store, hash-verified

96
97class 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')

Callers

nothing calls this directly

Calls 15

isValidHTTPTokenFunction · 0.85
isStreamFunction · 0.85
isBufferFunction · 0.85
isFormDataLikeFunction · 0.85
isIterableFunction · 0.85
isBlobLikeFunction · 0.85
serializePathWithQueryFunction · 0.85
getProtocolFromUrlStringFunction · 0.85
processHeaderFunction · 0.85
assertRequestHandlerFunction · 0.85
getServerNameFunction · 0.85
isValidHeaderValueFunction · 0.70

Tested by

no test coverage detected