feat(nbhttp): Implement http.Flusher for streaming support#487
Merged
lesismal merged 1 commit intolesismal:masterfrom Aug 8, 2025
Merged
feat(nbhttp): Implement http.Flusher for streaming support#487lesismal merged 1 commit intolesismal:masterfrom
lesismal merged 1 commit intolesismal:masterfrom
Conversation
The existing `nbhttp.Response` did not implement the `http.Flusher` interface, preventing its use with `http.NewResponseController` for streaming data to the client. This was particularly problematic for long-running requests or server-sent events (SSE). This change introduces full support for `http.Flusher` and ensures true streaming is possible by automatically enabling chunked encoding when a `Content-Length` is not explicitly set. Key changes: - Added a `Flush()` method to `Response` to implement `http.Flusher`. - Modified `checkChunked()` to default to `Transfer-Encoding: chunked` for responses without a `Content-Length`, which is crucial for streaming. - Added a no-op `Push()` method to satisfy the `http.Pusher` interface, returning an error as HTTP/2 Push is not supported.
Owner
|
Thank you for your PR BRO! |
Owner
|
v1.6.7 published. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The existing
nbhttp.Responsedid not implement thehttp.Flusherinterface, preventing its use withhttp.NewResponseControllerfor streaming data to the client. This was particularly problematic for long-running requests or server-sent events (SSE).This change introduces full support for
http.Flusherand ensures true streaming is possible by automatically enabling chunked encoding when aContent-Lengthis not explicitly set.Key changes:
Flush()method toResponseto implementhttp.Flusher.checkChunked()to default toTransfer-Encoding: chunkedfor responses without aContent-Length, which is crucial for streaming.Push()method to satisfy thehttp.Pusherinterface, returning an error as HTTP/2 Push is not supported.