mirror of
https://github.com/oven-sh/bun
synced 2026-02-02 15:08:46 +00:00
improve(node:http): uncork after flushing headers to ensure data is sent immediately (#23413)
### What does this PR do?
Calls `uncork()` after flushing response headers to ensure data is sent
as soon as possible, improving responsiveness.
This behavior still works correctly even without the explicit `uncork()`
call, due to the deferred uncork logic implemented here:
6e3359dd16/packages/bun-uws/src/Loop.h (L57-L64)
A test already covers this scenario in
`test/js/node/test/parallel/test-http-flush-response-headers.js`.
### How did you verify your code works?
CI
---------
Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -478,7 +478,7 @@ public:
|
||||
return internalEnd({nullptr, 0}, 0, false, false, closeConnection);
|
||||
}
|
||||
|
||||
void flushHeaders() {
|
||||
void flushHeaders(bool flushImmediately = false) {
|
||||
|
||||
writeStatus(HTTP_200_OK);
|
||||
|
||||
@@ -499,6 +499,10 @@ public:
|
||||
Super::write("\r\n", 2);
|
||||
httpResponseData->state |= HttpResponseData<SSL>::HTTP_WRITE_CALLED;
|
||||
}
|
||||
if (flushImmediately) {
|
||||
/* Uncork the socket to send data to the client immediately */
|
||||
this->uncork();
|
||||
}
|
||||
}
|
||||
/* Write parts of the response in chunking fashion. Starts timeout if failed. */
|
||||
bool write(std::string_view data, size_t *writtenPtr = nullptr) {
|
||||
|
||||
Reference in New Issue
Block a user