Skip to content

Commit 0b4b33c

Browse files
committed
fix: multipart crate has not been maintained in a long time
1 parent fcb2746 commit 0b4b33c

File tree

5 files changed

+788
-12
lines changed

5 files changed

+788
-12
lines changed

Cargo.toml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,9 @@ flate2 = { version = "1.0.24", default-features = false, optional = true }
2525
http = "1"
2626
log = "0.4.17"
2727
mime = { version = "0.3.16", optional = true }
28-
multipart = { version = "0.18.0", default-features = false, features = [
29-
"client",
30-
], optional = true }
28+
mime_guess = { version = "2.0.5", optional = true }
3129
native-tls = { version = "0.2.10", optional = true }
30+
rand = { version = "0.9.0", optional = true }
3231
rustls-native-certs = { version = "0.8.1", optional = true }
3332
rustls = { version = "0.23.22", optional = true }
3433
serde = { version = "1.0.143", optional = true }
@@ -47,9 +46,6 @@ http-body-util = "0.1.2"
4746
hyper = { version = "1.6.0", features = ["full"] }
4847
hyper-util = "0.1.10"
4948
lazy_static = "1.4.0"
50-
multipart = { version = "0.18.0", default-features = false, features = [
51-
"server",
52-
] }
5349
rustls = "0.23.22"
5450
tokio = { version = "1.20.1", features = ["full"] }
5551
tokio-rustls = "0.26.1"
@@ -64,7 +60,7 @@ compress-zlib-ng = ["flate2/zlib-ng"]
6460
default = ["compress", "tls-native"]
6561
form = ["serde", "serde_urlencoded"]
6662
json = ["serde", "serde_json"]
67-
multipart-form = ["multipart", "mime"]
63+
multipart-form = ["mime", "mime_guess", "rand"]
6864
# The following TLS features are mutually exclusive
6965
tls-native = ["native-tls"]
7066
tls-rustls-webpki-roots = ["__rustls", "webpki-roots"]

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,17 @@ macro_rules! warn {
7272
pub mod charsets;
7373
mod error;
7474
mod happy;
75-
#[cfg(feature = "multipart")]
75+
#[cfg(feature = "multipart-form")]
7676
mod multipart;
77+
#[cfg(feature = "multipart-form")]
78+
mod multipart_crate;
7779
mod parsing;
7880
mod request;
7981
mod streams;
8082
mod tls;
8183

8284
pub use crate::error::{Error, ErrorKind, InvalidResponseKind, Result};
83-
#[cfg(feature = "multipart")]
85+
#[cfg(feature = "multipart-form")]
8486
pub use crate::multipart::{Multipart, MultipartBuilder, MultipartFile};
8587
pub use crate::parsing::{Response, ResponseReader};
8688
pub use crate::request::proxy::{ProxySettings, ProxySettingsBuilder};

src/multipart.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use super::body::{Body, BodyKind};
22
use super::{Error, ErrorKind, Result};
33
use mime::Mime;
4-
use multipart::client as mp;
54
use std::fmt;
65
use std::io::{copy, prelude::*, Cursor, Error as IoError, Result as IoResult};
76

@@ -77,7 +76,7 @@ impl<'key, 'data> MultipartBuilder<'key, 'data> {
7776

7877
/// Creates a `Multipart` to be used as a body.
7978
pub fn build(self) -> Result<Multipart<'data>> {
80-
let mut mp = mp::lazy::Multipart::new();
79+
let mut mp = crate::multipart_crate::lazy::Multipart::new();
8180
for (k, v) in self.text {
8281
mp.add_text(k, v);
8382
}
@@ -91,7 +90,7 @@ impl<'key, 'data> MultipartBuilder<'key, 'data> {
9190

9291
/// A multipart form created using `MultipartBuilder`.
9392
pub struct Multipart<'data> {
94-
data: mp::lazy::PreparedFields<'data>,
93+
data: crate::multipart_crate::lazy::PreparedFields<'data>,
9594
}
9695

9796
impl Body for Multipart<'_> {

0 commit comments

Comments
 (0)