diff --git a/Cargo.toml b/Cargo.toml index efa432d..ddb121a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -44,7 +44,7 @@ futures-util = { version = "0.3", default-features = false, features = [] } tokio-util = { version = "0.2", features = ["codec"] } tokio = { version = "0.2", features = ["io-util", "sync"] } bytes = "0.5.2" -http = { git = "https://github.com/hyperium/http" } #"0.1.8" +http = "0.2" log = "0.4.1" fnv = "1.0.5" slab = "0.4.0" diff --git a/src/frame/headers.rs b/src/frame/headers.rs index bedd152..2491d8d 100644 --- a/src/frame/headers.rs +++ b/src/frame/headers.rs @@ -544,7 +544,7 @@ impl Pseudo { let mut path = parts .path_and_query - .map(|v| v.into()) + .map(|v| Bytes::copy_from_slice(v.as_str().as_bytes())) .unwrap_or_else(Bytes::new); if path.is_empty() && method != Method::OPTIONS { @@ -569,7 +569,9 @@ impl Pseudo { // If the URI includes an authority component, add it to the pseudo // headers if let Some(authority) = parts.authority { - pseudo.set_authority(unsafe { BytesStr::from_utf8_unchecked(authority.into()) }); + pseudo.set_authority(unsafe { + BytesStr::from_utf8_unchecked(Bytes::copy_from_slice(authority.as_str().as_bytes())) + }); } pseudo @@ -586,7 +588,12 @@ impl Pseudo { } pub fn set_scheme(&mut self, scheme: uri::Scheme) { - self.scheme = Some(unsafe { BytesStr::from_utf8_unchecked(scheme.into()) }); + let bytes = match scheme.as_str() { + "http" => Bytes::from_static(b"http"), + "https" => Bytes::from_static(b"https"), + s => Bytes::copy_from_slice(s.as_bytes()), + }; + self.scheme = Some(unsafe { BytesStr::from_utf8_unchecked(bytes) }); } pub fn set_authority(&mut self, authority: BytesStr) { diff --git a/src/server.rs b/src/server.rs index 55f4cd7..3c893b6 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1375,7 +1375,7 @@ impl proto::Peer for Peer { // A request translated from HTTP/1 must not include the :authority // header if let Some(authority) = pseudo.authority { - let maybe_authority = uri::Authority::from_shared(authority.clone().into_inner()); + let maybe_authority = uri::Authority::from_maybe_shared(authority.clone().into_inner()); parts.authority = Some(maybe_authority.or_else(|why| { malformed!( "malformed headers: malformed authority ({:?}): {}", @@ -1387,7 +1387,7 @@ impl proto::Peer for Peer { // A :scheme is always required. if let Some(scheme) = pseudo.scheme { - let maybe_scheme = uri::Scheme::from_shared(scheme.clone().into_inner()); + let maybe_scheme = scheme.parse(); let scheme = maybe_scheme.or_else(|why| { malformed!( "malformed headers: malformed scheme ({:?}): {}", @@ -1412,7 +1412,7 @@ impl proto::Peer for Peer { malformed!("malformed headers: missing path"); } - let maybe_path = uri::PathAndQuery::from_shared(path.clone().into_inner()); + let maybe_path = uri::PathAndQuery::from_maybe_shared(path.clone().into_inner()); parts.path_and_query = Some(maybe_path.or_else(|why| { malformed!("malformed headers: malformed path ({:?}): {}", path, why,) })?); diff --git a/tests/h2-fuzz/Cargo.toml b/tests/h2-fuzz/Cargo.toml index a429ca6..d119aed 100644 --- a/tests/h2-fuzz/Cargo.toml +++ b/tests/h2-fuzz/Cargo.toml @@ -11,5 +11,5 @@ h2 = { path = "../.." } env_logger = { version = "0.5.3", default-features = false } futures = { version = "0.3", default-features = false } honggfuzz = "0.5" -http = { git = "https://github.com/hyperium/http" } #"0.1.3" +http = "0.2" tokio = { version = "0.2", features = [] } diff --git a/tests/h2-support/Cargo.toml b/tests/h2-support/Cargo.toml index 66db1b6..6d24d59 100644 --- a/tests/h2-support/Cargo.toml +++ b/tests/h2-support/Cargo.toml @@ -10,6 +10,6 @@ h2 = { path = "../..", features = ["unstable-stream", "unstable"] } bytes = "0.5" env_logger = "0.5.9" futures = { version = "0.3", default-features = false } -http = { git = "https://github.com/hyperium/http" } #"0.1.3" +http = "0.2" tokio = { version = "0.2", features = ["time"] } tokio-test = "0.2" diff --git a/tests/h2-tests/tests/client_request.rs b/tests/h2-tests/tests/client_request.rs index 8fa2b5f..b156d97 100644 --- a/tests/h2-tests/tests/client_request.rs +++ b/tests/h2-tests/tests/client_request.rs @@ -861,7 +861,7 @@ async fn request_options_with_star() { let uri = uri::Uri::from_parts({ let mut parts = uri::Parts::default(); parts.scheme = Some(uri::Scheme::HTTP); - parts.authority = Some(uri::Authority::from_shared("example.com".into()).unwrap()); + parts.authority = Some(uri::Authority::from_static("example.com")); parts.path_and_query = Some(uri::PathAndQuery::from_static("*")); parts })