Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cy.Request does not send binary data (blob) #6178

Closed
OldrichDlouhy opened this issue Jan 16, 2020 · 3 comments · Fixed by #15931
Closed

cy.Request does not send binary data (blob) #6178

OldrichDlouhy opened this issue Jan 16, 2020 · 3 comments · Fixed by #15931
Assignees

Comments

@OldrichDlouhy
Copy link

Sending blob as body of a request sends empty content:

const body = new Blob([[1, 2, 3, 4]], { type: "application/octet-stream" });
cy.request(
  {
    body,
    method: "POST",
    url: "api/binaryBody",
    headers: {
      "Content-Type": "application/octet-stream",
    }
  })
  .then(response => {
    expect(response.status).to.equal(200);
  });

Results in following request:

The request we sent was:

Method: POST
URL: https://localhost:5001/api/binaryBody
Headers: {
  "Connection": "keep-alive",
  "Content-Type": "application/octet-stream",
  "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36",
  "accept": "*/*",
  "accept-encoding": "gzip, deflate",
  "content-length": 2
}
Body: {}

Expected behavior:

Binary data from the blob should be sent as the request body and the content-length header should be set correctly

Versions

Cypress: 3.8.2
OS: Windows 10 v1809, 64-bit
Browser: Chrome 76.0.3809.132
Node.js: 12.13.0

@qkreltms
Copy link

qkreltms commented Jan 18, 2021

I have same issue when I send .nil file, content-length sets to 32MB, though I actually have 16MB file

    cy.get('[data-test-id="uploadButton-niftiInput"]').attachFile({
      filePath: 'test1.nii.gz',
    })

@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review and removed stage: work in progress labels Apr 27, 2021
@cypress-bot cypress-bot bot added stage: waiting and removed stage: needs review The PR code is done & tested, needs review labels May 5, 2021
@cypress-bot cypress-bot bot added stage: needs review The PR code is done & tested, needs review stage: work in progress and removed stage: waiting stage: needs review The PR code is done & tested, needs review labels May 12, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 17, 2021

The code for this is done in cypress-io/cypress#15931, but has yet to be released.
We'll update this issue and reference the changelog when it's released.

@cypress-bot cypress-bot bot added stage: pending release and removed stage: needs review The PR code is done & tested, needs review labels May 17, 2021
@cypress-bot
Copy link
Contributor

cypress-bot bot commented May 24, 2021

Released in 7.4.0.

This comment thread has been locked. If you are still experiencing this issue after upgrading to
Cypress v7.4.0, please open a new issue.

@cypress-bot cypress-bot bot locked as resolved and limited conversation to collaborators May 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants