- Notifications
You must be signed in to change notification settings - Fork 60
Closed
Milestone
Description
When responding with a status code of 204 from a DELETE method, I'm getting the following exception:
System.InvalidOperationException: Writing to the response body is invalid for responses with status code 204. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.ThrowWritingToResponseBodyNotSupported() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.HandleNonBodyResponseWrite() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.WriteAsync(ReadOnlyMemory`1 data, CancellationToken cancellationToken) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseStream.WriteAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) at System.IO.MemoryStream.CopyToAsync(Stream destination, Int32 bufferSize, CancellationToken cancellationToken) at System.IO.Stream.CopyToAsync(Stream destination) at Marvin.Cache.Headers.HttpCacheHeadersMiddleware.<HandleResponse>d__14.MoveNext() When this exception is thrown it appears to be causing the code that removes keys marked for invalidation to be skipped. After deleting a resource the subsequent GET is returning the stored item. However, this works correctly with other endpoints that return a status code other than 204.
Any chance this could be updated to ensure that keys marked for invalidation are always removed even if an exception is thrown when modifying the response body?
Metadata
Metadata
Assignees
Labels
No labels