Collect streaming request bodies (#23)

Fixes #22.

Request bodies of a certain size come in streaming and the properties
return `nil`. We should check this and perform a check similar to what
Vapor's routing tools do internally:

1d53c99b6e/Sources/Vapor/Routing/RoutesBuilder%2BMethod.swift (L152)
This commit is contained in:
Stephen Celis 2023-02-06 13:33:29 -08:00 committed by GitHub
parent 876da8b61f
commit ae1db2ec96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 0 deletions

View File

@ -32,6 +32,11 @@ where Router.Input == URLRequestData {
chainingTo next: AsyncResponder
) async throws -> Response {
if request.body.data == nil {
try await _ = request.body.collect(max: request.application.routes.defaultMaxBodySize.value)
.get()
}
guard let requestData = URLRequestData(request: request)
else { return try await next.respond(to: request) }