Skip to content

Commit ae1db2e

Browse files
authored
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: https://github.com/vapor/vapor/blob/1d53c99b6ede0131bb02305f0d62fb2c6c830f3b/Sources/Vapor/Routing/RoutesBuilder%2BMethod.swift#L152
1 parent 876da8b commit ae1db2e

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Sources/VaporRouting/VaporRouting.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,11 @@ where Router.Input == URLRequestData {
3232
chainingTo next: AsyncResponder
3333
) async throws -> Response {
3434

35+
if request.body.data == nil {
36+
try await _ = request.body.collect(max: request.application.routes.defaultMaxBodySize.value)
37+
.get()
38+
}
39+
3540
guard let requestData = URLRequestData(request: request)
3641
else { return try await next.respond(to: request) }
3742

0 commit comments

Comments
 (0)