Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/Http11Probe/Client/RawTcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ namespace Http11Probe.Client;

public sealed class RawTcpClient : IAsyncDisposable
{
// Responses are read into a single fixed buffer and truncated at its size. Keep this above the
// largest payload any test sends — 100,000 bytes (MAL-LONG-URL, MAL-LONG-HEADER-NAME,
// MAL-LONG-HEADER-VALUE, MAL-LONG-METHOD) — so a server that echoes one back in an error
// response doesn't get cut off and misread as a truncated reply.
private const int ReadBufferSize = 128 * 1024;

private Socket? _socket;
private readonly TimeSpan _connectTimeout;
private readonly TimeSpan _readTimeout;
Expand Down Expand Up @@ -60,7 +66,7 @@ public async Task SendAsync(ReadOnlyMemory<byte> data)
if (_socket is null)
return ([], 0, ConnectionState.Error, false);

var buffer = new byte[65536];
var buffer = new byte[ReadBufferSize];
var totalRead = 0;

using var cts = new CancellationTokenSource(_readTimeout);
Expand Down
Loading