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

StreamCopier.CopyStream does not copy the header of the file into the output #4

Closed
gabriel-vasile opened this issue Jul 28, 2022 · 1 comment · Fixed by #6
Closed

Comments

@gabriel-vasile
Copy link
Contributor

After the discussion we had in gabriel-vasile/mimetype#310, I had a look at the copier.StreamCopier and I think there is a problem.

step1: extensionFromBody will read file header in order to detect extension. It reads from a bufio.Reader which, in turn, reads from resp.Body.
step2: Later, io.Copy(output, resp.Body) is called and, because the header was already read in step1, it is skipped.

You can confirm the problem by saving a URL twice:

  • once using radiot_dumper (make sure extensionFromBody is called when you test)
  • second time use the browser to save the file.
    Then, compare the file saved with radiot_dumper and the file saved using the browser. The radiot_dumper file will be smaller because it is missing the header.
gabriel-vasile added a commit to gabriel-vasile/radiot_dumper that referenced this issue Jul 29, 2022
gabriel-vasile added a commit to gabriel-vasile/radiot_dumper that referenced this issue Jul 29, 2022
F0rzend pushed a commit that referenced this issue Jul 29, 2022
Fix StreamCopier not including file headers into output; for #4
@F0rzend
Copy link
Owner

F0rzend commented Jul 30, 2022

Unfortunately, the problem has not been resolved. Apparently the point is that this is a stream, and not just a recording

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants