Skip to content

Commit 8258fcf

Browse files
MDA2AVclaude
andcommitted
Fix GlyphServer closing without response on oversized requests
When the receive buffer fills before headers are complete (e.g. 100KB URL or header), send 431 instead of silently closing the connection. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4e1851d commit 8258fcf

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

src/Servers/GlyphServer/Program.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,13 @@ static async Task HandleClientAsync(TcpClient client, CancellationToken ct)
4444
{
4545
while (!ct.IsCancellationRequested)
4646
{
47+
if (filled >= buffer.Length)
48+
{
49+
// Buffer full but headers still incomplete — request is too large
50+
await stream.WriteAsync(MakeErrorResponse(431, "Request Header Fields Too Large"), ct);
51+
return;
52+
}
53+
4754
var read = await stream.ReadAsync(buffer.AsMemory(filled), ct);
4855
if (read == 0) break;
4956
filled += read;

0 commit comments

Comments
 (0)