Skip to content

Commit

Permalink
Collect streaming request bodies (#23)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
stephencelis committed Feb 6, 2023
1 parent 876da8b commit ae1db2e
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Sources/VaporRouting/VaporRouting.swift
Expand Up @@ -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) }

Expand Down

0 comments on commit ae1db2e

Please sign in to comment.