isahc icon indicating copy to clipboard operation
isahc copied to clipboard

Fancy multipart form bodies

Open sagebind opened this issue 2 years ago • 3 comments

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 avatar Feb 15 '22 04:02 sagebind

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%) :arrow_down:
src/body/sync.rs 78.89% <75.86%> (-2.48%) :arrow_down:
src/body/mod.rs 82.60% <84.37%> (-0.73%) :arrow_down:
src/cookies/jar.rs 83.57% <0.00%> (+2.85%) :arrow_up:

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.

codecov[bot] avatar Feb 15 '22 04:02 codecov[bot]

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

Xuanwo avatar Sep 01 '22 04:09 Xuanwo

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.

sagebind avatar Sep 05 '22 01:09 sagebind