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:
Ciro Spaciari
2025-10-09 22:56:49 -07:00
committed by GitHub
parent 086eb73fe7
commit 3395774c8c
7 changed files with 106 additions and 20 deletions

View File

@@ -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) {