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

Support downloading binary responses #929

Closed
pryon opened this issue Jun 10, 2020 · 5 comments · Fixed by #955
Closed

Support downloading binary responses #929

pryon opened this issue Jun 10, 2020 · 5 comments · Fixed by #955
Assignees
Labels
feature New feature or request

Comments

@pryon
Copy link

pryon commented Jun 10, 2020

Describe the bug
When a binary file (e.g. an image) is requested, the binary content of the response is properly displayed in the response body window, however if the Download file button is clicked, a corrupted blob of data is downloaded instead of the actual binary file that was requested.

To Reproduce
Steps to reproduce the behavior:

  1. Go to postwoman.io
  2. Set http://tim.org/images/TIMtitle.GIF as the request URL
  3. Click Send
  4. When the response has arrived, click on the Download file button above the response body textfield
  5. Examine contents of the downloaded binary file (e.g. with a hex editor), or just try to open the image

Expected behavior
The same binary file gets downloaded that was requested from the remote server.

Screenshots
Hexdumps of the original and postwoman-downloaded image file.
Left: original image file, downloaded via right-click, Save image as...
Right: image file downloaded via postwoman.io

image

Desktop:

  • OS: Windows 10 1909
  • Browser: Chrome
  • Version: 83.0.4103.97

Additional context
When looking at the corrupted file, notice the double-quote in the very beginning and the very end, the unicode-escaped sequences and the occasional new EF BF BD byte triplets. Its size is also 2-3 times bigger than that of the original file.

@liyasthomas
Copy link
Member

@pryon Thanks for reporting the issue. We used Blob() for generating binary file to download. Actually it was intented for text/json formats.

Need to redo how to handle binary files 👍

@liyasthomas liyasthomas added the bug Something isn't working label Jun 10, 2020
@liyasthomas liyasthomas added this to the v2.0 milestone Jun 10, 2020
@liyasthomas liyasthomas added the help wanted Extra attention is needed label Jun 10, 2020
@AndrewBastin
Copy link
Member

AndrewBastin commented Jun 10, 2020

@liyasthomas, this is surely something important to be worked on.

I am working on a proposal (once I get the concepts down, I will announce it in the Telegram group for discussion) for a new extensible architecture for handling response bodies of different types, we can manage downloading response files as well in the new architecture.

In the mean time, what about disabling download response option for non-JSON responses ? If you give the green light I will implement a PR to temporarily disable the ability for non-JSON responses to be downloaded.

@liyasthomas
Copy link
Member

sounds good. I've been trying to convert Blob to array buffer array - but no use. Let's disable download option for binaries for now.

@AndrewBastin
Copy link
Member

Okay, I will work on the PR to temporarily disable that.

@AndrewBastin
Copy link
Member

AndrewBastin commented Jun 10, 2020

sounds good. I've been trying to convert Blob to array buffer array - but no use.

Well, I want separate out the logic from index.vue(i mean, jeez, ~2900 lines) as much as possible as it is getting really huge and complex. So I am working on a new architecture to separate the response handling work to different files.

@AndrewBastin AndrewBastin self-assigned this Jun 10, 2020
@liyasthomas liyasthomas added feature New feature or request and removed bug Something isn't working labels Jun 11, 2020
@liyasthomas liyasthomas changed the title Downloading binary response results in a corrupted file Support downloading binary responses Jun 11, 2020
@AndrewBastin AndrewBastin removed the help wanted Extra attention is needed label Jun 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants