mirror of
https://github.com/fafhrd91/actix-web
synced 2025-08-20 12:45:41 +02:00
complete impl for client request and response
This commit is contained in:
@@ -14,6 +14,7 @@ use futures::task::{Task, current as current_task};
|
||||
|
||||
use error::{ParseError, PayloadError, MultipartError};
|
||||
use payload::Payload;
|
||||
use client::ClientResponse;
|
||||
use httprequest::HttpRequest;
|
||||
|
||||
const MAX_HEADERS: usize = 32;
|
||||
@@ -97,6 +98,19 @@ impl Multipart {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create multipart instance for client response.
|
||||
pub fn from_response(resp: &mut ClientResponse) -> Multipart {
|
||||
match Multipart::boundary(resp.headers()) {
|
||||
Ok(boundary) => Multipart::new(boundary, resp.payload().clone()),
|
||||
Err(err) =>
|
||||
Multipart {
|
||||
error: Some(err),
|
||||
safety: Safety::new(),
|
||||
inner: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Extract boundary info from headers.
|
||||
pub fn boundary(headers: &HeaderMap) -> Result<String, MultipartError> {
|
||||
if let Some(content_type) = headers.get(header::CONTENT_TYPE) {
|
||||
|
Reference in New Issue
Block a user