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

Fancy multipart form bodies #375

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft

Fancy multipart form bodies #375

wants to merge 4 commits into from

Conversation

sagebind
Copy link
Owner

This provides an optional builder for generating multipart forms as a request body, supported both in the sync and async APIs.

This also extends Body and AsyncBody to have an inherent Content-Type, which is essential to make multipart forms reasonably useful.

Fixes #14.

@sagebind sagebind added the feature A new feature! label Feb 15, 2022
@codecov
Copy link

codecov bot commented Feb 15, 2022

Codecov Report

Merging #375 (0c923ae) into master (3a49173) will decrease coverage by 0.91%.
The diff coverage is 50.49%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #375      +/-   ##
==========================================
- Coverage   79.46%   78.54%   -0.92%     
==========================================
  Files          52       53       +1     
  Lines        3092     3146      +54     
==========================================
+ Hits         2457     2471      +14     
- Misses        635      675      +40     
Impacted Files Coverage Δ
src/forms/multipart.rs 0.00% <0.00%> (ø)
src/lib.rs 76.19% <ø> (ø)
src/client.rs 79.18% <66.66%> (-0.15%) ⬇️
src/body/sync.rs 78.89% <75.86%> (-2.48%) ⬇️
src/body/mod.rs 82.60% <84.37%> (-0.73%) ⬇️
src/cookies/jar.rs 83.57% <0.00%> (+2.85%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3a49173...0c923ae. Read the comment docs.

@Xuanwo
Copy link

Xuanwo commented Sep 1, 2022

Hi, @sagebind any updates on this? We need this feature too, is there any help I can provide?

@sagebind
Copy link
Owner Author

sagebind commented Sep 5, 2022

This PR is squarely in the "experimental" phase at the moment, and its API is fairly clunky. The main problem to solve here is how to allow attaching a specific Content-Type to a body itself, because specifying a Content-Type manually is tedious at best, especially with multipart forms which have the boundary in the header value.

This might require some more refactoring for bodies to have inherent content types across the board instead of just a surface-level change.

Ideally if possible we could have a single API for building both multipart forms and www forms, with the former having extra support for arbitrary streams as fields. Though that might be not possible.

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

Successfully merging this pull request may close these issues.

Fancy multipart forms API
2 participants