(fetchParams, isAuthenticationFetch = false, isNewConnectionFetch = false)
| 14037 | } |
| 14038 | __name(httpRedirectFetch, "httpRedirectFetch"); |
| 14039 | async function httpNetworkOrCacheFetch(fetchParams, isAuthenticationFetch = false, isNewConnectionFetch = false) { |
| 14040 | const request = fetchParams.request; |
| 14041 | let httpFetchParams = null; |
| 14042 | let httpRequest = null; |
| 14043 | let response = null; |
| 14044 | const httpCache = null; |
| 14045 | const revalidatingFlag = false; |
| 14046 | if (request.window === "no-window" && request.redirect === "error") { |
| 14047 | httpFetchParams = fetchParams; |
| 14048 | httpRequest = request; |
| 14049 | } else { |
| 14050 | httpRequest = cloneRequest(request); |
| 14051 | httpFetchParams = { ...fetchParams }; |
| 14052 | httpFetchParams.request = httpRequest; |
| 14053 | } |
| 14054 | const includeCredentials = request.credentials === "include" || request.credentials === "same-origin" && request.responseTainting === "basic"; |
| 14055 | const contentLength = httpRequest.body ? httpRequest.body.length : null; |
| 14056 | let contentLengthHeaderValue = null; |
| 14057 | if (httpRequest.body == null && ["POST", "PUT"].includes(httpRequest.method)) { |
| 14058 | contentLengthHeaderValue = "0"; |
| 14059 | } |
| 14060 | if (contentLength != null) { |
| 14061 | contentLengthHeaderValue = isomorphicEncode(`${contentLength}`); |
| 14062 | } |
| 14063 | if (contentLengthHeaderValue != null && !httpRequest.headersList.contains("content-length", true)) { |
| 14064 | httpRequest.headersList.append("content-length", contentLengthHeaderValue, true); |
| 14065 | } |
| 14066 | if (contentLength != null && httpRequest.keepalive) { |
| 14067 | } |
| 14068 | if (webidl.is.URL(httpRequest.referrer)) { |
| 14069 | httpRequest.headersList.append("referer", isomorphicEncode(httpRequest.referrer.href), true); |
| 14070 | } |
| 14071 | appendRequestOriginHeader(httpRequest); |
| 14072 | appendFetchMetadata(httpRequest); |
| 14073 | if (!httpRequest.headersList.contains("user-agent", true)) { |
| 14074 | httpRequest.headersList.append("user-agent", defaultUserAgent, true); |
| 14075 | } |
| 14076 | if (httpRequest.cache === "default" && (httpRequest.headersList.contains("if-modified-since", true) || httpRequest.headersList.contains("if-none-match", true) || httpRequest.headersList.contains("if-unmodified-since", true) || httpRequest.headersList.contains("if-match", true) || httpRequest.headersList.contains("if-range", true))) { |
| 14077 | httpRequest.cache = "no-store"; |
| 14078 | } |
| 14079 | if (httpRequest.cache === "no-cache" && !httpRequest.preventNoCacheCacheControlHeaderModification && !httpRequest.headersList.contains("cache-control", true)) { |
| 14080 | httpRequest.headersList.append("cache-control", "max-age=0", true); |
| 14081 | } |
| 14082 | if (httpRequest.cache === "no-store" || httpRequest.cache === "reload") { |
| 14083 | if (!httpRequest.headersList.contains("pragma", true)) { |
| 14084 | httpRequest.headersList.append("pragma", "no-cache", true); |
| 14085 | } |
| 14086 | if (!httpRequest.headersList.contains("cache-control", true)) { |
| 14087 | httpRequest.headersList.append("cache-control", "no-cache", true); |
| 14088 | } |
| 14089 | } |
| 14090 | if (httpRequest.headersList.contains("range", true)) { |
| 14091 | httpRequest.headersList.append("accept-encoding", "identity", true); |
| 14092 | } |
| 14093 | if (!httpRequest.headersList.contains("accept-encoding", true)) { |
| 14094 | if (urlHasHttpsScheme(requestCurrentURL(httpRequest))) { |
| 14095 | httpRequest.headersList.append("accept-encoding", "br, gzip, deflate", true); |
| 14096 | } else { |
no test coverage detected
searching dependent graphs…