question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

content-length header is lost under Cypress.

See original GitHub issue

Current behavior

When using Cypress, no content-length header is returned. This error is not reproduced when using the functionality without Cypress.

Desired behavior

Content length is returned.

Test code to reproduce

git clone https://github.com/dvkruchinin/cvat.git
cd cvat
git checkout case77-for-cypress-issue
docker-compose -f docker-compose.yml -f docker-compose.dev.yml build
docker-compose up -d
docker exec -it cvat bash -ic 'python3 ~/manage.py createsuperuser'
user: admin
email: <can leave it empty>
password: 12qwaszx
cd tests
npm ci
npx cypress open

run the test actions_objects2/case_77_intelligent_scissors.js

For checking without Cypress: Open Chrome Go to http://localhost:8080 Login as admin password 12qwaszx And reproduce the actions from the test

Versions

Cypress version: 6.4.0, 7.3.0 Browser: Chome Version 90.0.4430.93 (Official Build) (64-bit) OS: 20.04.1-Ubuntu

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:4
  • Comments:18

github_iconTop GitHub Comments

3reactions
adi518commented, Mar 26, 2022

Here’s an example, it goes in your Cypress code:

cy.intercept( 'GET', 'https://foobar.com/media.mp4', (req) => {
    req.continue((res) => {
      // monkey patch content-length, since cypress has a bug
      // where it won't pass this property to the response.
      const contentLength = 123456;
      res.headers['Content-Length'] = String(contentLength);
    });
  }
).as('mediaRequest');

Notice you’ll have to update it when you change your mock or things can/will break. I think it might be possible to make this seamless by reading your mock with fs.readFileSync and calculating the content length.

2reactions
masciugocommented, Nov 24, 2022

I am experiencing the same problem. Thanks for the workaround but it I hope it will fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Content-length header is not getting set in response to client
We have a requirement where we need to send content-length header in the response of a MPGW service to a client which listens...
Read more >
How can I set my request headers in Cypress to avoid ...
On my side, it work with visit() function. The url used will show you header sent. Hope this code sample can help you...
Read more >
Changelog - Cypress Documentation
Fixes an issue introduced in 10.3.0 where network logs could be missing ... Added icons to help indicate that column headers provide more...
Read more >
@cypress/request - npm Package Health Analysis | Snyk
Looks like @cypress/request is missing a security policy. ... When doing so, content-type and content-length are preserved in the PUT headers.
Read more >
huge json data in response and Content-Length Header
There are some signs missing and the json String cannot be decoded on JS side. ... How do you set the Content-Length Header-Variable,...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found