Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

fix(fetch): use case-insensitive host header lookup on redirect (#41850)

Dmitry Gozmanbeff82dd595e
diff --git a/packages/playwright-core/src/server/fetch.ts b/packages/playwright-core/src/server/fetch.ts
index e9c1fbc1ba..e5778afb76 100644
--- a/packages/playwright-core/src/server/fetch.ts
+++ b/packages/playwright-core/src/server/fetch.ts
@@ -476,8 +476,7 @@ export abstract class APIRequestContext extends SdkObject {
return;
}
- if (headers['host'])
- headers['host'] = locationURL.host;
+ setHeader(headers, 'host', locationURL.host);
// Drop credentials scoped to the original origin on cross-origin redirects.
if (locationURL.origin !== url.origin)
diff --git a/tests/library/browsercontext-fetch.spec.ts b/tests/library/browsercontext-fetch.spec.ts
index 46831e62ca..54f219d2cd 100644
--- a/tests/library/browsercontext-fetch.spec.ts
+++ b/tests/library/browsercontext-fetch.spec.ts
@@ -1436,7 +1436,7 @@ it('should update host header on redirect', async ({ context, server }) => {
});
const reqPromise = server.waitForRequest('/test');
const response = await context.request.get(server.PREFIX + '/redirect', {
- headers: { host: new URL(server.PREFIX).host }
+ headers: { HosT: new URL(server.PREFIX).host }
});
expect(redirectCount).toBe(2);
await expect(response).toBeOK();