Skip to content

Latest commit

 

History

History
81 lines (53 loc) · 2.31 KB

README.md

File metadata and controls

81 lines (53 loc) · 2.31 KB

cypress-308-test

Repo for Cypress issue cypress-io/cypress#28058 "API call changes method on 308 redirect"

Purpose

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).

Reference

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.

Current behavior

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.

Desired behavior

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.

Test code to reproduce

Execute

git clone https://github.com/julianklose/cypress-308-test.git
cd cypress-308-test
npm ci
npm test

Cypress test spec

describe('308 redirect', () => {
  it('POST request to test', () => {
    cy.request("POST", "/test").its("body").should("eq", "POST");
  })
});

serve configuration

app.all('/test', (req, res) => {
  res.redirect(308, "/target");
});

app.all('/target', (req, res) => {
  res.send(req.method);
});

Cypress version

13.3.2

Node version

v18.18.2

Operating System

Windows 10.0.19045.3570

Logs

  1) 308 redirect
       POST request to test:

      Timed out retrying after 4000ms
      + expected - actual

      -'GET'
      +'POST'