Lines Matching refs:response

11 } = require('./response')
196 // 12. Let handleFetchDone given response response be to finalize and
197 // report timing with response, globalObject, and "fetch".
198 const handleFetchDone = (response) =>
199 finalizeAndReportTiming(response, 'fetch')
203 // given response being these substeps:
205 const processResponse = (response) => {
211 // 2. If response’s aborted flag is set, then:
212 if (response.aborted) {
224 // 3. If response is a network error, then reject p with a TypeError
226 if (response.type === 'error') {
228 Object.assign(new TypeError('fetch failed'), { cause: response.error })
234 // given response, "immutable", and relevantRealm.
236 responseObject[kState] = response
238 responseObject[kHeaders][kHeadersList] = response.headersList
258 function finalizeAndReportTiming (response, initiatorType = 'other') {
259 // 1. If response is an aborted network error, then return.
260 if (response.type === 'error' && response.aborted) {
264 // 2. If response’s URL list is null or empty, then return.
265 if (!response.urlList?.length) {
269 // 3. Let originalURL be response’s URL list[0].
270 const originalURL = response.urlList[0]
272 // 4. Let timingInfo be response’s timing info.
273 let timingInfo = response.timingInfo
275 // 5. Let cacheState be response’s cache state.
276 let cacheState = response.cacheState
288 // 8. If response’s timing allow passed flag is not set, then:
289 if (!response.timingAllowPassed) {
306 // 10. Set response’s timing info to timingInfo.
307 response.timingInfo = timingInfo
356 // 4. Let response be responseObject’s response.
357 const response = responseObject[kState]
359 // 5. If response’s body is not null and is readable, then error response’s
361 if (response.body != null && isReadable(response.body?.stream)) {
362 response.body.stream.cancel(error).catch((err) => {
417 // process response is processResponse,
418 // process response consume body is processResponseConsumeBody,
419 // process response end-of-body is processResponseEndOfBody,
532 // 2. Let response be null.
533 let response = null
536 // not local, then set response to a network error.
538 response = makeNetworkError('local URLs only')
549 // Security Policy returns blocked, then set response to a network error.
551 response = makeNetworkError('bad port')
581 // 11. If response is null, then set response to the result of running
583 if (response === null) {
584 response = await (async () => {
589 // and request’s response tainting is "basic"
596 // 1. Set request’s response tainting to "basic".
619 // 2. Set request’s response tainting to "opaque".
636 // 1. Set request’s response tainting to "cors".
645 // 1. Set request’s response tainting to "cors".
653 // 12. If recursive is true, then return response.
655 return response
658 // 13. If response is not a network error and response is not a filtered
659 // response, then:
660 if (response.status !== 0 && !response.internalResponse) {
661 // If request’s response tainting is "cors", then:
664 // given `Access-Control-Expose-Headers` and response’s header list.
667 // contains `*`, then set response’s CORS-exposed header-name list to
668 // all unique header names in response’s header list.
671 // response’s CORS-exposed header-name list to headerNames.
675 // Set response to the following filtered response with response as its
676 // internal response, depending on request’s response tainting:
678 response = filterResponse(response, 'basic')
680 response = filterResponse(response, 'cors')
682 response = filterResponse(response, 'opaque')
688 // 14. Let internalResponse be response, if response is a network error,
689 // and response’s internal response otherwise.
691 response.status === 0 ? response : response.internalResponse
702 response.timingAllowPassed = true
705 // 17. If response is not a network error and any of the following returns
713 // 18. If response’s type is "opaque", internalResponse’s status is 206,
715 // list does not contain `Range`, then set response and internalResponse
718 response.type === 'opaque' &&
723 response = internalResponse = makeNetworkError()
726 // 19. If response is not a network error and either request’s method is
731 response.status !== 0 &&
747 // 2. If request’s response tainting is "opaque", or response’s body is null,
749 if (request.responseTainting === 'opaque' || response.body == null) {
750 processBodyError(response.error)
763 // 2. Set response’s body to bytes as a body.
764 response.body = safelyExtractBody(bytes)[0]
766 // 3. Run fetch finale given fetchParams and response.
767 fetchFinale(fetchParams, response)
770 // 4. Fully read response’s body given processBody and processBodyError.
771 await fullyReadBody(response.body, processBody, processBodyError)
773 // 21. Otherwise, run fetch finale given fetchParams and response.
774 fetchFinale(fetchParams, response)
797 // If request’s current URL’s path is the string "blank", then return a new response
838 // 7. Return a new response whose status message is `OK`, header list is
840 const response = makeResponse({
848 response.body = body
850 return Promise.resolve(response)
867 // 4. Return a response whose status message is `OK`,
896 // https://fetch.spec.whatwg.org/#finalize-response
897 function finalizeResponse (fetchParams, response) {
901 // 2, If fetchParams’s process response done is not null, then queue a fetch
902 // task to run fetchParams’s process response done given response, with
905 queueMicrotask(() => fetchParams.processResponseDone(response))
910 function fetchFinale (fetchParams, response) {
911 // 1. If response is a network error, then:
912 if (response.type === 'error') {
913 // 1. Set response’s URL list to « fetchParams’s request’s URL list[0] ».
914 response.urlList = [fetchParams.request.urlList[0]]
916 // 2. Set response’s timing info to the result of creating an opaque timing
918 response.timingInfo = createOpaqueTimingInfo({
928 // If fetchParams’s process response end-of-body is not null,
929 // then queue a fetch task to run fetchParams’s process response
930 // end-of-body given response with fetchParams’s task destination.
932 queueMicrotask(() => fetchParams.processResponseEndOfBody(response))
936 // 3. If fetchParams’s process response is non-null, then queue a fetch task
937 // to run fetchParams’s process response given response, with fetchParams’s
940 queueMicrotask(() => fetchParams.processResponse(response))
943 // 4. If response’s body is null, then run processResponseEndOfBody.
944 if (response.body == null) {
973 // 4. Set response’s body to the result of piping response’s body through transformStream.
974 response.body = { stream: response.body.stream.pipeThrough(transformStream) }
977 // 6. If fetchParams’s process response consume body is non-null, then:
980 // process response consume body given response and nullOrBytes.
981 const processBody = (nullOrBytes) => fetchParams.processResponseConsumeBody(response, nullOrBytes)
984 // response consume body given response and failure.
985 const processBodyError = (failure) => fetchParams.processResponseConsumeBody(response, failure)
987 // 3. If response’s body is null, then queue a fetch task to run processBody
989 if (response.body == null) {
992 // 4. Otherwise, fully read response’s body given processBody, processBodyError,
994 return fullyReadBody(response.body, processBody, processBodyError)
1005 // 2. Let response be null.
1006 let response = null
1019 // 6. If response is null, then:
1020 if (response === null) {
1030 // 3. Set response and actualResponse to the result of running
1032 actualResponse = response = await httpNetworkOrCacheFetch(fetchParams)
1034 // 4. If request’s response tainting is "cors" and a CORS check
1035 // for request and response returns failure, then return a network error.
1038 corsCheck(request, response) === 'failure'
1043 // 5. If the TAO check for request and response returns failure, then set
1045 if (TAOCheck(request, response) === 'failure') {
1050 // 7. If either request’s response tainting or response’s type
1055 (request.responseTainting === 'opaque' || response.type === 'opaque') &&
1078 // Set response to a network error.
1079 response = makeNetworkError('unexpected redirect')
1081 // Set response to an opaque-redirect filtered response whose internal
1082 // response is actualResponse.
1083 // NOTE(spec): On the web this would return an `opaqueredirect` response,
1086 response = actualResponse
1088 // Set response to the result of running HTTP-redirect fetch given
1089 // fetchParams and response.
1090 response = await httpRedirectFetch(fetchParams, response)
1096 // 9. Set response’s timing info to timingInfo.
1097 response.timingInfo = timingInfo
1099 // 10. Return response.
1100 return response
1104 function httpRedirectFetch (fetchParams, response) {
1108 // 2. Let actualResponse be response, if response is not a filtered response,
1109 // and response’s internal response otherwise.
1110 const actualResponse = response.internalResponse
1111 ? response.internalResponse
1112 : response
1124 // 4. If locationURL is null, then return response.
1126 return response
1158 // 10. If request’s response tainting is "cors" and locationURL includes
1262 // 4. Let response be null.
1263 let response = null
1451 // 10. If response is null, then:
1452 if (response == null) {
1485 // 5. If response is null, then:
1486 if (response == null) {
1487 // 1. Set response to forwardResponse.
1488 response = forwardResponse
1496 // 11. Set response’s URL list to a clone of httpRequest’s URL list.
1497 response.urlList = [...httpRequest.urlList]
1499 // 12. If httpRequest’s header list contains `Range`, then set response’s
1502 response.rangeRequested = true
1505 // 13. Set response’s request-includes-credentials to includeCredentials.
1506 response.requestIncludesCredentials = includeCredentials
1508 // 14. If response’s status is 401, httpRequest’s response tainting is not
1513 // 15. If response’s status is 407, then:
1514 if (response.status === 407) {
1531 // 5. Set response to the result of running HTTP-network-or-cache fetch given
1539 // response’s status is 421
1540 response.status === 421 &&
1553 // 2. Set response to the result of running HTTP-network-or-cache
1557 // the active response before we can start a new one.
1561 response = await httpNetworkOrCacheFetch(
1573 // 18. Return response.
1574 return response
1599 // 2. Let response be null.
1600 let response = null
1652 // 5. Set response to the result of making an HTTP request over connection
1664 // - Set timingInfo’s final network-response start time to the coarsened
1667 // of the response (e.g., frame header bytes for HTTP/2 or response status
1674 // timingInfo’s final network-response start time above.
1677 // response is transferred via HTTP/1.0 or older, then return a network
1760 response = makeResponse({ status, statusText, headersList, socket })
1765 response = makeResponse({ status, statusText, headersList })
1830 // 1. Set response’s body to a new body whose stream is stream.
1831 response.body = { stream }
1833 // 2. If response is not a network error and request’s cache mode is
1834 // not "no-store", then update response in httpCache for request.
1841 // `Set-Cookie` in response’s header list, if any, and request’s current URL.
1882 // 2. Otherwise, if the bytes transmission for response’s message
1884 // stream, finalize response for fetchParams and response, and
1888 finalizeResponse(fetchParams, response)
1924 // 1. Set response’s aborted flag.
1925 response.aborted = true
1950 // 20. Return response.
1951 return response
2075 // 1. If one or more bytes have been transmitted from response’s
2082 // given `Content-Encoding` and response’s header list.