Repo for Cypress issue cypress-io/cypress#28058 "API call changes method on 308 redirect"
This branch demonstrates the non-compliance of @cypress/request in cypress@13.3.2
to RFC 9110 - HTTP Semantics section 15.4.9 HTTP 308 (Permanent Redirect).
RFC 9110 - 15.4 Redirection 3xx states:
307 (Temporary Redirect) and 308 (Permanent Redirect) RFC7538 were later added to unambiguously indicate method-preserving redirects, and status codes 301 and 302 have been adjusted to allow a POST request to be redirected as GET.
Calling @cypress/request with POST method to a URL that returns an HTTP 308 (Permanent Redirect) status code, causes a GET request to be sent to the redirected URL.
If a URL responds with HTTP 308 (Permanent Redirect) status code to a @cypress/request where the POST method has been used, then a method-preserving POST request should be sent to the redirected URL. No GET request should be sent.
Execute
git clone https://github.com/julianklose/cypress-308-test.git
cd cypress-308-test
npm ci
npm test
describe('308 redirect', () => {
it('POST request to test', () => {
cy.request("POST", "/test").its("body").should("eq", "POST");
})
});
app.all('/test', (req, res) => {
res.redirect(308, "/target");
});
app.all('/target', (req, res) => {
res.send(req.method);
});
13.3.2
v18.18.2
Windows 10.0.19045.3570
1) 308 redirect
POST request to test:
Timed out retrying after 4000ms
+ expected - actual
-'GET'
+'POST'