Skip to content

Commit 9c80fdb

Browse files
committed
refactor(lib): rename http_types to http
1 parent 6f71932 commit 9c80fdb

File tree

12 files changed

+97
-97
lines changed

12 files changed

+97
-97
lines changed

src/client/compat_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use futures::{Future, Poll, Stream};
2-
use http_types;
2+
use http;
33
use tokio_service::Service;
44

55
use client::{Connect, Client, FutureResponse};
@@ -21,8 +21,8 @@ where C: Connect,
2121
B: Stream<Error=Error> + 'static,
2222
B::Item: AsRef<[u8]>,
2323
{
24-
type Request = http_types::Request<B>;
25-
type Response = http_types::Response<Body>;
24+
type Request = http::Request<B>;
25+
type Response = http::Response<Body>;
2626
type Error = Error;
2727
type Future = CompatFutureResponse;
2828

@@ -43,7 +43,7 @@ pub fn future(fut: FutureResponse) -> CompatFutureResponse {
4343
}
4444

4545
impl Future for CompatFutureResponse {
46-
type Item = http_types::Response<Body>;
46+
type Item = http::Response<Body>;
4747
type Error = Error;
4848

4949
fn poll(&mut self) -> Poll<Self::Item, Error> {

src/client/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::time::Duration;
1010
use futures::{future, Poll, Async, Future, Stream};
1111
use futures::unsync::oneshot;
1212
#[cfg(feature = "compat")]
13-
use http_types;
13+
use http;
1414
use tokio_io::{AsyncRead, AsyncWrite};
1515
use tokio::reactor::Handle;
1616
use tokio_proto::BindClient;
@@ -118,7 +118,7 @@ where C: Connect,
118118
/// Send an `http::Request` using this Client.
119119
#[inline]
120120
#[cfg(feature = "compat")]
121-
pub fn request_compat(&self, req: http_types::Request<B>) -> compat::CompatFutureResponse {
121+
pub fn request_compat(&self, req: http::Request<B>) -> compat::CompatFutureResponse {
122122
self::compat_impl::future(self.call(req.into()))
123123
}
124124

src/header/mod.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ use std::iter::{FromIterator, IntoIterator};
8383
use std::{mem, fmt};
8484

8585
#[cfg(feature = "compat")]
86-
use http_types;
86+
use http;
8787

8888
use unicase::Ascii;
8989

@@ -552,8 +552,8 @@ impl fmt::Debug for Headers {
552552
}
553553

554554
#[cfg(feature = "compat")]
555-
impl From<http_types::HeaderMap> for Headers {
556-
fn from(mut header_map: http_types::HeaderMap) -> Headers {
555+
impl From<http::HeaderMap> for Headers {
556+
fn from(mut header_map: http::HeaderMap) -> Headers {
557557
let mut headers = Headers::new();
558558
for (name, mut value_drain) in header_map.drain() {
559559
if let Some(first_value) = value_drain.next() {
@@ -569,23 +569,23 @@ impl From<http_types::HeaderMap> for Headers {
569569
}
570570

571571
#[cfg(feature = "compat")]
572-
impl From<Headers> for http_types::HeaderMap {
573-
fn from(headers: Headers) -> http_types::HeaderMap {
574-
let mut header_map = http_types::HeaderMap::new();
572+
impl From<Headers> for http::HeaderMap {
573+
fn from(headers: Headers) -> http::HeaderMap {
574+
let mut header_map = http::HeaderMap::new();
575575
for header in headers.iter() {
576576
let entry = header_map.entry(header.name())
577577
.expect("attempted to convert invalid header name");
578578
let mut value_iter = header.raw().iter().map(|line| {
579-
http_types::header::HeaderValue::from_bytes(line)
579+
http::header::HeaderValue::from_bytes(line)
580580
.expect("attempted to convert invalid header value")
581581
});
582582
match entry {
583-
http_types::header::Entry::Occupied(mut occupied) => {
583+
http::header::Entry::Occupied(mut occupied) => {
584584
for value in value_iter {
585585
occupied.append(value);
586586
}
587587
},
588-
http_types::header::Entry::Vacant(vacant) => {
588+
http::header::Entry::Vacant(vacant) => {
589589
if let Some(first_value) = value_iter.next() {
590590
let mut occupied = vacant.insert_entry(first_value);
591591
for value in value_iter {
@@ -996,22 +996,22 @@ mod tests {
996996
#[test]
997997
#[cfg(feature = "compat")]
998998
fn test_compat() {
999-
use http_types;
999+
use http;
10001000

10011001
let mut orig_hyper_headers = Headers::new();
10021002
orig_hyper_headers.set(ContentLength(11));
10031003
orig_hyper_headers.set(Host::new("foo.bar", None));
10041004
orig_hyper_headers.append_raw("x-foo", b"bar".to_vec());
10051005
orig_hyper_headers.append_raw("x-foo", b"quux".to_vec());
10061006

1007-
let mut orig_http_headers = http_types::HeaderMap::new();
1008-
orig_http_headers.insert(http_types::header::CONTENT_LENGTH, "11".parse().unwrap());
1009-
orig_http_headers.insert(http_types::header::HOST, "foo.bar".parse().unwrap());
1007+
let mut orig_http_headers = http::HeaderMap::new();
1008+
orig_http_headers.insert(http::header::CONTENT_LENGTH, "11".parse().unwrap());
1009+
orig_http_headers.insert(http::header::HOST, "foo.bar".parse().unwrap());
10101010
orig_http_headers.append("x-foo", "bar".parse().unwrap());
10111011
orig_http_headers.append("x-foo", "quux".parse().unwrap());
10121012

10131013
let conv_hyper_headers: Headers = orig_http_headers.clone().into();
1014-
let conv_http_headers: http_types::HeaderMap = orig_hyper_headers.clone().into();
1014+
let conv_http_headers: http::HeaderMap = orig_hyper_headers.clone().into();
10151015
assert_eq!(orig_hyper_headers, conv_hyper_headers);
10161016
assert_eq!(orig_http_headers, conv_http_headers);
10171017
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ extern crate bytes;
2222
#[macro_use] extern crate futures;
2323
extern crate futures_cpupool;
2424
#[cfg(feature = "compat")]
25-
extern crate http as http_types;
25+
extern crate http;
2626
extern crate httparse;
2727
extern crate language_tags;
2828
#[macro_use] extern crate log;

src/method.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::str::FromStr;
44
use std::convert::AsRef;
55

66
#[cfg(feature = "compat")]
7-
use http_types;
7+
use http;
88

99
use error::Error;
1010
use self::Method::{Options, Get, Post, Put, Delete, Head, Trace, Connect, Patch,
@@ -160,26 +160,26 @@ impl Default for Method {
160160
}
161161

162162
#[cfg(feature = "compat")]
163-
impl From<http_types::Method> for Method {
164-
fn from(method: http_types::Method) -> Method {
163+
impl From<http::Method> for Method {
164+
fn from(method: http::Method) -> Method {
165165
match method {
166-
http_types::Method::GET =>
166+
http::Method::GET =>
167167
Method::Get,
168-
http_types::Method::POST =>
168+
http::Method::POST =>
169169
Method::Post,
170-
http_types::Method::PUT =>
170+
http::Method::PUT =>
171171
Method::Put,
172-
http_types::Method::DELETE =>
172+
http::Method::DELETE =>
173173
Method::Delete,
174-
http_types::Method::HEAD =>
174+
http::Method::HEAD =>
175175
Method::Head,
176-
http_types::Method::OPTIONS =>
176+
http::Method::OPTIONS =>
177177
Method::Options,
178-
http_types::Method::CONNECT =>
178+
http::Method::CONNECT =>
179179
Method::Connect,
180-
http_types::Method::PATCH =>
180+
http::Method::PATCH =>
181181
Method::Patch,
182-
http_types::Method::TRACE =>
182+
http::Method::TRACE =>
183183
Method::Trace,
184184
_ => {
185185
method.as_ref().parse()
@@ -190,29 +190,29 @@ impl From<http_types::Method> for Method {
190190
}
191191

192192
#[cfg(feature = "compat")]
193-
impl From<Method> for http_types::Method {
194-
fn from(method: Method) -> http_types::Method {
195-
use http_types::HttpTryFrom;
193+
impl From<Method> for http::Method {
194+
fn from(method: Method) -> http::Method {
195+
use http::HttpTryFrom;
196196

197197
match method {
198198
Method::Get =>
199-
http_types::Method::GET,
199+
http::Method::GET,
200200
Method::Post =>
201-
http_types::Method::POST,
201+
http::Method::POST,
202202
Method::Put =>
203-
http_types::Method::PUT,
203+
http::Method::PUT,
204204
Method::Delete =>
205-
http_types::Method::DELETE,
205+
http::Method::DELETE,
206206
Method::Head =>
207-
http_types::Method::HEAD,
207+
http::Method::HEAD,
208208
Method::Options =>
209-
http_types::Method::OPTIONS,
209+
http::Method::OPTIONS,
210210
Method::Connect =>
211-
http_types::Method::CONNECT,
211+
http::Method::CONNECT,
212212
Method::Patch =>
213-
http_types::Method::PATCH,
213+
http::Method::PATCH,
214214
Method::Trace =>
215-
http_types::Method::TRACE,
215+
http::Method::TRACE,
216216
Method::Extension(s) => {
217217
HttpTryFrom::try_from(s.as_str())
218218
.expect("attempted to convert invalid method")
@@ -279,7 +279,7 @@ mod tests {
279279
#[test]
280280
#[cfg(feature = "compat")]
281281
fn test_compat() {
282-
use http_types::{self, HttpTryFrom};
282+
use http::{self, HttpTryFrom};
283283

284284
let methods = vec![
285285
"GET",
@@ -289,9 +289,9 @@ mod tests {
289289
];
290290
for method in methods {
291291
let orig_hyper_method = Method::from_str(method).unwrap();
292-
let orig_http_method = http_types::Method::try_from(method).unwrap();
292+
let orig_http_method = http::Method::try_from(method).unwrap();
293293
let conv_hyper_method: Method = orig_http_method.clone().into();
294-
let conv_http_method: http_types::Method = orig_hyper_method.clone().into();
294+
let conv_http_method: http::Method = orig_hyper_method.clone().into();
295295
assert_eq!(orig_hyper_method, conv_hyper_method);
296296
assert_eq!(orig_http_method, conv_http_method);
297297
}

src/proto/request.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::mem::replace;
44
use std::net::SocketAddr;
55

66
#[cfg(feature = "compat")]
7-
use http_types;
7+
use http;
88

99
use header::Headers;
1010
use proto::{Body, MessageHead, RequestHead, RequestLine};
@@ -138,25 +138,25 @@ impl<B> fmt::Debug for Request<B> {
138138
}
139139

140140
#[cfg(feature = "compat")]
141-
impl From<Request> for http_types::Request<Body> {
142-
fn from(from_req: Request) -> http_types::Request<Body> {
141+
impl From<Request> for http::Request<Body> {
142+
fn from(from_req: Request) -> http::Request<Body> {
143143
let (m, u, v, h, b) = from_req.deconstruct();
144144

145-
let to_req = http_types::Request::new(());
145+
let to_req = http::Request::new(());
146146
let (mut to_parts, _) = to_req.into_parts();
147147

148148
to_parts.method = m.into();
149149
to_parts.uri = u.into();
150150
to_parts.version = v.into();
151151
to_parts.headers = h.into();
152152

153-
http_types::Request::from_parts(to_parts, b)
153+
http::Request::from_parts(to_parts, b)
154154
}
155155
}
156156

157157
#[cfg(feature = "compat")]
158-
impl<B> From<http_types::Request<B>> for Request<B> {
159-
fn from(from_req: http_types::Request<B>) -> Request<B> {
158+
impl<B> From<http::Request<B>> for Request<B> {
159+
fn from(from_req: http::Request<B>) -> Request<B> {
160160
let (from_parts, body) = from_req.into_parts();
161161

162162
let mut to_req = Request::new(from_parts.method.into(), from_parts.uri.into());

src/proto/response.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::fmt;
33
use std::mem::replace;
44

55
#[cfg(feature = "compat")]
6-
use http_types;
6+
use http;
77

88
use header::{Header, Headers};
99
use proto::{MessageHead, ResponseHead, Body};
@@ -148,8 +148,8 @@ impl fmt::Debug for Response {
148148
}
149149

150150
#[cfg(feature = "compat")]
151-
impl<B> From<http_types::Response<B>> for Response<B> {
152-
fn from(from_res: http_types::Response<B>) -> Response<B> {
151+
impl<B> From<http::Response<B>> for Response<B> {
152+
fn from(from_res: http::Response<B>) -> Response<B> {
153153
let (from_parts, body) = from_res.into_parts();
154154
let mut to_res = Response::new();
155155
to_res.version = from_parts.version.into();
@@ -160,14 +160,14 @@ impl<B> From<http_types::Response<B>> for Response<B> {
160160
}
161161

162162
#[cfg(feature = "compat")]
163-
impl From<Response> for http_types::Response<Body> {
164-
fn from(mut from_res: Response) -> http_types::Response<Body> {
165-
let (mut to_parts, ()) = http_types::Response::new(()).into_parts();
163+
impl From<Response> for http::Response<Body> {
164+
fn from(mut from_res: Response) -> http::Response<Body> {
165+
let (mut to_parts, ()) = http::Response::new(()).into_parts();
166166
to_parts.version = from_res.version().into();
167167
to_parts.status = from_res.status().into();
168168
let from_headers = replace(from_res.headers_mut(), Headers::new());
169169
to_parts.headers = from_headers.into();
170-
http_types::Response::from_parts(to_parts, from_res.body())
170+
http::Response::from_parts(to_parts, from_res.body())
171171
}
172172
}
173173

src/server/compat_impl.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::io::{Error as IoError};
22

33
use futures::{Future, Poll};
4-
use http_types;
4+
use http;
55
use tokio_service::{NewService, Service};
66

77
use error::Error;
@@ -17,7 +17,7 @@ pub struct CompatFuture<F> {
1717
}
1818

1919
impl<F, Bd> Future for CompatFuture<F>
20-
where F: Future<Item=http_types::Response<Bd>, Error=Error>
20+
where F: Future<Item=http::Response<Bd>, Error=Error>
2121
{
2222
type Item = Response<Bd>;
2323
type Error = Error;
@@ -41,7 +41,7 @@ pub fn service<S>(service: S) -> CompatService<S> {
4141
}
4242

4343
impl<S, Bd> Service for CompatService<S>
44-
where S: Service<Request=http_types::Request<Body>, Response=http_types::Response<Bd>, Error=Error>
44+
where S: Service<Request=http::Request<Body>, Response=http::Response<Bd>, Error=Error>
4545
{
4646
type Request = Request;
4747
type Response = Response<Bd>;
@@ -68,7 +68,7 @@ pub fn new_service<S>(new_service: S) -> NewCompatService<S> {
6868
}
6969

7070
impl<S, Bd> NewService for NewCompatService<S>
71-
where S: NewService<Request=http_types::Request<Body>, Response=http_types::Response<Bd>, Error=Error>
71+
where S: NewService<Request=http::Request<Body>, Response=http::Response<Bd>, Error=Error>
7272
{
7373
type Request = Request;
7474
type Response = Response<Bd>;

src/server/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use futures::{Future, Stream, Poll, Async, Sink, StartSend, AsyncSink};
2222
use futures::future::Map;
2323

2424
#[cfg(feature = "compat")]
25-
use http_types;
25+
use http;
2626

2727
use tokio_io::{AsyncRead, AsyncWrite};
2828
use tokio::reactor::{Core, Handle, Timeout};
@@ -129,7 +129,7 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
129129
/// See `Http::bind`.
130130
#[cfg(feature = "compat")]
131131
pub fn bind_compat<S, Bd>(&self, addr: &SocketAddr, new_service: S) -> ::Result<Server<compat::NewCompatService<S>, Bd>>
132-
where S: NewService<Request = http_types::Request<Body>, Response = http_types::Response<Bd>, Error = ::Error> +
132+
where S: NewService<Request = http::Request<Body>, Response = http::Response<Bd>, Error = ::Error> +
133133
Send + Sync + 'static,
134134
Bd: Stream<Item=B, Error=::Error>,
135135
{
@@ -174,7 +174,7 @@ impl<B: AsRef<[u8]> + 'static> Http<B> {
174174
io: I,
175175
remote_addr: SocketAddr,
176176
service: S)
177-
where S: Service<Request = http_types::Request<Body>, Response = http_types::Response<Bd>, Error = ::Error> + 'static,
177+
where S: Service<Request = http::Request<Body>, Response = http::Response<Bd>, Error = ::Error> + 'static,
178178
Bd: Stream<Item=B, Error=::Error> + 'static,
179179
I: AsyncRead + AsyncWrite + 'static,
180180
{

0 commit comments

Comments
 (0)