Description
Version
1.52.0
Steps to reproduce
I am using the following request interceptor:
await page.route(async (route: Route) => {
const request = route.request();
const headers = request.headers();
headers["My-Extra-Header"] = "Extra-Header-Value";
await route.continue({
headers: headers,
});
});
(I'm not sure if the interceptor is affecting anything or if this would happen without it, but I thought I would mention it anyway)
After a POST request to a server, which returns a 302 redirect as the result, and when Playwright is set to follow redirects automatically, the Content-Length header from the original POST request is included with the GET request to the redirect URI:
General
URL: Omitted
Method: GET
Status Code: 400
Request Headers
Host: Omitted
Cookie: Omitted
user-agent: Mozilla/5.0 (X11; Linux x86_64; rv:137.0) Gecko/20100101 Firefox/137.0
accept: text/html,application/xhtml+xml,application/xml;q=0.9,/;q=0.8
accept-language: en-US
accept-encoding: gzip, deflate, br, zstd
content-type: application/x-www-form-urlencoded
content-length: 47
referer: Omitted
origin: Omitted
upgrade-insecure-requests: 1
sec-fetch-dest: document
sec-fetch-mode: navigate
sec-fetch-site: same-origin
sec-fetch-user: ?1
connection: keep-alive
My-Extra-Header: Extra-Header-Value
Time
Start: 7.1s
Duration: 7ms
Content-Length is not valid for GET requests, so when this happens against CloudFront it rejects the request:
Expected behavior
The Content-Length header is never included for HTTP Verbs that do not have a body.
Actual behavior
The Content-Length header was included in the request, causing an error with CloudFront.
Additional context
NOTE: This only happens with Firefox and Safari, it is not happening with Chromium based browsers. I can confirm that this exact set up works fine with Chrome and I cannot see a Content-Length header in the network logs on Chrome.
Environment
System:
OS: macOS 15.3.1
Memory: 84.78 MB / 36.00 GB
Binaries:
Node: 18.20.4 - ~/.nvm/versions/node/v18.20.4/bin/node
npm: 10.7.0 - ~/.nvm/versions/node/v18.20.4/bin/npm
pnpm: 9.9.0 - ~/.nvm/versions/node/v18.20.4/bin/pnpm
Languages:
Bash: 5.2.32 - /opt/homebrew/bin/bash