(body, allowH2)
| 2201 | return dispatchWithProtocolPreference(body) |
| 2202 | |
| 2203 | function dispatchWithProtocolPreference (body, allowH2) { |
| 2204 | return new Promise((resolve, reject) => agent.dispatch( |
| 2205 | { |
| 2206 | path: hasTrailingQuestionMark ? `${path}?` : path, |
| 2207 | origin: url.origin, |
| 2208 | method: request.method, |
| 2209 | body: agent.isMockActive ? request.body && (request.body.source || request.body.stream) : body, |
| 2210 | // Preserve the serialized fetch body for MockAgent net-connect fallthroughs. |
| 2211 | __mockAgentBodyForDispatch: body, |
| 2212 | headers: request.headersList.entries, |
| 2213 | maxRedirections: 0, |
| 2214 | upgrade: request.mode === 'websocket' ? 'websocket' : undefined, |
| 2215 | ...(allowH2 === false ? { allowH2 } : null) |
| 2216 | }, |
| 2217 | { |
| 2218 | body: null, |
| 2219 | abort: null, |
| 2220 | |
| 2221 | onRequestStart (controller) { |
| 2222 | // TODO (fix): Do we need connection here? |
| 2223 | const { connection } = fetchParams.controller |
| 2224 | |
| 2225 | // Set timingInfo’s final connection timing info to the result of calling clamp and coarsen |
| 2226 | // connection timing info with connection’s timing info, timingInfo’s post-redirect start |
| 2227 | // time, and fetchParams’s cross-origin isolated capability. |
| 2228 | // TODO: implement connection timing |
| 2229 | timingInfo.finalConnectionTimingInfo = clampAndCoarsenConnectionTimingInfo(undefined, timingInfo.postRedirectStartTime, fetchParams.crossOriginIsolatedCapability) |
| 2230 | |
| 2231 | const abort = (reason) => controller.abort(reason) |
| 2232 | |
| 2233 | if (connection.destroyed) { |
| 2234 | abort(new DOMException('The operation was aborted.', 'AbortError')) |
| 2235 | } else { |
| 2236 | fetchParams.controller.on('terminated', abort) |
| 2237 | this.abort = connection.abort = abort |
| 2238 | } |
| 2239 | |
| 2240 | // Set timingInfo’s final network-request start time to the coarsened shared current time given |
| 2241 | // fetchParams’s cross-origin isolated capability. |
| 2242 | timingInfo.finalNetworkRequestStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability) |
| 2243 | }, |
| 2244 | |
| 2245 | onResponseStarted () { |
| 2246 | // Set timingInfo’s final network-response start time to the coarsened shared current |
| 2247 | // time given fetchParams’s cross-origin isolated capability, immediately after the |
| 2248 | // user agent’s HTTP parser receives the first byte of the response (e.g., frame header |
| 2249 | // bytes for HTTP/2 or response status line for HTTP/1.x). |
| 2250 | timingInfo.finalNetworkResponseStartTime = coarsenedSharedCurrentTime(fetchParams.crossOriginIsolatedCapability) |
| 2251 | }, |
| 2252 | |
| 2253 | onResponseStart (controller, status, headers, statusText) { |
| 2254 | if (status < 200) { |
| 2255 | return |
| 2256 | } |
| 2257 | |
| 2258 | const rawHeaders = controller?.rawHeaders ?? [] |
| 2259 | const headersList = new HeadersList() |
| 2260 | appendHeadersListFromResponseHeaders(headersList, headers, rawHeaders) |
no test coverage detected
searching dependent graphs…