a fork of iceshrimp.net but a tweaked frontend to my personal liking. waow
fediverse social-media social iceshrimp fedi
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

[backend/asp] Correctly handle API requests using chunked transfer encoding

+10 -2
+7
Iceshrimp.Backend/Core/Extensions/HttpRequestExtensions.cs
··· 1 + namespace Iceshrimp.Backend.Core.Extensions; 2 + 3 + public static class HttpRequestExtensions 4 + { 5 + public static bool HasBody(this HttpRequest request) => 6 + request.ContentLength > 0 || request.Headers.TransferEncoding.FirstOrDefault() == "chunked"; 7 + }
+3 -2
Iceshrimp.Backend/Core/Extensions/ModelBinderProviderExtensions.cs
··· 113 113 { 114 114 if (bindingContext.IsTopLevelObject) 115 115 { 116 - if (bindingContext is { HttpContext.Request: { HasFormContentType: false, ContentLength: > 0 } }) 116 + if (bindingContext is { HttpContext.Request.HasFormContentType: false } && 117 + bindingContext.HttpContext.Request.HasBody()) 117 118 { 118 119 if (bodyBinder != null) 119 120 { ··· 121 122 await bodyBinder.BindModelAsync(bindingContext); 122 123 } 123 124 } 124 - else if (bindingContext.HttpContext.Request.ContentLength == 0 && dictionaryBinder != null) 125 + else if (!bindingContext.HttpContext.Request.HasBody() && dictionaryBinder != null) 125 126 { 126 127 bindingContext.BindingSource = BindingSource.Query; 127 128 await dictionaryBinder.BindModelAsync(bindingContext);