Skip to content

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

@OldrichDlouhy

Description

@OldrichDlouhy

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

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions