Files
Honza Dvorsky 93bd8f2e02 Test HTTP server - avoid writing .end to the wrong channel for responses using content-length (#3792)
### Motivation:

One of my project uses `NIOHTTP1TestServer` for testing and for
responses that contain the `content-length` header + `connection:
close`,
the test was flaky - failing intermittently, because the client closed
the connection before the test managed to submit `.end` to the test
server.

The cause was a race condition between the test and the client's and
server's threads hosting their respective event loops.

### Modifications:

Now `NIOHTTP1TestServer` captures the channel that sent the `.head`, and
even once `currentClientChannel` changes (but before the next `.head` is
sent),
when a call to send `.end` comes in, uses the channel associated with
the previous `.head`, rather than reading `currentClientChannel`.

This test is skipped on Darwin as it requires the platform to detect
early EOF.

### Result:

More reliable tests that involve two requests that come in at once (in a
deterministic order), when the second one is parked and ready right
after the first one finishes.
2026-11-18 08:44:43 +01:00
..