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

Content-Length 0 in HEAD Response #16

Open
gurry opened this issue Jun 24, 2018 · 7 comments
Open

Content-Length 0 in HEAD Response #16

gurry opened this issue Jun 24, 2018 · 7 comments

Comments

@gurry
Copy link

gurry commented Jun 24, 2018

If I try a HEAD request on any file that simple_http_server is serving, it always returns the Content-Length header with value 0. If I try the GET request on the same file, it returns the correct value in that header. HEAD is often used by many file downloading software to determine the length of the file before downloading it. This would break them (as it's doing in my case).

@gurry
Copy link
Author

gurry commented Jun 24, 2018

A quick debugging session showed that we're setting the content length correctly for HEAD requests:

resp.headers.set(ContentLength(metadata.len()));

which is identical to how we set it for GET requests:

resp.headers.set(ContentLength(metadata.len()));

Yet it works for GET and doesn't work for HEAD. What gives?

I also saw in the debugger that the metadata field does contain the correct length read from the file system for HEAD.

@TheWaWaR
Copy link
Owner

Seems hyper or iron reset the ContentLength

A PR is welcome! : )

@gurry
Copy link
Author

gurry commented Jun 26, 2018

Thanks @TheWaWaR.

I agree with you. I should've ideally done the fix, but I'm in the middle of a lot of stuff right now. So will have to do this later (unless someone beats me to it).

@gurry
Copy link
Author

gurry commented Aug 16, 2018

It's an Iron bug. I've filed an issue there: iron/iron#582

@sergeevabc
Copy link

Are you going to release a new Windows binary with this fix?

@gurry
Copy link
Author

gurry commented Dec 27, 2018

Will have to move to the new version of Iron to get this fix released.

@recolic
Copy link

recolic commented Aug 1, 2022

This issue is still not fixed in version 0.6.2.

image

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

No branches or pull requests

4 participants