diff --git a/Cargo.toml b/Cargo.toml index 1e55be5..b8e7e05 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -18,7 +18,7 @@ futures = "0.1" tokio-io = "0.1.3" tokio-timer = "0.1" bytes = "0.4" -http = { git = "https://github.com/carllerche/http", rev = "2dd15d9" } +http = { git = "https://github.com/carllerche/http" } byteorder = "1.0" log = "0.3.8" fnv = "1.0.5" diff --git a/examples/akamai.rs b/examples/akamai.rs index e0275fb..c061b70 100644 --- a/examples/akamai.rs +++ b/examples/akamai.rs @@ -10,7 +10,7 @@ extern crate env_logger; use h2::client::Client; -use http::{method, Request}; +use http::{Request, Method}; use futures::*; use tokio_core::reactor; @@ -65,7 +65,7 @@ pub fn main() { let mut h2 = res.unwrap(); let request = Request::builder() - .method(method::GET) + .method(Method::GET) .uri("https://http2.akamai.com/") .body(()).unwrap(); diff --git a/examples/server-tr.rs b/examples/server-tr.rs index 4951674..61a1903 100644 --- a/examples/server-tr.rs +++ b/examples/server-tr.rs @@ -38,7 +38,7 @@ pub fn main() { println!("GOT request: {:?}", request); let response = Response::builder() - .status(status::OK) + .status(StatusCode::OK) .body(()).unwrap(); if let Err(e) = stream.send_response(response, false) { diff --git a/examples/server.rs b/examples/server.rs index 39b0785..f12e663 100644 --- a/examples/server.rs +++ b/examples/server.rs @@ -38,7 +38,7 @@ pub fn main() { println!("GOT request: {:?}", request); let response = Response::builder() - .status(status::OK) + .status(StatusCode::OK) .body(()).unwrap(); if let Err(e) = stream.send_response(response, false) { diff --git a/src/hpack/decoder.rs b/src/hpack/decoder.rs index 44e1b0e..0608fa4 100644 --- a/src/hpack/decoder.rs +++ b/src/hpack/decoder.rs @@ -1,7 +1,9 @@ use super::{huffman, Header}; use frame; -use http::{method, header, status}; +use http::{header}; +use http::method::{self, Method}; +use http::status::{self, StatusCode}; use bytes::{Buf, Bytes, BytesMut}; use string::String; @@ -544,24 +546,24 @@ impl From for frame::Error { /// Get an entry from the static table pub fn get_static(idx: usize) -> Header { - use http::{status, method, header}; + use http::header; use http::header::HeaderValue; match idx { 1 => Header::Authority(from_static("")), - 2 => Header::Method(method::GET), - 3 => Header::Method(method::POST), + 2 => Header::Method(Method::GET), + 3 => Header::Method(Method::POST), 4 => Header::Path(from_static("/")), 5 => Header::Path(from_static("/index.html")), 6 => Header::Scheme(from_static("http")), 7 => Header::Scheme(from_static("https")), - 8 => Header::Status(status::OK), - 9 => Header::Status(status::NO_CONTENT), - 10 => Header::Status(status::PARTIAL_CONTENT), - 11 => Header::Status(status::NOT_MODIFIED), - 12 => Header::Status(status::BAD_REQUEST), - 13 => Header::Status(status::NOT_FOUND), - 14 => Header::Status(status::INTERNAL_SERVER_ERROR), + 8 => Header::Status(StatusCode::OK), + 9 => Header::Status(StatusCode::NO_CONTENT), + 10 => Header::Status(StatusCode::PARTIAL_CONTENT), + 11 => Header::Status(StatusCode::NOT_MODIFIED), + 12 => Header::Status(StatusCode::BAD_REQUEST), + 13 => Header::Status(StatusCode::NOT_FOUND), + 14 => Header::Status(StatusCode::INTERNAL_SERVER_ERROR), 15 => Header::Field { name: header::ACCEPT_CHARSET, value: HeaderValue::from_static(""), diff --git a/src/hpack/table.rs b/src/hpack/table.rs index 8382b72..fc94f4d 100644 --- a/src/hpack/table.rs +++ b/src/hpack/table.rs @@ -1,7 +1,8 @@ use super::Header; use fnv::FnvHasher; -use http::{method, header}; +use http::header; +use http::method::Method; use std::{cmp, mem, usize}; use std::collections::VecDeque; @@ -721,8 +722,8 @@ fn index_static(header: &Header) -> Option<(usize, bool)> { Header::Authority(_) => Some((1, false)), Header::Method(ref v) => { match *v { - method::GET => Some((2, true)), - method::POST => Some((3, true)), + Method::GET => Some((2, true)), + Method::POST => Some((3, true)), _ => Some((2, false)), } } diff --git a/src/hpack/test/fuzz.rs b/src/hpack/test/fuzz.rs index 6a6aa94..79b37f4 100644 --- a/src/hpack/test/fuzz.rs +++ b/src/hpack/test/fuzz.rs @@ -176,8 +176,7 @@ impl Arbitrary for FuzzHpack { } fn gen_header(g: &mut StdRng) -> Header> { - use http::StatusCode; - use http::method::{self, Method}; + use http::{Method, StatusCode}; if g.gen_weighted_bool(10) { match g.next_u32() % 5 { @@ -187,11 +186,11 @@ fn gen_header(g: &mut StdRng) -> Header> { } 1 => { let method = match g.next_u32() % 6 { - 0 => method::GET, - 1 => method::POST, - 2 => method::PUT, - 3 => method::PATCH, - 4 => method::DELETE, + 0 => Method::GET, + 1 => Method::POST, + 2 => Method::PUT, + 3 => Method::PATCH, + 4 => Method::DELETE, 5 => { let n: usize = g.gen_range(3, 7); let bytes: Vec = (0..n).map(|_| { diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 638bc02..6480148 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -299,7 +299,7 @@ impl Streams pub fn send_request(&mut self, request: Request<()>, end_of_stream: bool) -> Result, SendError> { - use http::method; + use http::Method; use super::stream::ContentLength; // TODO: There is a hazard with assigning a stream ID before the @@ -319,7 +319,7 @@ impl Streams me.actions.send.init_window_sz(), me.actions.recv.init_window_sz()); - if *request.method() == method::HEAD { + if *request.method() == Method::HEAD { stream.content_length = ContentLength::Head; } diff --git a/src/server.rs b/src/server.rs index 93a4598..4c41ee7 100644 --- a/src/server.rs +++ b/src/server.rs @@ -418,7 +418,7 @@ impl proto::Peer for Peer { fn convert_poll_message(headers: frame::Headers) -> Result { - use http::{version, uri}; + use http::{Version, uri}; let mut b = Request::builder(); @@ -434,7 +434,7 @@ impl proto::Peer for Peer { } }; - b.version(version::HTTP_2); + b.version(Version::HTTP_2); if let Some(method) = pseudo.method { b.method(method); diff --git a/tests/flow_control.rs b/tests/flow_control.rs index 4d19e0c..48c9ec3 100644 --- a/tests/flow_control.rs +++ b/tests/flow_control.rs @@ -30,7 +30,7 @@ fn send_data_without_requesting_capacity() { .wait().unwrap(); let request = Request::builder() - .method(method::POST) + .method(Method::POST) .uri("https://http2.akamai.com/") .body(()).unwrap(); @@ -44,7 +44,7 @@ fn send_data_without_requesting_capacity() { // Get the response let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::NO_CONTENT); + assert_eq!(resp.status(), StatusCode::NO_CONTENT); h2.wait().unwrap(); } diff --git a/tests/prioritization.rs b/tests/prioritization.rs index 632d472..d06b4d6 100644 --- a/tests/prioritization.rs +++ b/tests/prioritization.rs @@ -28,7 +28,7 @@ fn single_stream_send_large_body() { .wait().unwrap(); let request = Request::builder() - .method(method::POST) + .method(Method::POST) .uri("https://http2.akamai.com/") .body(()).unwrap(); @@ -45,7 +45,7 @@ fn single_stream_send_large_body() { // Get the response let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::NO_CONTENT); + assert_eq!(resp.status(), StatusCode::NO_CONTENT); h2.wait().unwrap(); } @@ -82,7 +82,7 @@ fn single_stream_send_extra_large_body_multi_frames_one_buffer() { .wait().unwrap(); let request = Request::builder() - .method(method::POST) + .method(Method::POST) .uri("https://http2.akamai.com/") .body(()).unwrap(); @@ -98,7 +98,7 @@ fn single_stream_send_extra_large_body_multi_frames_one_buffer() { // Get the response let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::NO_CONTENT); + assert_eq!(resp.status(), StatusCode::NO_CONTENT); h2.wait().unwrap(); } @@ -147,7 +147,7 @@ fn single_stream_send_extra_large_body_multi_frames_multi_buffer() { .wait().unwrap(); let request = Request::builder() - .method(method::POST) + .method(Method::POST) .uri("https://http2.akamai.com/") .body(()).unwrap(); @@ -164,7 +164,7 @@ fn single_stream_send_extra_large_body_multi_frames_multi_buffer() { // Get the response let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::NO_CONTENT); + assert_eq!(resp.status(), StatusCode::NO_CONTENT); h2.wait().unwrap(); } diff --git a/tests/stream_states.rs b/tests/stream_states.rs index 0262a31..6d14016 100644 --- a/tests/stream_states.rs +++ b/tests/stream_states.rs @@ -32,7 +32,7 @@ fn send_recv_headers_only() { let mut stream = h2.request(request, true).unwrap(); let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::NO_CONTENT); + assert_eq!(resp.status(), StatusCode::NO_CONTENT); h2.wait().unwrap(); } @@ -66,7 +66,7 @@ fn send_recv_data() { .wait().unwrap(); let request = Request::builder() - .method(method::POST) + .method(Method::POST) .uri("https://http2.akamai.com/") .body(()).unwrap(); @@ -83,7 +83,7 @@ fn send_recv_data() { // Get the response let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::OK); + assert_eq!(resp.status(), StatusCode::OK); // Take the body let (_, body) = resp.into_parts(); @@ -131,7 +131,7 @@ fn send_headers_recv_data_single_frame() { let mut stream = h2.request(request, true).unwrap(); let resp = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(resp.status(), status::OK); + assert_eq!(resp.status(), StatusCode::OK); // Take the body let (_, body) = resp.into_parts(); @@ -169,7 +169,7 @@ fn send_data_after_headers_eos() { // Send the request let mut request = request::Head::default(); - request.method = method::POST; + request.method = Method::POST; request.uri = "https://http2.akamai.com/".parse().unwrap(); let id = 1.into(); diff --git a/tests/support/Cargo.toml b/tests/support/Cargo.toml index 0444a74..82d5fcb 100644 --- a/tests/support/Cargo.toml +++ b/tests/support/Cargo.toml @@ -7,7 +7,7 @@ authors = ["Carl Lerche "] futures = "0.1" tokio-io = "0.1" bytes = "0.4" -http = { git = "https://github.com/carllerche/http", rev = "2dd15d9" } +http = { git = "https://github.com/carllerche/http" } env_logger = "0.4" mock-io = { git = "https://github.com/carllerche/mock-io", branch = "experiments" } diff --git a/tests/support/src/lib.rs b/tests/support/src/lib.rs index d66d8b1..75670c2 100644 --- a/tests/support/src/lib.rs +++ b/tests/support/src/lib.rs @@ -21,11 +21,11 @@ pub use self::futures::future::poll_fn; pub use self::http::{ request, response, - method, - status, Request, Response, + Method, HeaderMap, + StatusCode, }; pub use self::h2::*; diff --git a/tests/trailers.rs b/tests/trailers.rs index f4982ae..809936b 100644 --- a/tests/trailers.rs +++ b/tests/trailers.rs @@ -35,7 +35,7 @@ fn recv_trailers_only() { let mut stream = h2.request(request, true).unwrap(); let response = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(response.status(), status::OK); + assert_eq!(response.status(), StatusCode::OK); let (_, mut body) = response.into_parts(); @@ -88,7 +88,7 @@ fn send_trailers_immediately() { stream.send_trailers(trailers).unwrap(); let response = h2.run(poll_fn(|| stream.poll_response())).unwrap(); - assert_eq!(response.status(), status::OK); + assert_eq!(response.status(), StatusCode::OK); let (_, mut body) = response.into_parts();