Write the uploaded data to /dev/null...

This commit is contained in:
Jeff Leung 2024-09-03 23:04:45 -07:00
parent d50cc3ed4c
commit 130312301e
1 changed files with 4 additions and 6 deletions

View File

@ -5,6 +5,7 @@ var builder = WebApplication.CreateSlimBuilder(args);
builder.WebHost.ConfigureKestrel(options => {
options.Limits.MaxRequestBodySize = long.MaxValue;
options.Limits.MaxRequestBufferSize = long.MaxValue;
}).UseKestrelHttpsConfiguration();
builder.Services.AddLogging();
@ -82,16 +83,13 @@ app.MapGet("/api/v1/large", async (HttpRequest request, HttpResponse response, I
}
});
app.MapPost("/api/v1/upload", (HttpRequest request, ILogger<Program> logger) =>
app.MapPost("/api/v1/upload", async (HttpRequest request, ILogger<Program> logger) =>
{
try
{
await request.Body.CopyToAsync(Stream.Null);
return Results.Ok();
}
catch (IOException ex)
{
logger.LogError(ex, "An error occurred while reading the request body.");
return Results.Problem("An error occurred while reading the request body.", statusCode: 500);
}
catch (Exception ex)
{