fix(server): the chunk route raises its body limit before authentication
Authentication answers 401 and 403 before the endpoint runs, with the chunk unread; over Kestrel's 1 MiB limit the connection was closed and the Uploader saw a network error instead of being asked to sign in. The chunk route now carries IRequestSizeLimitMetadata for the largest chunk size a server allows, which routing applies when it selects the endpoint. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
2 files changed
+26
-6
No files matched your search
@@ -189,8 +189,14 @@ public sealed class UploadTests(TestContext context)
|
||||
}
|
||||
using (var unknown = await Uploads.PutChunkAsync(uploader, Guid.CreateVersion7(), 0, data)) await unknown.ExpectErrorAsync(HttpStatusCode.NotFound, "not_found");
|
||||
using (var complete = await uploader.PostAsync($"/api/v1/uploads/{id}/complete", null)) await complete.ExpectAsync(HttpStatusCode.OK);
|
||||
using var late = await Uploads.PutChunkAsync(uploader, id, 0, data);
|
||||
await late.ExpectErrorAsync(HttpStatusCode.Conflict, "upload_state");
|
||||
using (var late = await Uploads.PutChunkAsync(uploader, id, 0, data)) await late.ExpectErrorAsync(HttpStatusCode.Conflict, "upload_state");
|
||||
|
||||
// Authentication answers before the endpoint runs: a user who may not upload, and a session signed out meanwhile.
|
||||
var (viewer, _, _) = await server.UserAsync("marco", "viewer");
|
||||
using (var forbidden = await Uploads.PutChunkAsync(viewer, id, 0, data)) await forbidden.ExpectErrorAsync(HttpStatusCode.Forbidden, "forbidden");
|
||||
using (var logout = await uploader.PostAsync("/api/v1/auth/logout", null)) await logout.ExpectAsync(HttpStatusCode.NoContent);
|
||||
using var revoked = await Uploads.PutChunkAsync(uploader, id, 0, data);
|
||||
await revoked.ExpectErrorAsync(HttpStatusCode.Unauthorized, "unauthorized");
|
||||
}
|
||||
|
||||
[Test]
|
||||
|
||||
Reference in new issue
Block a user