hyper icon indicating copy to clipboard operation
hyper copied to clipboard

Response without a body receives `Transfer-Encoding: chunked`

Open slyrz opened this issue 9 years ago • 2 comments

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?

slyrz avatar Jul 13 '17 12:07 slyrz

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 avatar Jul 13 '17 16:07 seanmonstar

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

slyrz avatar Jul 13 '17 18:07 slyrz