mirror of
https://github.com/yhirose/cpp-httplib.git
synced 2026-08-11 21:01:24 +00:00
Mbed TLS has no SSL_peek() equivalent, so is_peer_closed() (called after every SSL request write) probed liveness with a real 1-byte mbedtls_ssl_read() and discarded whatever it read. If the response had already arrived by the time the probe ran — plausible under CI load or plain OS scheduling — the probe silently ate the first byte of the status line, corrupting the response and surfacing as a fast "Failed to read connection" failure. This was the root cause of the long-standing MbedTLS-only CI flakiness (ServerTest cases failing intermittently on Ubuntu and macOS), previously worked around by reducing gtest shard parallelism. Fix: push the probed byte back into MbedTlsSession and have tls::read()/pending() account for it, so no data is lost. Also fix a second, unrelated flake: ProxyTunnelTest. OriginReturning407InsideTunnelDoesNotLeakProxyDigest used "localhost" for its client while the test's proxy harness only listens on 127.0.0.1; under dual-stack resolution this could race with another test's server on ::1 using the same ephemeral port. Pin the test to 127.0.0.1. With the root cause fixed, restore the mbedTLS CI jobs (ubuntu, ubuntu-26.04, macOS) to the default shard count instead of the previously reduced SHARDS=1/2 mitigation.