Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Collect streaming request bodies #23

Merged
merged 1 commit into from Feb 6, 2023
Merged

Conversation

stephencelis
Copy link
Member

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

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
Copy link

@dmzza dmzza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes sense to me. It would be nice if Vapor Routing could support streaming the request body in addition to just collecting it. I guess that problem is that you wouldn't be able to parse the body without collecting the whole thing first. But this is great, and a nice bonus that you're using Vapor's configurable defaultMaxBodySize.

I tried this branch with my example project tests and with my real application, and both are working consistently with large requests after thousands of test repetitions. Thanks for finding a solution so quickly!

@stephencelis stephencelis merged commit ae1db2e into main Feb 6, 2023
@stephencelis stephencelis deleted the fix-streaming-request-size branch February 6, 2023 21:33
@stephencelis
Copy link
Member Author

It would be nice if Vapor Routing could support streaming the request body in addition to just collecting it

It'd definitely be nice to support streaming and incremental parsing in the future, but for now collecting everything and parsing all at once seems to be the way to go. Hopefully we'll be able to explore async parsing in the future!

@stephencelis
Copy link
Member Author

@dmzza Released 0.1.3 with the fix, thanks for reporting the bug!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Longer POST/PUT body fails inconsistently (tests attached)
3 participants