Update to http 0.2 (#432)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,)
|
||||
})?);
|
||||
|
||||
@@ -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 = [] }
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user