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 Jetty Server does not send back content-length #4764

Closed
CaoManhDat opened this issue Apr 9, 2020 · 3 comments · Fixed by #4768
Closed

HTTP2 Jetty Server does not send back content-length #4764

CaoManhDat opened this issue Apr 9, 2020 · 3 comments · Fixed by #4768

Comments

@CaoManhDat
Copy link

CaoManhDat commented Apr 9, 2020

Jetty version 9.4.24.v20191120

Java version Java 11

Question On requesting to a plain text HTTP2 (h2c) Jetty Server, the response doesn't include content-length in the header. But with that same server on requesting using HTTP/1.1, the server does return content-legth.
I understand that content-length is not required for HTTP2 protocol. But it will be very helpful for client for handling the response if content-length is available. So do Jetty have any configuration to enforce server to return content-length in the header?

@sbordet
Copy link
Contributor

sbordet commented Apr 9, 2020

You are correct that currently we don't add the Content-Length header if we know in advance the total content length.

Can you expand on how this header will be useful to a HTTP/2 client?

@CaoManhDat
Copy link
Author

Few examples

  • use it for BufferingResponseListener, so it can know exactly how much memory it needs to allocate.
  • in my case we need to choose wether to use BufferingResponseListener (which doesn't need to spin a new thread to wait for data from other's side) or InputStreamResponseListener
  • same idea from http2 spec community: Encouraging Content-Length headers httpwg/http2-spec#558

sbordet added a commit that referenced this issue Apr 14, 2020
Updates after review.
Now the Content-Length header is generated by HpackEncoder based on
MetaData.contentLength, so that the MetaData.HttpFields are not modified.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
sbordet added a commit that referenced this issue Apr 14, 2020
Fixed InterleavingTest that was using the wrong MetaData.Response constructor.
Fixed handling of HEAD methods in HttpTransportOverHTTP2.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
sbordet added a commit that referenced this issue Apr 14, 2020
…length

Fixes #4764 - HTTP2 Jetty Server does not send back content-length.
@CaoManhDat
Copy link
Author

Thanks!

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

Successfully merging a pull request may close this issue.

2 participants