Make multipart an optional feature (default off) (#1128)

This commit is contained in:
nickelc
2021-01-04 22:20:17 +01:00
committed by GitHub
parent 1f425a0244
commit afed48cafd
12 changed files with 51 additions and 9 deletions

View File

@@ -152,6 +152,7 @@ impl Body {
ImplStream(self)
}
#[cfg(feature = "multipart")]
pub(crate) fn content_length(&self) -> Option<u64> {
match self.inner {
Inner::Reusable(ref bytes) => Some(bytes.len() as u64),

View File

@@ -9,6 +9,7 @@ pub(crate) use self::decoder::Decoder;
pub mod body;
pub mod client;
pub mod decoder;
#[cfg(feature = "multipart")]
pub mod multipart;
pub(crate) mod request;
mod response;

View File

@@ -11,9 +11,12 @@ use serde_json;
use super::body::Body;
use super::client::{Client, Pending};
#[cfg(feature = "multipart")]
use super::multipart;
use super::response::Response;
use crate::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_LENGTH, CONTENT_TYPE};
use crate::header::{HeaderMap, HeaderName, HeaderValue, CONTENT_TYPE};
#[cfg(feature = "multipart")]
use crate::header::CONTENT_LENGTH;
use crate::{Method, Url};
use http::{Request as HttpRequest, request::Parts};
@@ -260,6 +263,7 @@ impl RequestBuilder {
/// # Ok(())
/// # }
/// ```
#[cfg(feature = "multipart")]
pub fn multipart(self, mut multipart: multipart::Form) -> RequestBuilder {
let mut builder = self.header(
CONTENT_TYPE,