Renamed RequestHeadWrapper->RequestHeadType

This commit is contained in:
Dmitry Pypin 2019-09-05 12:01:04 -07:00
parent 64b65f0c9d
commit 9f4606b0e2
8 changed files with 33 additions and 33 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "actix-http" name = "actix-http"
version = "0.2.10" version = "0.2.9"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix http primitives" description = "Actix http primitives"
readme = "README.md" readme = "README.md"

View File

@ -9,7 +9,7 @@ use h2::client::SendRequest;
use crate::body::MessageBody; use crate::body::MessageBody;
use crate::h1::ClientCodec; use crate::h1::ClientCodec;
use crate::message::{RequestHead, RequestHeadWrapper, ResponseHead}; use crate::message::{RequestHead, RequestHeadType, ResponseHead};
use crate::payload::Payload; use crate::payload::Payload;
use crate::header::HeaderMap; use crate::header::HeaderMap;
@ -129,14 +129,14 @@ where
match self.io.take().unwrap() { match self.io.take().unwrap() {
ConnectionType::H1(io) => Box::new(h1proto::send_request( ConnectionType::H1(io) => Box::new(h1proto::send_request(
io, io,
RequestHeadWrapper::Owned(head), RequestHeadType::Owned(head),
body, body,
self.created, self.created,
self.pool, self.pool,
)), )),
ConnectionType::H2(io) => Box::new(h2proto::send_request( ConnectionType::H2(io) => Box::new(h2proto::send_request(
io, io,
RequestHeadWrapper::Owned(head), RequestHeadType::Owned(head),
body, body,
self.created, self.created,
self.pool, self.pool,
@ -153,14 +153,14 @@ where
match self.io.take().unwrap() { match self.io.take().unwrap() {
ConnectionType::H1(io) => Box::new(h1proto::send_request( ConnectionType::H1(io) => Box::new(h1proto::send_request(
io, io,
RequestHeadWrapper::Rc(head, extra_headers), RequestHeadType::Rc(head, extra_headers),
body, body,
self.created, self.created,
self.pool, self.pool,
)), )),
ConnectionType::H2(io) => Box::new(h2proto::send_request( ConnectionType::H2(io) => Box::new(h2proto::send_request(
io, io,
RequestHeadWrapper::Rc(head, extra_headers), RequestHeadType::Rc(head, extra_headers),
body, body,
self.created, self.created,
self.pool, self.pool,
@ -182,7 +182,7 @@ where
fn open_tunnel(mut self, head: RequestHead) -> Self::TunnelFuture { fn open_tunnel(mut self, head: RequestHead) -> Self::TunnelFuture {
match self.io.take().unwrap() { match self.io.take().unwrap() {
ConnectionType::H1(io) => { ConnectionType::H1(io) => {
Either::A(Box::new(h1proto::open_tunnel(io, RequestHeadWrapper::Owned(head)))) Either::A(Box::new(h1proto::open_tunnel(io, RequestHeadType::Owned(head))))
} }
ConnectionType::H2(io) => { ConnectionType::H2(io) => {
if let Some(mut pool) = self.pool.take() { if let Some(mut pool) = self.pool.take() {
@ -200,7 +200,7 @@ where
fn open_tunnel_extra(mut self, head: Rc<RequestHead>, extra_headers: Option<HeaderMap>) -> Self::TunnelFuture { fn open_tunnel_extra(mut self, head: Rc<RequestHead>, extra_headers: Option<HeaderMap>) -> Self::TunnelFuture {
match self.io.take().unwrap() { match self.io.take().unwrap() {
ConnectionType::H1(io) => { ConnectionType::H1(io) => {
Either::A(Box::new(h1proto::open_tunnel(io, RequestHeadWrapper::Rc(head, extra_headers)))) Either::A(Box::new(h1proto::open_tunnel(io, RequestHeadType::Rc(head, extra_headers))))
} }
ConnectionType::H2(io) => { ConnectionType::H2(io) => {
if let Some(mut pool) = self.pool.take() { if let Some(mut pool) = self.pool.take() {

View File

@ -9,7 +9,7 @@ use futures::{Async, Future, Poll, Sink, Stream};
use crate::error::PayloadError; use crate::error::PayloadError;
use crate::h1; use crate::h1;
use crate::http::header::{IntoHeaderValue, HOST}; use crate::http::header::{IntoHeaderValue, HOST};
use crate::message::{RequestHeadWrapper, ResponseHead}; use crate::message::{RequestHeadType, ResponseHead};
use crate::payload::{Payload, PayloadStream}; use crate::payload::{Payload, PayloadStream};
use crate::header::HeaderMap; use crate::header::HeaderMap;
@ -20,7 +20,7 @@ use crate::body::{BodySize, MessageBody};
pub(crate) fn send_request<T, B>( pub(crate) fn send_request<T, B>(
io: T, io: T,
mut head_wrapper: RequestHeadWrapper, mut head_wrapper: RequestHeadType,
body: B, body: B,
created: time::Instant, created: time::Instant,
pool: Option<Acquired<T>>, pool: Option<Acquired<T>>,
@ -42,10 +42,10 @@ where
match wrt.get_mut().take().freeze().try_into() { match wrt.get_mut().take().freeze().try_into() {
Ok(value) => { Ok(value) => {
match head_wrapper { match head_wrapper {
RequestHeadWrapper::Owned(ref mut head) => { RequestHeadType::Owned(ref mut head) => {
head.headers.insert(HOST, value) head.headers.insert(HOST, value)
}, },
RequestHeadWrapper::Rc(_, ref mut extra_headers) => { RequestHeadType::Rc(_, ref mut extra_headers) => {
let headers = extra_headers.get_or_insert(HeaderMap::new()); let headers = extra_headers.get_or_insert(HeaderMap::new());
headers.insert(HOST, value) headers.insert(HOST, value)
}, },
@ -104,7 +104,7 @@ where
pub(crate) fn open_tunnel<T>( pub(crate) fn open_tunnel<T>(
io: T, io: T,
head_wrapper: RequestHeadWrapper, head_wrapper: RequestHeadType,
) -> impl Future<Item = (ResponseHead, Framed<T, h1::ClientCodec>), Error = SendRequestError> ) -> impl Future<Item = (ResponseHead, Framed<T, h1::ClientCodec>), Error = SendRequestError>
where where
T: AsyncRead + AsyncWrite + 'static, T: AsyncRead + AsyncWrite + 'static,

View File

@ -9,7 +9,7 @@ use http::header::{HeaderValue, CONNECTION, CONTENT_LENGTH, TRANSFER_ENCODING};
use http::{request::Request, HttpTryFrom, Method, Version}; use http::{request::Request, HttpTryFrom, Method, Version};
use crate::body::{BodySize, MessageBody}; use crate::body::{BodySize, MessageBody};
use crate::message::{RequestHeadWrapper, ResponseHead}; use crate::message::{RequestHeadType, ResponseHead};
use crate::payload::Payload; use crate::payload::Payload;
use crate::header::HeaderMap; use crate::header::HeaderMap;
@ -19,7 +19,7 @@ use super::pool::Acquired;
pub(crate) fn send_request<T, B>( pub(crate) fn send_request<T, B>(
io: SendRequest<Bytes>, io: SendRequest<Bytes>,
head_wrapper: RequestHeadWrapper, head_wrapper: RequestHeadType,
body: B, body: B,
created: time::Instant, created: time::Instant,
pool: Option<Acquired<T>>, pool: Option<Acquired<T>>,
@ -69,8 +69,8 @@ where
// Extracting extra headers from RequestHeadWrapper. HeaderMap::new() does not allocate. // Extracting extra headers from RequestHeadWrapper. HeaderMap::new() does not allocate.
let (head_wrapper, extra_headers) = match head_wrapper { let (head_wrapper, extra_headers) = match head_wrapper {
RequestHeadWrapper::Owned(head) => (RequestHeadWrapper::Owned(head), HeaderMap::new()), RequestHeadType::Owned(head) => (RequestHeadType::Owned(head), HeaderMap::new()),
RequestHeadWrapper::Rc(head, extra_headers) => (RequestHeadWrapper::Rc(head, None), extra_headers.unwrap_or(HeaderMap::new())), RequestHeadType::Rc(head, extra_headers) => (RequestHeadType::Rc(head, None), extra_headers.unwrap_or(HeaderMap::new())),
}; };
// merging headers from head and extra headers. // merging headers from head and extra headers.

View File

@ -17,7 +17,7 @@ use crate::body::BodySize;
use crate::config::ServiceConfig; use crate::config::ServiceConfig;
use crate::error::{ParseError, PayloadError}; use crate::error::{ParseError, PayloadError};
use crate::helpers; use crate::helpers;
use crate::message::{ConnectionType, Head, MessagePool, RequestHead, RequestHeadWrapper, ResponseHead}; use crate::message::{ConnectionType, Head, MessagePool, RequestHead, RequestHeadType, ResponseHead};
use crate::header::HeaderMap; use crate::header::HeaderMap;
bitflags! { bitflags! {
@ -50,7 +50,7 @@ struct ClientCodecInner {
// encoder part // encoder part
flags: Flags, flags: Flags,
headers_size: u32, headers_size: u32,
encoder: encoder::MessageEncoder<RequestHeadWrapper>, encoder: encoder::MessageEncoder<RequestHeadType>,
} }
impl Default for ClientCodec { impl Default for ClientCodec {
@ -185,7 +185,7 @@ impl Decoder for ClientPayloadCodec {
} }
impl Encoder for ClientCodec { impl Encoder for ClientCodec {
type Item = Message<(RequestHeadWrapper, BodySize)>; type Item = Message<(RequestHeadType, BodySize)>;
type Error = io::Error; type Error = io::Error;
fn encode( fn encode(

View File

@ -16,7 +16,7 @@ use crate::http::header::{
HeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING, HeaderValue, ACCEPT_ENCODING, CONNECTION, CONTENT_LENGTH, DATE, TRANSFER_ENCODING,
}; };
use crate::http::{HeaderMap, Method, StatusCode, Version}; use crate::http::{HeaderMap, Method, StatusCode, Version};
use crate::message::{ConnectionType, Head, RequestHead, ResponseHead, RequestHeadWrapper}; use crate::message::{ConnectionType, Head, RequestHead, ResponseHead, RequestHeadType};
use crate::request::Request; use crate::request::Request;
use crate::response::Response; use crate::response::Response;
@ -263,7 +263,7 @@ impl MessageType for Response<()> {
} }
} }
impl MessageType for RequestHeadWrapper { impl MessageType for RequestHeadType {
fn status(&self) -> Option<StatusCode> { fn status(&self) -> Option<StatusCode> {
None None
} }
@ -538,7 +538,7 @@ mod tests {
head.headers head.headers
.insert(CONTENT_TYPE, HeaderValue::from_static("plain/text")); .insert(CONTENT_TYPE, HeaderValue::from_static("plain/text"));
let mut head_wrapper = RequestHeadWrapper::Owned(head); let mut head_wrapper = RequestHeadType::Owned(head);
let _ = head_wrapper.encode_headers( let _ = head_wrapper.encode_headers(
&mut bytes, &mut bytes,
@ -584,7 +584,7 @@ mod tests {
head.headers head.headers
.append(CONTENT_TYPE, HeaderValue::from_static("xml")); .append(CONTENT_TYPE, HeaderValue::from_static("xml"));
let mut head_wrapper = RequestHeadWrapper::Owned(head); let mut head_wrapper = RequestHeadType::Owned(head);
let _ = head_wrapper.encode_headers( let _ = head_wrapper.encode_headers(
&mut bytes, &mut bytes,
@ -610,7 +610,7 @@ mod tests {
extra_headers.insert(AUTHORIZATION,HeaderValue::from_static("another authorization")); extra_headers.insert(AUTHORIZATION,HeaderValue::from_static("another authorization"));
extra_headers.insert(DATE, HeaderValue::from_static("date")); extra_headers.insert(DATE, HeaderValue::from_static("date"));
let mut head_wrapper = RequestHeadWrapper::Rc(Rc::new(head), Some(extra_headers)); let mut head_wrapper = RequestHeadType::Rc(Rc::new(head), Some(extra_headers));
let _ = head_wrapper.encode_headers( let _ = head_wrapper.encode_headers(
&mut bytes, &mut bytes,

View File

@ -182,25 +182,25 @@ impl RequestHead {
} }
#[derive(Debug)] #[derive(Debug)]
pub enum RequestHeadWrapper { pub enum RequestHeadType {
Owned(RequestHead), Owned(RequestHead),
Rc(Rc<RequestHead>, Option<HeaderMap>), Rc(Rc<RequestHead>, Option<HeaderMap>),
} }
impl RequestHeadWrapper { impl RequestHeadType {
pub fn extra_headers(&self) -> Option<&HeaderMap> { pub fn extra_headers(&self) -> Option<&HeaderMap> {
match self { match self {
RequestHeadWrapper::Owned(_) => None, RequestHeadType::Owned(_) => None,
RequestHeadWrapper::Rc(_, headers) => headers.as_ref(), RequestHeadType::Rc(_, headers) => headers.as_ref(),
} }
} }
} }
impl AsRef<RequestHead> for RequestHeadWrapper { impl AsRef<RequestHead> for RequestHeadType {
fn as_ref(&self) -> &RequestHead { fn as_ref(&self) -> &RequestHead {
match self { match self {
RequestHeadWrapper::Owned(head) => &head, RequestHeadType::Owned(head) => &head,
RequestHeadWrapper::Rc(head, _) => head.as_ref(), RequestHeadType::Rc(head, _) => head.as_ref(),
} }
} }
} }

View File

@ -1,6 +1,6 @@
[package] [package]
name = "awc" name = "awc"
version = "0.2.5" version = "0.2.4"
authors = ["Nikolay Kim <fafhrd91@gmail.com>"] authors = ["Nikolay Kim <fafhrd91@gmail.com>"]
description = "Actix http client." description = "Actix http client."
readme = "README.md" readme = "README.md"