From 87c89026581d07f0b777cbd8e4d50eab5dca21b2 Mon Sep 17 00:00:00 2001 From: Dmitry Pypin Date: Mon, 9 Sep 2019 15:52:58 -0700 Subject: [PATCH] Small renaming --- actix-http/src/client/h1proto.rs | 16 ++++++++-------- actix-http/src/client/h2proto.rs | 16 ++++++++-------- actix-http/src/h1/client.rs | 10 +++++----- actix-http/src/h1/encoder.rs | 16 ++++++++-------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/actix-http/src/client/h1proto.rs b/actix-http/src/client/h1proto.rs index dfe3e7902..fa920ab92 100644 --- a/actix-http/src/client/h1proto.rs +++ b/actix-http/src/client/h1proto.rs @@ -20,7 +20,7 @@ use crate::body::{BodySize, MessageBody}; pub(crate) fn send_request( io: T, - mut head_wrapper: RequestHeadType, + mut head: RequestHeadType, body: B, created: time::Instant, pool: Option>, @@ -30,18 +30,18 @@ where B: MessageBody, { // set request host header - if !head_wrapper.as_ref().headers.contains_key(HOST) && !head_wrapper.extra_headers().iter().any(|h| h.contains_key(HOST)) { - if let Some(host) = head_wrapper.as_ref().uri.host() { + if !head.as_ref().headers.contains_key(HOST) && !head.extra_headers().iter().any(|h| h.contains_key(HOST)) { + if let Some(host) = head.as_ref().uri.host() { let mut wrt = BytesMut::with_capacity(host.len() + 5).writer(); - let _ = match head_wrapper.as_ref().uri.port_u16() { + let _ = match head.as_ref().uri.port_u16() { None | Some(80) | Some(443) => write!(wrt, "{}", host), Some(port) => write!(wrt, "{}:{}", host, port), }; match wrt.get_mut().take().freeze().try_into() { Ok(value) => { - match head_wrapper { + match head { RequestHeadType::Owned(ref mut head) => { head.headers.insert(HOST, value) }, @@ -68,7 +68,7 @@ where // create Framed and send request Framed::new(io, h1::ClientCodec::default()) - .send((head_wrapper, len).into()) + .send((head, len).into()) .from_err() // send request body .and_then(move |framed| match body.size() { @@ -104,14 +104,14 @@ where pub(crate) fn open_tunnel( io: T, - head_wrapper: RequestHeadType, + head: RequestHeadType, ) -> impl Future), Error = SendRequestError> where T: AsyncRead + AsyncWrite + 'static, { // create Framed and send request Framed::new(io, h1::ClientCodec::default()) - .send((head_wrapper, BodySize::None).into()) + .send((head, BodySize::None).into()) .from_err() // read response .and_then(|framed| { diff --git a/actix-http/src/client/h2proto.rs b/actix-http/src/client/h2proto.rs index 2a5707019..2993d89d8 100644 --- a/actix-http/src/client/h2proto.rs +++ b/actix-http/src/client/h2proto.rs @@ -19,7 +19,7 @@ use super::pool::Acquired; pub(crate) fn send_request( io: SendRequest, - head_wrapper: RequestHeadType, + head: RequestHeadType, body: B, created: time::Instant, pool: Option>, @@ -28,8 +28,8 @@ where T: AsyncRead + AsyncWrite + 'static, B: MessageBody, { - trace!("Sending client request: {:?} {:?}", head_wrapper, body.size()); - let head_req = head_wrapper.as_ref().method == Method::HEAD; + trace!("Sending client request: {:?} {:?}", head, body.size()); + let head_req = head.as_ref().method == Method::HEAD; let length = body.size(); let eof = match length { BodySize::None | BodySize::Empty | BodySize::Sized(0) => true, @@ -40,8 +40,8 @@ where .map_err(SendRequestError::from) .and_then(move |mut io| { let mut req = Request::new(()); - *req.uri_mut() = head_wrapper.as_ref().uri.clone(); - *req.method_mut() = head_wrapper.as_ref().method.clone(); + *req.uri_mut() = head.as_ref().uri.clone(); + *req.method_mut() = head.as_ref().method.clone(); *req.version_mut() = Version::HTTP_2; let mut skip_len = true; @@ -67,14 +67,14 @@ where ), }; - // Extracting extra headers from RequestHeadWrapper. HeaderMap::new() does not allocate. - let (head_wrapper, extra_headers) = match head_wrapper { + // Extracting extra headers from RequestHeadType. HeaderMap::new() does not allocate. + let (head, extra_headers) = match head { RequestHeadType::Owned(head) => (RequestHeadType::Owned(head), HeaderMap::new()), RequestHeadType::Rc(head, extra_headers) => (RequestHeadType::Rc(head, None), extra_headers.unwrap_or(HeaderMap::new())), }; // merging headers from head and extra headers. - let headers = head_wrapper.as_ref().headers.iter() + let headers = head.as_ref().headers.iter() .filter(|(name, _)| { !extra_headers.contains_key(*name) }) diff --git a/actix-http/src/h1/client.rs b/actix-http/src/h1/client.rs index 3c75a8692..c0bbcc694 100644 --- a/actix-http/src/h1/client.rs +++ b/actix-http/src/h1/client.rs @@ -194,13 +194,13 @@ impl Encoder for ClientCodec { dst: &mut BytesMut, ) -> Result<(), Self::Error> { match item { - Message::Item((mut head_wrapper, length)) => { + Message::Item((mut head, length)) => { let inner = &mut self.inner; - inner.version = head_wrapper.as_ref().version; - inner.flags.set(Flags::HEAD, head_wrapper.as_ref().method == Method::HEAD); + inner.version = head.as_ref().version; + inner.flags.set(Flags::HEAD, head.as_ref().method == Method::HEAD); // connection status - inner.ctype = match head_wrapper.as_ref().connection_type() { + inner.ctype = match head.as_ref().connection_type() { ConnectionType::KeepAlive => { if inner.flags.contains(Flags::KEEPALIVE_ENABLED) { ConnectionType::KeepAlive @@ -214,7 +214,7 @@ impl Encoder for ClientCodec { inner.encoder.encode( dst, - &mut head_wrapper, + &mut head, false, false, inner.version, diff --git a/actix-http/src/h1/encoder.rs b/actix-http/src/h1/encoder.rs index efae76f63..380dfe328 100644 --- a/actix-http/src/h1/encoder.rs +++ b/actix-http/src/h1/encoder.rs @@ -538,9 +538,9 @@ mod tests { head.headers .insert(CONTENT_TYPE, HeaderValue::from_static("plain/text")); - let mut head_wrapper = RequestHeadType::Owned(head); + let mut head = RequestHeadType::Owned(head); - let _ = head_wrapper.encode_headers( + let _ = head.encode_headers( &mut bytes, Version::HTTP_11, BodySize::Empty, @@ -552,7 +552,7 @@ mod tests { Bytes::from_static(b"\r\nContent-Length: 0\r\nConnection: close\r\nDate: date\r\nContent-Type: plain/text\r\n\r\n") ); - let _ = head_wrapper.encode_headers( + let _ = head.encode_headers( &mut bytes, Version::HTTP_11, BodySize::Stream, @@ -564,7 +564,7 @@ mod tests { Bytes::from_static(b"\r\nTransfer-Encoding: chunked\r\nDate: date\r\nContent-Type: plain/text\r\n\r\n") ); - let _ = head_wrapper.encode_headers( + let _ = head.encode_headers( &mut bytes, Version::HTTP_11, BodySize::Sized64(100), @@ -584,9 +584,9 @@ mod tests { head.headers .append(CONTENT_TYPE, HeaderValue::from_static("xml")); - let mut head_wrapper = RequestHeadType::Owned(head); + let mut head = RequestHeadType::Owned(head); - let _ = head_wrapper.encode_headers( + let _ = head.encode_headers( &mut bytes, Version::HTTP_11, BodySize::Stream, @@ -610,9 +610,9 @@ mod tests { extra_headers.insert(AUTHORIZATION,HeaderValue::from_static("another authorization")); extra_headers.insert(DATE, HeaderValue::from_static("date")); - let mut head_wrapper = RequestHeadType::Rc(Rc::new(head), Some(extra_headers)); + let mut head = RequestHeadType::Rc(Rc::new(head), Some(extra_headers)); - let _ = head_wrapper.encode_headers( + let _ = head.encode_headers( &mut bytes, Version::HTTP_11, BodySize::Empty,