From 6e640e1cedc1cf5b0160e76a01a96363a9e68a61 Mon Sep 17 00:00:00 2001 From: GHXX Date: Wed, 27 May 2026 23:28:13 +0200 Subject: [PATCH] fix SetStatusCodeAndDisposeAsync(HttpStatusCode.NotModified) breaking --- SimpleHttpServer/Types/RequestContext.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/SimpleHttpServer/Types/RequestContext.cs b/SimpleHttpServer/Types/RequestContext.cs index ffe8f0a..f49128b 100644 --- a/SimpleHttpServer/Types/RequestContext.cs +++ b/SimpleHttpServer/Types/RequestContext.cs @@ -52,8 +52,10 @@ public class RequestContext : IDisposable { public async Task SetStatusCodeAndDisposeAsync(HttpStatusCode status) { using (this) { SetStatusCode((int) status); - await WriteToRespAsync("\n\n"); - await RespWriter.FlushAsync(); + if (status != HttpStatusCode.NotModified) { // NotModified must not write any data to response + await WriteToRespAsync("\n\n"); + await RespWriter.FlushAsync(); + } } }