mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +01:00
add helper conversion from ClientResponse for HttpResponseBuilder
This commit is contained in:
parent
afb81b6b8f
commit
e8a1850c79
@ -18,6 +18,8 @@ use error::Error;
|
||||
use handler::Responder;
|
||||
use header::{Header, IntoHeaderValue, ContentEncoding};
|
||||
use httprequest::HttpRequest;
|
||||
use httpmessage::HttpMessage;
|
||||
use client::ClientResponse;
|
||||
|
||||
/// max write buffer size 64k
|
||||
pub(crate) const MAX_WRITE_BUFFER_SIZE: usize = 65_536;
|
||||
@ -722,6 +724,20 @@ impl Responder for BytesMut {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create `HttpResponseBuilder` from `ClientResponse`
|
||||
///
|
||||
/// It is useful for proxy response. This implementation
|
||||
/// copies all responses's headers and status.
|
||||
impl<'a> From<&'a ClientResponse> for HttpResponseBuilder {
|
||||
fn from(resp: &'a ClientResponse) -> HttpResponseBuilder {
|
||||
let mut builder = HttpResponse::build(resp.status());
|
||||
for (key, value) in resp.headers() {
|
||||
builder.header(key.clone(), value.clone());
|
||||
}
|
||||
builder
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
struct InnerHttpResponse {
|
||||
version: Option<Version>,
|
||||
|
Loading…
Reference in New Issue
Block a user