You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If an API route is spied on using cy.intercept (e.g. cy.intercept('/api') with no stub), an additional Content-Length: 0 header will be sent to the server, despite the original request from the application code not including a Content-Length header at all.
Without cy.intercept, the headers are left unchanged and there is no bug.
When using cy.intercept to stub (e.g. cy.intercept('/api', {})), there is no bug.
Desired behavior
The headers sent to the server should be identical to the headers in the original request regardless of whether cy.intercept is used to spy on the request.
Testing this requires a server process since the problematic request headers only show up after the request has left the browser. The repo has a minimal express server and instructions on how to boot it.
I also observed this on Cypress 10.5.0 and 10.10.0, as I upgraded while trying to debug.
I also observed this on Node v16.15.0, which is the version my company uses in production.
The text was updated successfully, but these errors were encountered:
@Bourg, thanks for logging this issue and including the reproduction. It appears we are incorrectly comparing the content-length of the headers without actually verifying the header is populated.
Current behavior
If an API route is spied on using
cy.intercept
(e.g.cy.intercept('/api')
with no stub), an additionalContent-Length: 0
header will be sent to the server, despite the original request from the application code not including aContent-Length
header at all.Without
cy.intercept
, the headers are left unchanged and there is no bug.When using
cy.intercept
to stub (e.g.cy.intercept('/api', {})
), there is no bug.Desired behavior
The headers sent to the server should be identical to the headers in the original request regardless of whether
cy.intercept
is used to spy on the request.Test code to reproduce
https://github.com/Bourg/cypress-bug-content-length
Testing this requires a server process since the problematic request headers only show up after the request has left the browser. The repo has a minimal express server and instructions on how to boot it.
Cypress Version
10.11.0
Node version
v18.12.0
Operating System
macOS 12.5.1
Debug Logs
Other
I also observed this on Cypress 10.5.0 and 10.10.0, as I upgraded while trying to debug.
I also observed this on Node v16.15.0, which is the version my company uses in production.
The text was updated successfully, but these errors were encountered: