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

HTTP2 outgoing messages should set content-length if payload knows it #1547

Closed
seanmonstar opened this issue Jun 6, 2018 · 0 comments
Closed
Labels
A-http2 Area: HTTP/2 specific. C-feature Category: feature. This is adding a new feature. E-easy Effort: easy. A task that would be a great starting point for a new contributor.

Comments

@seanmonstar
Copy link
Member

For instance, a server replying with Response::new(Body::from("Hello, World!")) over HTTP2 should set the content-length: 13 header.

Steps to fix

  • In proto::h2::server, before calling SendResponse::send_response, check body.content_length(). If it returns Some(len), check if the headers contain CONTENT_LENGTH, and if not, add the header with the serialized length.
  • Do the same in proto::h2::client, before calling SendRequest::send_request.
  • Serializing into a header value can make use of hyper::headers::content_length_value.
  • A new function, set_content_length_if_not_present, could probably be added to hyper::headers, making use of HeaderMap::entry.
@seanmonstar seanmonstar added E-easy Effort: easy. A task that would be a great starting point for a new contributor. C-feature Category: feature. This is adding a new feature. A-http2 Area: HTTP/2 specific. labels Jun 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-http2 Area: HTTP/2 specific. C-feature Category: feature. This is adding a new feature. E-easy Effort: easy. A task that would be a great starting point for a new contributor.
Projects
None yet
Development

No branches or pull requests

1 participant