
























@@ -1,5 +1,6 @@
11import { randomUUID } from "node:crypto";
22import { URL } from "node:url";
3+import { normalizeRequestInitHeadersForFetch } from "../infra/fetch-headers.js";
34import { resolveDebugProxySettings, type DebugProxySettings } from "./env.js";
45import {
56closeDebugProxyCaptureStore,
@@ -174,8 +175,9 @@ function installDebugProxyGlobalFetchPatch(
174175fetchTarget[DEBUG_PROXY_FETCH_PATCH_KEY] = { originalFetch };
175176fetchTarget.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
176177const url = resolveUrlString(input);
178+const normalizedInit = normalizeRequestInitHeadersForFetch(init);
177179try {
178-const response = await originalFetch(input, init);
180+const response = await originalFetch(input, normalizedInit);
179181if (url && /^https?:/i.test(url)) {
180182captureHttpExchange(
181183{
@@ -184,17 +186,18 @@ function installDebugProxyGlobalFetchPatch(
184186(typeof Request !== "undefined" && input instanceof Request
185187 ? input.method
186188 : undefined) ??
187-init?.method ??
189+normalizedInit?.method ??
188190"GET",
189191requestHeaders:
190192(typeof Request !== "undefined" && input instanceof Request
191193 ? input.headers
192- : undefined) ?? (init?.headers as Headers | Record<string, string> | undefined),
194+ : undefined) ??
195+(normalizedInit?.headers as Headers | Record<string, string> | undefined),
193196requestBody:
194197(typeof Request !== "undefined" && input instanceof Request
195198 ? (input as Request & { body?: BodyInit | null }).body
196199 : undefined) ??
197-(init as (RequestInit & { body?: BodyInit | null }) | undefined)?.body ??
200+(normalizedInit as (RequestInit & { body?: BodyInit | null }) | undefined)?.body ??
198201null,
199202 response,
200203transport: "http",
@@ -225,7 +228,7 @@ function installDebugProxyGlobalFetchPatch(
225228(typeof Request !== "undefined" && input instanceof Request
226229 ? input.method
227230 : undefined) ??
228-init?.method ??
231+normalizedInit?.method ??
229232"GET",
230233host: parsed.host,
231234path: `${parsed.pathname}${parsed.search}`,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。