1
0
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:
Nikolay Kim
2018-01-29 14:44:25 -08:00
parent 6416a796c3
commit b686f39d0b
10 changed files with 474 additions and 68 deletions

View File

@@ -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) {