Raise the response read buffer to 128KiB - #150
Merged
Merged
Conversation
ReadResponseAsync reads into a single fixed 64KiB buffer, and both the header loop and DrainAvailable stop at buffer.Length. Anything past that is silently dropped: no exception, no truncation flag, just a short response that later assertions read as the server's actual reply. Four tests send payloads of 100,000 bytes — MAL-LONG-URL, MAL-LONG-HEADER-NAME, MAL-LONG-HEADER-VALUE and MAL-LONG-METHOD. A server that echoes one back in its error response overruns the buffer, so what the probe records for those cases is a truncation artifact rather than what the server sent. Raise the buffer to 128KiB, which clears the 100,000-byte ceiling with room for status line and headers, and name it so the bound is documented where the tests that set it are listed.
|
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.



RawTcpClient.ReadResponseAsyncreads every response into a single fixed 64KiB buffer (new byte[65536]), and both the header loop andDrainAvailableare bounded bytotalRead < buffer.Length. Anything beyond that is silently dropped — no exception, no truncation flag, just a short response that downstream assertions treat as the server's actual reply.That bound is smaller than the largest request the suite sends.
What overruns it
Four tests build 100,000-byte payloads:
MAL-LONG-URLMAL-LONG-HEADER-NAMEMAL-LONG-HEADER-VALUEMAL-LONG-METHODA server that echoes the offending value back in its error response — a reasonably common thing to do — produces a reply larger than 64KiB. The probe cuts it off and records the fragment. For those cases the result reflects our buffer, not the server's behaviour.
COOK-OVERSIZEDandMAL-CHUNK-EXT-64Ksend exactly 65,536 bytes, so they sit right on the boundary and overrun as soon as any status line or headers accompany the echo.Change
65536→128 * 1024, extracted to a namedReadBufferSizeconstant with the ceiling documented next to it. 128KiB clears 100,000 bytes with ~30KiB of headroom for the status line and headers.One buffer is allocated per
ReadResponseAsynccall, so this is +64KiB per read, transient and immediately collectable. No behavioural change for any response that already fit.Verification
Builds clean in Release, 0 warnings / 0 errors.
Not yet run against live servers. The local hardware this was written on is mid-diagnosis for a suspected memory fault, so the full suite hasn't been executed to confirm the affected tests change verdict. The change is a pure bound increase — it can only make previously-truncated reads complete — but the CI probe run is the real check on whether any
MAL-LONG-*result shifts.