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

Handle http/2 request body without content-length #1146

Merged
merged 2 commits into from
Dec 9, 2024

Conversation

hamnis
Copy link
Contributor

@hamnis hamnis commented Dec 7, 2024

Http/2 is always streaming, so setting content-length is optional.

Http/2 is always streaming, so setting content-length is optional.
Copy link
Member

@danicheg danicheg left a 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
Copy link
Member

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.

Comment on lines +82 to +84
// If we dont do this, we might block finalization
publisher.subscribe(DrainingSubscriber)
BodyPublishers.noBody
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏻

@hamnis hamnis merged commit 17242da into series/0.10 Dec 9, 2024
18 checks passed
@hamnis hamnis deleted the http/2-streaming branch December 9, 2024 22:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants