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

Implement streaming of multipart field data #2899

Merged
merged 3 commits into from
Jun 11, 2024

Conversation

kyri-petrou
Copy link
Collaborator

/fixes #2734
/claim #2734

With this PR, we enable streaming of multipart field data by handling each chunk emitted by the input ZStream separately, and optionally flushing the buffer when the last byte(s) don't match the boundary.

I have a small concern with this approach though; in cases that request streaming is enabled, the output stream will be emitting individual bytes which can be quite bad for performance. I'm thinking we should potentially make this behaviour configurable via an extra argument to the StreamingForm case class and disable it by default. @jdegoes @khajavi what do you think?

@kyri-petrou
Copy link
Collaborator Author

Ended up implementing the collect method without streaming field data (which was not necessary since we collect the entire stream into memory) and the fields method using field data streaming. This way we don't incur any performance penalty wherever collect is used (e.g., using Body#asMultipartForm)

@jdegoes jdegoes merged commit dc0e883 into zio:main Jun 11, 2024
33 checks passed
@kyri-petrou kyri-petrou deleted the support-streaming-multipart-field-data branch June 11, 2024 22:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for Streaming of Data Part of Multipart Form Fields
2 participants