usebruno / bruno

Opensource IDE For Exploring and Testing Api's (lightweight alternative to postman/insomnia)
https://www.usebruno.com/
MIT License
27.56k stars 1.27k forks source link

Binary response data in `tests` and `post-response` #3477

Open koliyo opened 1 week ago

koliyo commented 1 week ago

I have checked the following:

Describe the bug

I see other issues referencing binary data in the bruno app, eg showing image in preview window, and downloading the response to file. But I am having issue with using binary data using bruno-cli in the response object. I have res.body which is of string type, and contains lots of UTF-8 Replacement Character instances.

Am I missing something, or is there no way of getting the raw binary data from the response in post-response or tests sections?

.bru file to reproduce the bug

No response

Screenshots/Live demo link

this is using the cli runner

koliyo commented 1 week ago

It would be preferable if the cli and electron app use the same basic request processing. Right now there seem to be two implementations with different behavior.

 // usebruno/bruno/packages/bruno-electron/src/ipc/network/prepare-request.js
  let axiosRequest = {
    mode: request.body.mode,
    method: request.method,
    url,
    headers,
    pathParams: request?.params?.filter((param) => param.type === 'path'),
    responseType: 'arraybuffer'
  };

vs

  // usebruno/bruno/packages/bruno-cli/src/runner/prepare-request.js
  let axiosRequest = {
    method: request.method,
    url: request.url,
    headers: headers,
    pathParams: request?.params?.filter((param) => param.type === 'path')
  };

specifically the difference with responseType: 'arraybuffer'

ganesh-bruno commented 2 days ago

Hey @koliyo,

Thanks for reporting this issue.

We’ve identified an inconsistency between the app and CLI. We're working on it.