-
Notifications
You must be signed in to change notification settings - Fork 20
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
Handle http/2 request body without content-length #1146
Conversation
Http/2 is always streaming, so setting content-length is optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking progress, just sharing some food for thought.
@@ -63,10 +63,15 @@ object JdkHttpClient { | |||
def convertRequest(req: Request[F]): Resource[F, HttpRequest] = | |||
flow.toPublisher(req.body.chunks.map(_.toByteBuffer)).evalMap { publisher => | |||
convertHttpVersionFromHttp4s[F](req.httpVersion).map { version => | |||
def isStreaming = version match { | |||
case HttpClient.Version.HTTP_1_1 => req.isChunked | |||
case HttpClient.Version.HTTP_2 => req.contentLength.isEmpty |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At first glance, this seems a little tricky. But given the streaming nature, I think relying on req.body eq Stream.empty[Nothing]
is hardly a better option.
core/src/main/scala/org/http4s/jdkhttpclient/JdkHttpClient.scala
Outdated
Show resolved
Hide resolved
// If we dont do this, we might block finalization | ||
publisher.subscribe(DrainingSubscriber) | ||
BodyPublishers.noBody |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
Http/2 is always streaming, so setting content-length is optional.