C
C#16mo ago
VeQox

✅ asp.net BodyReader

var reader = HttpContext.Request.BodyReader;
var rawBody = Encoding.UTF8.GetString((await reader.ReadAsync()).Buffer);
var ((name, capacity, isPublic), error) = JsonUtils.Deserialize<PostRoomRequestBody>(rawBody);
await reader.CompleteAsync();
var reader = HttpContext.Request.BodyReader;
var rawBody = Encoding.UTF8.GetString((await reader.ReadAsync()).Buffer);
var ((name, capacity, isPublic), error) = JsonUtils.Deserialize<PostRoomRequestBody>(rawBody);
await reader.CompleteAsync();
Im trying to read the body (which works) but then it throws an exception
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMSD270MT6R7", Request id "0HMSD270MT6R7:00000001": An unhandled exception was thrown by the application.
Microsoft.AspNetCore.Connections.ConnectionAbortedException: The connection was aborted by the application.
---> System.InvalidOperationException: Reading is already in progress.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.TryReadInternal(ReadResult& readResult)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.OnConsumeAsync()
--- End of inner exception stack trace ---
fail: Microsoft.AspNetCore.Server.Kestrel[13]
Connection id "0HMSD270MT6R7", Request id "0HMSD270MT6R7:00000001": An unhandled exception was thrown by the application.
Microsoft.AspNetCore.Connections.ConnectionAbortedException: The connection was aborted by the application.
---> System.InvalidOperationException: Reading is already in progress.
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1ContentLengthMessageBody.TryReadInternal(ReadResult& readResult)
at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.Http1MessageBody.OnConsumeAsync()
--- End of inner exception stack trace ---
after some digging i found out this is a bug? https://github.com/dotnet/runtime/issues/53914 Is there a known workaround for this?
GitHub
SocketsHttpHandler.SendAsync reads request Content stream twice · I...
Description Under very specific conditions, SocketsHttpHandler.SendAsync when using HTTP/2 attempts to copy the HttpRequestMessage.Content twice. In Island Gateway (AKA what eventually became YARP)...
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server