refactor(lib): rename http_types to http

This commit is contained in:
Sean McArthur
2017-09-29 18:12:55 -07:00
parent 6f71932015
commit 9c80fdbb9e
12 changed files with 97 additions and 97 deletions

View File

@@ -1,5 +1,5 @@
use futures::{Future, Poll, Stream}; use futures::{Future, Poll, Stream};
use http_types; use http;
use tokio_service::Service; use tokio_service::Service;
use client::{Connect, Client, FutureResponse}; use client::{Connect, Client, FutureResponse};
@@ -21,8 +21,8 @@ where C: Connect,
B: Stream<Error=Error> + 'static, B: Stream<Error=Error> + 'static,
B::Item: AsRef<[u8]>, B::Item: AsRef<[u8]>,
{ {
type Request = http_types::Request<B>; type Request = http::Request<B>;
type Response = http_types::Response<Body>; type Response = http::Response<Body>;
type Error = Error; type Error = Error;
type Future = CompatFutureResponse; type Future = CompatFutureResponse;
@@ -43,7 +43,7 @@ pub fn future(fut: FutureResponse) -> CompatFutureResponse {
} }
impl Future for CompatFutureResponse { impl Future for CompatFutureResponse {
type Item = http_types::Response<Body>; type Item = http::Response<Body>;
type Error = Error; type Error = Error;
fn poll(&mut self) -> Poll<Self::Item, Error> { fn poll(&mut self) -> Poll<Self::Item, Error> {

View File

@@ -10,7 +10,7 @@ use std::time::Duration;
use futures::{future, Poll, Async, Future, Stream}; use futures::{future, Poll, Async, Future, Stream};
use futures::unsync::oneshot; use futures::unsync::oneshot;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use tokio::reactor::Handle; use tokio::reactor::Handle;
use tokio_proto::BindClient; use tokio_proto::BindClient;
@@ -118,7 +118,7 @@ where C: Connect,
/// Send an `http::Request` using this Client. /// Send an `http::Request` using this Client.
#[inline] #[inline]
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
pub fn request_compat(&self, req: http_types::Request<B>) -> compat::CompatFutureResponse { pub fn request_compat(&self, req: http::Request<B>) -> compat::CompatFutureResponse {
self::compat_impl::future(self.call(req.into())) self::compat_impl::future(self.call(req.into()))
} }

View File

@@ -83,7 +83,7 @@ use std::iter::{FromIterator, IntoIterator};
use std::{mem, fmt}; use std::{mem, fmt};
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use unicase::Ascii; use unicase::Ascii;
@@ -552,8 +552,8 @@ impl fmt::Debug for Headers {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<http_types::HeaderMap> for Headers { impl From<http::HeaderMap> for Headers {
fn from(mut header_map: http_types::HeaderMap) -> Headers { fn from(mut header_map: http::HeaderMap) -> Headers {
let mut headers = Headers::new(); let mut headers = Headers::new();
for (name, mut value_drain) in header_map.drain() { for (name, mut value_drain) in header_map.drain() {
if let Some(first_value) = value_drain.next() { if let Some(first_value) = value_drain.next() {
@@ -569,23 +569,23 @@ impl From<http_types::HeaderMap> for Headers {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<Headers> for http_types::HeaderMap { impl From<Headers> for http::HeaderMap {
fn from(headers: Headers) -> http_types::HeaderMap { fn from(headers: Headers) -> http::HeaderMap {
let mut header_map = http_types::HeaderMap::new(); let mut header_map = http::HeaderMap::new();
for header in headers.iter() { for header in headers.iter() {
let entry = header_map.entry(header.name()) let entry = header_map.entry(header.name())
.expect("attempted to convert invalid header name"); .expect("attempted to convert invalid header name");
let mut value_iter = header.raw().iter().map(|line| { let mut value_iter = header.raw().iter().map(|line| {
http_types::header::HeaderValue::from_bytes(line) http::header::HeaderValue::from_bytes(line)
.expect("attempted to convert invalid header value") .expect("attempted to convert invalid header value")
}); });
match entry { match entry {
http_types::header::Entry::Occupied(mut occupied) => { http::header::Entry::Occupied(mut occupied) => {
for value in value_iter { for value in value_iter {
occupied.append(value); occupied.append(value);
} }
}, },
http_types::header::Entry::Vacant(vacant) => { http::header::Entry::Vacant(vacant) => {
if let Some(first_value) = value_iter.next() { if let Some(first_value) = value_iter.next() {
let mut occupied = vacant.insert_entry(first_value); let mut occupied = vacant.insert_entry(first_value);
for value in value_iter { for value in value_iter {
@@ -996,7 +996,7 @@ mod tests {
#[test] #[test]
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
fn test_compat() { fn test_compat() {
use http_types; use http;
let mut orig_hyper_headers = Headers::new(); let mut orig_hyper_headers = Headers::new();
orig_hyper_headers.set(ContentLength(11)); orig_hyper_headers.set(ContentLength(11));
@@ -1004,14 +1004,14 @@ mod tests {
orig_hyper_headers.append_raw("x-foo", b"bar".to_vec()); orig_hyper_headers.append_raw("x-foo", b"bar".to_vec());
orig_hyper_headers.append_raw("x-foo", b"quux".to_vec()); orig_hyper_headers.append_raw("x-foo", b"quux".to_vec());
let mut orig_http_headers = http_types::HeaderMap::new(); let mut orig_http_headers = http::HeaderMap::new();
orig_http_headers.insert(http_types::header::CONTENT_LENGTH, "11".parse().unwrap()); orig_http_headers.insert(http::header::CONTENT_LENGTH, "11".parse().unwrap());
orig_http_headers.insert(http_types::header::HOST, "foo.bar".parse().unwrap()); orig_http_headers.insert(http::header::HOST, "foo.bar".parse().unwrap());
orig_http_headers.append("x-foo", "bar".parse().unwrap()); orig_http_headers.append("x-foo", "bar".parse().unwrap());
orig_http_headers.append("x-foo", "quux".parse().unwrap()); orig_http_headers.append("x-foo", "quux".parse().unwrap());
let conv_hyper_headers: Headers = orig_http_headers.clone().into(); let conv_hyper_headers: Headers = orig_http_headers.clone().into();
let conv_http_headers: http_types::HeaderMap = orig_hyper_headers.clone().into(); let conv_http_headers: http::HeaderMap = orig_hyper_headers.clone().into();
assert_eq!(orig_hyper_headers, conv_hyper_headers); assert_eq!(orig_hyper_headers, conv_hyper_headers);
assert_eq!(orig_http_headers, conv_http_headers); assert_eq!(orig_http_headers, conv_http_headers);
} }

View File

@@ -22,7 +22,7 @@ extern crate bytes;
#[macro_use] extern crate futures; #[macro_use] extern crate futures;
extern crate futures_cpupool; extern crate futures_cpupool;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
extern crate http as http_types; extern crate http;
extern crate httparse; extern crate httparse;
extern crate language_tags; extern crate language_tags;
#[macro_use] extern crate log; #[macro_use] extern crate log;

View File

@@ -4,7 +4,7 @@ use std::str::FromStr;
use std::convert::AsRef; use std::convert::AsRef;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use error::Error; use error::Error;
use self::Method::{Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch, use self::Method::{Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch,
@@ -160,26 +160,26 @@ impl Default for Method {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<http_types::Method> for Method { impl From<http::Method> for Method {
fn from(method: http_types::Method) -> Method { fn from(method: http::Method) -> Method {
match method { match method {
http_types::Method::GET => http::Method::GET =>
Method::Get, Method::Get,
http_types::Method::POST => http::Method::POST =>
Method::Post, Method::Post,
http_types::Method::PUT => http::Method::PUT =>
Method::Put, Method::Put,
http_types::Method::DELETE => http::Method::DELETE =>
Method::Delete, Method::Delete,
http_types::Method::HEAD => http::Method::HEAD =>
Method::Head, Method::Head,
http_types::Method::OPTIONS => http::Method::OPTIONS =>
Method::Options, Method::Options,
http_types::Method::CONNECT => http::Method::CONNECT =>
Method::Connect, Method::Connect,
http_types::Method::PATCH => http::Method::PATCH =>
Method::Patch, Method::Patch,
http_types::Method::TRACE => http::Method::TRACE =>
Method::Trace, Method::Trace,
_ => { _ => {
method.as_ref().parse() method.as_ref().parse()
@@ -190,29 +190,29 @@ impl From<http_types::Method> for Method {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<Method> for http_types::Method { impl From<Method> for http::Method {
fn from(method: Method) -> http_types::Method { fn from(method: Method) -> http::Method {
use http_types::HttpTryFrom; use http::HttpTryFrom;
match method { match method {
Method::Get => Method::Get =>
http_types::Method::GET, http::Method::GET,
Method::Post => Method::Post =>
http_types::Method::POST, http::Method::POST,
Method::Put => Method::Put =>
http_types::Method::PUT, http::Method::PUT,
Method::Delete => Method::Delete =>
http_types::Method::DELETE, http::Method::DELETE,
Method::Head => Method::Head =>
http_types::Method::HEAD, http::Method::HEAD,
Method::Options => Method::Options =>
http_types::Method::OPTIONS, http::Method::OPTIONS,
Method::Connect => Method::Connect =>
http_types::Method::CONNECT, http::Method::CONNECT,
Method::Patch => Method::Patch =>
http_types::Method::PATCH, http::Method::PATCH,
Method::Trace => Method::Trace =>
http_types::Method::TRACE, http::Method::TRACE,
Method::Extension(s) => { Method::Extension(s) => {
HttpTryFrom::try_from(s.as_str()) HttpTryFrom::try_from(s.as_str())
.expect("attempted to convert invalid method") .expect("attempted to convert invalid method")
@@ -279,7 +279,7 @@ mod tests {
#[test] #[test]
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
fn test_compat() { fn test_compat() {
use http_types::{self, HttpTryFrom}; use http::{self, HttpTryFrom};
let methods = vec![ let methods = vec![
"GET", "GET",
@@ -289,9 +289,9 @@ mod tests {
]; ];
for method in methods { for method in methods {
let orig_hyper_method = Method::from_str(method).unwrap(); let orig_hyper_method = Method::from_str(method).unwrap();
let orig_http_method = http_types::Method::try_from(method).unwrap(); let orig_http_method = http::Method::try_from(method).unwrap();
let conv_hyper_method: Method = orig_http_method.clone().into(); let conv_hyper_method: Method = orig_http_method.clone().into();
let conv_http_method: http_types::Method = orig_hyper_method.clone().into(); let conv_http_method: http::Method = orig_hyper_method.clone().into();
assert_eq!(orig_hyper_method, conv_hyper_method); assert_eq!(orig_hyper_method, conv_hyper_method);
assert_eq!(orig_http_method, conv_http_method); assert_eq!(orig_http_method, conv_http_method);
} }

View File

@@ -4,7 +4,7 @@ use std::mem::replace;
use std::net::SocketAddr; use std::net::SocketAddr;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use header::Headers; use header::Headers;
use proto::{Body, MessageHead, RequestHead, RequestLine}; use proto::{Body, MessageHead, RequestHead, RequestLine};
@@ -138,11 +138,11 @@ impl<B> fmt::Debug for Request<B> {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<Request> for http_types::Request<Body> { impl From<Request> for http::Request<Body> {
fn from(from_req: Request) -> http_types::Request<Body> { fn from(from_req: Request) -> http::Request<Body> {
let (m, u, v, h, b) = from_req.deconstruct(); let (m, u, v, h, b) = from_req.deconstruct();
let to_req = http_types::Request::new(()); let to_req = http::Request::new(());
let (mut to_parts, _) = to_req.into_parts(); let (mut to_parts, _) = to_req.into_parts();
to_parts.method = m.into(); to_parts.method = m.into();
@@ -150,13 +150,13 @@ impl From<Request> for http_types::Request<Body> {
to_parts.version = v.into(); to_parts.version = v.into();
to_parts.headers = h.into(); to_parts.headers = h.into();
http_types::Request::from_parts(to_parts, b) http::Request::from_parts(to_parts, b)
} }
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl<B> From<http_types::Request<B>> for Request<B> { impl<B> From<http::Request<B>> for Request<B> {
fn from(from_req: http_types::Request<B>) -> Request<B> { fn from(from_req: http::Request<B>) -> Request<B> {
let (from_parts, body) = from_req.into_parts(); let (from_parts, body) = from_req.into_parts();
let mut to_req = Request::new(from_parts.method.into(), from_parts.uri.into()); let mut to_req = Request::new(from_parts.method.into(), from_parts.uri.into());

View File

@@ -3,7 +3,7 @@ use std::fmt;
use std::mem::replace; use std::mem::replace;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use header::{Header, Headers}; use header::{Header, Headers};
use proto::{MessageHead, ResponseHead, Body}; use proto::{MessageHead, ResponseHead, Body};
@@ -148,8 +148,8 @@ impl fmt::Debug for Response {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl<B> From<http_types::Response<B>> for Response<B> { impl<B> From<http::Response<B>> for Response<B> {
fn from(from_res: http_types::Response<B>) -> Response<B> { fn from(from_res: http::Response<B>) -> Response<B> {
let (from_parts, body) = from_res.into_parts(); let (from_parts, body) = from_res.into_parts();
let mut to_res = Response::new(); let mut to_res = Response::new();
to_res.version = from_parts.version.into(); to_res.version = from_parts.version.into();
@@ -160,14 +160,14 @@ impl<B> From<http_types::Response<B>> for Response<B> {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<Response> for http_types::Response<Body> { impl From<Response> for http::Response<Body> {
fn from(mut from_res: Response) -> http_types::Response<Body> { fn from(mut from_res: Response) -> http::Response<Body> {
let (mut to_parts, ()) = http_types::Response::new(()).into_parts(); let (mut to_parts, ()) = http::Response::new(()).into_parts();
to_parts.version = from_res.version().into(); to_parts.version = from_res.version().into();
to_parts.status = from_res.status().into(); to_parts.status = from_res.status().into();
let from_headers = replace(from_res.headers_mut(), Headers::new()); let from_headers = replace(from_res.headers_mut(), Headers::new());
to_parts.headers = from_headers.into(); to_parts.headers = from_headers.into();
http_types::Response::from_parts(to_parts, from_res.body()) http::Response::from_parts(to_parts, from_res.body())
} }
} }

View File

@@ -1,7 +1,7 @@
use std::io::{Error as IoError}; use std::io::{Error as IoError};
use futures::{Future, Poll}; use futures::{Future, Poll};
use http_types; use http;
use tokio_service::{NewService, Service}; use tokio_service::{NewService, Service};
use error::Error; use error::Error;
@@ -17,7 +17,7 @@ pub struct CompatFuture<F> {
} }
impl<F, Bd> Future for CompatFuture<F> impl<F, Bd> Future for CompatFuture<F>
where F: Future<Item=http_types::Response<Bd>, Error=Error> where F: Future<Item=http::Response<Bd>, Error=Error>
{ {
type Item = Response<Bd>; type Item = Response<Bd>;
type Error = Error; type Error = Error;
@@ -41,7 +41,7 @@ pub fn service<S>(service: S) -> CompatService<S> {
} }
impl<S, Bd> Service for CompatService<S> impl<S, Bd> Service for CompatService<S>
where S: Service<Request=http_types::Request<Body>, Response=http_types::Response<Bd>, Error=Error> where S: Service<Request=http::Request<Body>, Response=http::Response<Bd>, Error=Error>
{ {
type Request = Request; type Request = Request;
type Response = Response<Bd>; type Response = Response<Bd>;
@@ -68,7 +68,7 @@ pub fn new_service<S>(new_service: S) -> NewCompatService<S> {
} }
impl<S, Bd> NewService for NewCompatService<S> impl<S, Bd> NewService for NewCompatService<S>
where S: NewService<Request=http_types::Request<Body>, Response=http_types::Response<Bd>, Error=Error> where S: NewService<Request=http::Request<Body>, Response=http::Response<Bd>, Error=Error>
{ {
type Request = Request; type Request = Request;
type Response = Response<Bd>; type Response = Response<Bd>;

View File

@@ -22,7 +22,7 @@ use futures::{Future, Stream, Poll, Async, Sink, StartSend, AsyncSink};
use futures::future::Map; use futures::future::Map;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use tokio_io::{AsyncRead, AsyncWrite}; use tokio_io::{AsyncRead, AsyncWrite};
use tokio::reactor::{Core, Handle, Timeout}; use tokio::reactor::{Core, Handle, Timeout};
@@ -129,7 +129,7 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
/// See `Http::bind`. /// See `Http::bind`.
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
pub fn bind_compat<S, Bd>(&self, addr: &SocketAddr, new_service: S) -> ::Result<Server<compat::NewCompatService<S>, Bd>> pub fn bind_compat<S, Bd>(&self, addr: &SocketAddr, new_service: S) -> ::Result<Server<compat::NewCompatService<S>, Bd>>
where S: NewService<Request = http_types::Request<Body>, Response = http_types::Response<Bd>, Error = ::Error> + where S: NewService<Request = http::Request<Body>, Response = http::Response<Bd>, Error = ::Error> +
Send + Sync + 'static, Send + Sync + 'static,
Bd: Stream<Item=B, Error=::Error>, Bd: Stream<Item=B, Error=::Error>,
{ {
@@ -174,7 +174,7 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
io: I, io: I,
remote_addr: SocketAddr, remote_addr: SocketAddr,
service: S) service: S)
where S: Service<Request = http_types::Request<Body>, Response = http_types::Response<Bd>, Error = ::Error> + 'static, where S: Service<Request = http::Request<Body>, Response = http::Response<Bd>, Error = ::Error> + 'static,
Bd: Stream<Item=B, Error=::Error> + 'static, Bd: Stream<Item=B, Error=::Error> + 'static,
I: AsyncRead + AsyncWrite + 'static, I: AsyncRead + AsyncWrite + 'static,
{ {

View File

@@ -3,7 +3,7 @@ use std::fmt;
use std::cmp::Ordering; use std::cmp::Ordering;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
/// An HTTP status code (`status-code` in RFC 7230 et al.). /// An HTTP status code (`status-code` in RFC 7230 et al.).
/// ///
@@ -600,17 +600,17 @@ impl From<StatusCode> for u16 {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<http_types::StatusCode> for StatusCode { impl From<http::StatusCode> for StatusCode {
fn from(status: http_types::StatusCode) -> StatusCode { fn from(status: http::StatusCode) -> StatusCode {
StatusCode::try_from(status.as_u16()) StatusCode::try_from(status.as_u16())
.expect("attempted to convert invalid status code") .expect("attempted to convert invalid status code")
} }
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<StatusCode> for http_types::StatusCode { impl From<StatusCode> for http::StatusCode {
fn from(status: StatusCode) -> http_types::StatusCode { fn from(status: StatusCode) -> http::StatusCode {
http_types::StatusCode::from_u16(status.as_u16()) http::StatusCode::from_u16(status.as_u16())
.expect("attempted to convert invalid status code") .expect("attempted to convert invalid status code")
} }
} }
@@ -769,12 +769,12 @@ mod tests {
#[test] #[test]
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
fn test_compat() { fn test_compat() {
use http_types::{self, HttpTryFrom}; use http::{self, HttpTryFrom};
for i in 100..600 { for i in 100..600 {
let orig_hyper_status = StatusCode::try_from(i).unwrap(); let orig_hyper_status = StatusCode::try_from(i).unwrap();
let orig_http_status = http_types::StatusCode::try_from(i).unwrap(); let orig_http_status = http::StatusCode::try_from(i).unwrap();
let conv_hyper_status: StatusCode = orig_http_status.into(); let conv_hyper_status: StatusCode = orig_http_status.into();
let conv_http_status: http_types::StatusCode = orig_hyper_status.into(); let conv_http_status: http::StatusCode = orig_hyper_status.into();
assert_eq!(orig_hyper_status, conv_hyper_status); assert_eq!(orig_hyper_status, conv_hyper_status);
assert_eq!(orig_http_status, conv_http_status); assert_eq!(orig_http_status, conv_http_status);
} }

View File

@@ -3,7 +3,7 @@ use std::fmt::{Display, self};
use std::str::{self, FromStr}; use std::str::{self, FromStr};
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use ::common::ByteStr; use ::common::ByteStr;
use bytes::{BufMut, Bytes, BytesMut}; use bytes::{BufMut, Bytes, BytesMut};
@@ -319,18 +319,18 @@ impl Display for Uri {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<http_types::Uri> for Uri { impl From<http::Uri> for Uri {
fn from(uri: http_types::Uri) -> Uri { fn from(uri: http::Uri) -> Uri {
uri.to_string().parse() uri.to_string().parse()
.expect("attempted to convert invalid uri") .expect("attempted to convert invalid uri")
} }
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<Uri> for http_types::Uri { impl From<Uri> for http::Uri {
fn from(uri: Uri) -> http_types::Uri { fn from(uri: Uri) -> http::Uri {
let bytes = uri.source.into_bytes(); let bytes = uri.source.into_bytes();
http_types::Uri::from_shared(bytes) http::Uri::from_shared(bytes)
.expect("attempted to convert invalid uri") .expect("attempted to convert invalid uri")
} }
} }

View File

@@ -6,7 +6,7 @@ use std::fmt;
use std::str::FromStr; use std::str::FromStr;
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
use http_types; use http;
use error::Error; use error::Error;
use self::HttpVersion::{Http09, Http10, Http11, H2, H2c}; use self::HttpVersion::{Http09, Http10, Http11, H2, H2c};
@@ -62,33 +62,33 @@ impl Default for HttpVersion {
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<http_types::Version> for HttpVersion { impl From<http::Version> for HttpVersion {
fn from(v: http_types::Version) -> HttpVersion { fn from(v: http::Version) -> HttpVersion {
match v { match v {
http_types::Version::HTTP_09 => http::Version::HTTP_09 =>
HttpVersion::Http09, HttpVersion::Http09,
http_types::Version::HTTP_10 => http::Version::HTTP_10 =>
HttpVersion::Http10, HttpVersion::Http10,
http_types::Version::HTTP_11 => http::Version::HTTP_11 =>
HttpVersion::Http11, HttpVersion::Http11,
http_types::Version::HTTP_2 => http::Version::HTTP_2 =>
HttpVersion::H2 HttpVersion::H2
} }
} }
} }
#[cfg(feature = "compat")] #[cfg(feature = "compat")]
impl From<HttpVersion> for http_types::Version { impl From<HttpVersion> for http::Version {
fn from(v: HttpVersion) -> http_types::Version { fn from(v: HttpVersion) -> http::Version {
match v { match v {
HttpVersion::Http09 => HttpVersion::Http09 =>
http_types::Version::HTTP_09, http::Version::HTTP_09,
HttpVersion::Http10 => HttpVersion::Http10 =>
http_types::Version::HTTP_10, http::Version::HTTP_10,
HttpVersion::Http11 => HttpVersion::Http11 =>
http_types::Version::HTTP_11, http::Version::HTTP_11,
HttpVersion::H2 => HttpVersion::H2 =>
http_types::Version::HTTP_2, http::Version::HTTP_2,
_ => panic!("attempted to convert unexpected http version") _ => panic!("attempted to convert unexpected http version")
} }
} }