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

Response without a body receives Transfer-Encoding: chunked #1257

Closed
slyrz opened this issue Jul 13, 2017 · 2 comments
Closed

Response without a body receives Transfer-Encoding: chunked #1257

slyrz opened this issue Jul 13, 2017 · 2 comments
Labels
C-bug Category: bug. Something is wrong. This is bad!

Comments

@slyrz
Copy link

slyrz commented Jul 13, 2017

I want a server to make a 304 Not Modified response like this:

Response::new()
         .with_status(StatusCode::NotModified)
         .with_header(ETag(etag))
         .with_header(LastModified(last_modified))

My problem is hyper sees the response without body (or without Content-Length) and adds a Transfer-Encoding: chunked to the headers (here's the culprit).

Am I using the API wrong or is this an error on hyper's side?

@seanmonstar
Copy link
Member

It's a bug in hyper. I've been working on this week actually, to better handle when message shouldn't have bodies. Besides 304, also 204, and also when the request verb would not allow a response body, like HEAD or CONNECT.

@seanmonstar seanmonstar added the C-bug Category: bug. Something is wrong. This is bad! label Jul 13, 2017
seanmonstar added a commit that referenced this issue Jul 13, 2017
By knowing if the incoming Request was a HEAD, or checking for 204 or
304 status codes, the server will do a better job of either adding
or removing `Content-Length` and `Transfer-Encoding` headers.

Closes #1257
seanmonstar added a commit that referenced this issue Jul 13, 2017
By knowing if the incoming Request was a HEAD, or checking for 204 or
304 status codes, the server will do a better job of either adding
or removing `Content-Length` and `Transfer-Encoding` headers.

Closes #1257
@slyrz
Copy link
Author

slyrz commented Jul 13, 2017

Great to hear it's being resolved and thank you for fixing this!

seanmonstar added a commit that referenced this issue Jul 13, 2017
By knowing if the incoming Request was a HEAD, or checking for 204 or
304 status codes, the server will do a better job of either adding
or removing `Content-Length` and `Transfer-Encoding` headers.

Closes #1257
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug. Something is wrong. This is bad!
Projects
None yet
Development

No branches or pull requests

2 participants