Skip to content

feat(core): expose request body content streams - #923

Closed
sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:feat/http-request-body-content
Closed

sylvesterkaczmarek wants to merge 2 commits into
openai:mainfrom
sylvesterkaczmarek:feat/http-request-body-content

Conversation

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor

Summary

Add HttpRequestBody.content(): InputStream so custom HTTP client implementations can consume request bodies directly as streams.

Addresses the request-body portion of #664.

Problem

HttpResponse.body() already exposes an InputStream, but HttpRequestBody only exposes writeTo(OutputStream). Custom HttpClient adapters therefore have to bridge the push-style request body API themselves.

Changes

  • add a JVM-default content(): InputStream method to HttpRequestBody
  • keep existing third-party implementations compatible by providing a default fallback based on writeTo
  • override the fallback for built-in JSON and multipart bodies
  • stream multipart framing with SequenceInputStream, so InputStream-backed file parts are not buffered into memory
  • add focused Kotlin regression coverage for fallback behavior and byte-for-byte multipart parity
  • add a Java-facing regression proving existing implementations do not need to implement the new method

Compatibility

The repository compiles Kotlin interfaces with -Xjvm-default=all, so the new method is emitted as a Java default interface method. Existing Java and Kotlin implementations are not required to add an override.

The fallback implementation buffers only for third-party bodies that do not override content(). Built-in SDK request bodies override it, including streaming multipart bodies.

Validation

  • branch is based directly on current upstream main at 715a30468d3232a5df4f6c6bec8b2175404eb8b9
  • branch is 0 commits behind upstream
  • diff is limited to HttpRequestBody, built-in request-body implementations, and focused tests
  • focused regression tests are included for Kotlin and Java callers
  • full repository validation is left to GitHub Actions because this environment does not have a complete local checkout/toolchain

Addresses #664

@sylvesterkaczmarek
sylvesterkaczmarek requested a review from a team as a code owner August 21, 2026 10:53

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3d392208bb

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@sylvesterkaczmarek
sylvesterkaczmarek force-pushed the feat/http-request-body-content branch from 3d39220 to dc2f9cd Compare September 30, 2026 22:15
@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

I resolved this PR against current main while preserving the intended fix and newer upstream behavior. The branch is now mergeable and no longer has a base conflict. Could a maintainer please re-review it when convenient?

@codex review

@sylvesterkaczmarek

Copy link
Copy Markdown
Contributor Author

Addressed the DEBUG logging streaming regression in f5997f3. LoggingHttpRequestBody now implements a streaming content() wrapper that logs incrementally instead of falling back to the buffering default, with a regression test whose delegate consumes content() and fails if writeTo() is used. The review thread is resolved. @codex review

@dpiet-oai

Copy link
Copy Markdown
Contributor

Thank you, Sylvester, for the request-body streaming proposal, tests, and logging fix. We built on this work in #1245, which has now merged and adds HttpRequestBody.content(). Closing this PR as superseded by that implementation.

@dpiet-oai dpiet-oai closed this Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants