[rust-crates] Update http to 0.1.19
This updates the `http` crate to 0.1.19, which adds support for link-local
addresses in the Uri type.
Bug: 36623
Change-Id: I082dd1c0f29ff7ed874a27530360eaa9188b5723
diff --git a/third_party/rust_crates/Cargo.lock b/third_party/rust_crates/Cargo.lock
index 6fd531b..6829295 100644
--- a/third_party/rust_crates/Cargo.lock
+++ b/third_party/rust_crates/Cargo.lock
@@ -688,7 +688,7 @@
"harfbuzz 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)",
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper 0.12.24 (registry+https://github.com/rust-lang/crates.io-index)",
"hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)",
"id_tree 1.5.0 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -941,7 +941,7 @@
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
- "http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"indexmap 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
"slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1008,7 +1008,7 @@
[[package]]
name = "http"
-version = "0.1.15"
+version = "0.1.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1029,7 +1029,7 @@
"bytes 0.4.11 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.29 (registry+https://github.com/rust-lang/crates.io-index)",
"h2 0.1.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)",
+ "http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)",
"httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"itoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -3205,7 +3205,7 @@
"checksum hashbrown 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "61e4900fa4e80b3d15c78a08ec8a08433246063fa7577e7b2c6426b3b21b1f79"
"checksum heck 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205"
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
-"checksum http 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)" = "1a10e5b573b9a0146545010f50772b9e8b1dd0a256564cc4307694c68832a2f5"
+"checksum http 0.1.19 (registry+https://github.com/rust-lang/crates.io-index)" = "d7e06e336150b178206af098a055e3621e8336027e2b4d126bda0bc64824baaf"
"checksum httparse 1.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "e8734b0cfd3bc3e101ec59100e101c2eecd19282202e87808b3037b442777a83"
"checksum hyper 0.12.24 (registry+https://github.com/rust-lang/crates.io-index)" = "fdfa9b401ef6c4229745bb6e9b2529192d07b920eed624cdee2a82348cd550af"
"checksum hyper-rustls 0.17.1 (registry+https://github.com/rust-lang/crates.io-index)" = "719d85c7df4a7f309a77d145340a063ea929dcb2e025bae46a80345cffec2952"
diff --git a/third_party/rust_crates/vendor/http/.cargo-checksum.json b/third_party/rust_crates/vendor/http/.cargo-checksum.json
index 880aeaa..e50d579 100644
--- a/third_party/rust_crates/vendor/http/.cargo-checksum.json
+++ b/third_party/rust_crates/vendor/http/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"CHANGELOG.md":"13b0f685dda24d8292863299facde90206d1aa9a059128b7664f34eff5abee41","Cargo.toml":"e190526ef579a3c1aad69736f950a3c441b6212d5fd4c6280a6b5e731fd71150","LICENSE-APACHE":"8bb1b50b0e5c9399ae33bd35fab2769010fa6c14e8860c729a52295d84896b7a","LICENSE-MIT":"dc91f8200e4b2a1f9261035d4c18c33c246911a6c0f7b543d75347e61b249cff","README.md":"f73e225735ebdcafa1ba79216261fe24828f873d8940c9f96adb37d933a93aaf","benches/header_map/basic.rs":"7e91c67c5ee59bb0f12bba735e4b2ed0b0fc2a4c0007c3920dfc66d266eeaeeb","benches/header_map/mod.rs":"601ab90cdb234f0d1e15c98d9d407f1dd44984d6abb0ecaccd9f64f1fc5255e2","benches/header_map/vec_map.rs":"6cee49372f891c21355d04c336ebd26971c42b78a2edb7e8281174d771856d2f","benches/header_value.rs":"53c765dff1ad2c7e7f9bfcb35bdbb3f9b42e3e0a537401dc691226488389062c","benches/uri.rs":"5e3e5c4cbaa69390317a32b1e8f15aa4e9425466739dd81c3d3d379c47da1457","src/byte_str.rs":"87688714c2d8fb1086e362d1d239bd3353a7f4bc6839740eeea3fcbbfd3d71e5","src/convert.rs":"b4ef00e97f56ebdcd98ee43a3d1460f4b50aa0dcef39a8e25d13b31d16d148d4","src/error.rs":"0e4df207f49be5af249870837607f8fc24102a4641a7b775f907688deff6930a","src/extensions.rs":"7e57d0ff5251bb8fb212c36168849a3f9b14ee8aa1aeed8483153908562aa07a","src/header/map.rs":"33a3ace9d4165c4611a69b122b81c8e1352240986d8e92aeb8f475e919230d12","src/header/mod.rs":"59c0431016f797e4d700b5aabb9c6092c40acde3d2003d3c70bc373fa6fe37b2","src/header/name.rs":"09647672d74ffa56c83e437150e5d2b9c0e5828cf0361b09c201c0679472c832","src/header/value.rs":"0456bd07ac6a623888a5f5cb87a4be750440da10d24aaf887d52cc465f9bb732","src/lib.rs":"df900587ffc8b8d80e174bebaa7565b2a42153da34251da8e33a61efd344e238","src/method.rs":"63b72090a01b7d920c2d5f487b580c4bd93fb522514a5dc2dd3b2ed11d3dee5a","src/request.rs":"b9e99d5cb00d82bd2239832ddbc3bb6f684efd08410d08f498f50cdcf4ef3062","src/response.rs":"90cb51393bb27ef589c4b29fa438d4d3488ae74178a24be169bfba33700e557d","src/status.rs":"11440c53df112388613a1bde2ad1b9a3bf46aacf700e070c7aa4131e3f242e14","src/uri/authority.rs":"f43757cdcd8bfc75e6e389cf76d241e8fe4ce2376d5736334d38f6e511d0c792","src/uri/builder.rs":"6dc27c738fd57f0e44313c511dd1e14dcc9fa1362638a6b5255c73ef00307d90","src/uri/mod.rs":"f5c4b634f380003456d00a5f40e727b1c05512b4e2e796f26785472a9f25ec6e","src/uri/path.rs":"9fc8b66498b1806175efd07961c35ab0cd5312da0219fd98674cd072db952f6e","src/uri/port.rs":"a52c7d16d21f22897d5007c673dbd2a6fdfa550385cff663b6d7642893e4e71e","src/uri/scheme.rs":"2152ec76ad60c5de2182f3714f7ce2ee514d632d510917a7c4ddc8a9ec36292d","src/uri/tests.rs":"97b6150971ed284de0407d37faf2decb402a611543fda29fee61f471937f81e5","src/version.rs":"d7cea6976335425a1fd10766083f9ac74b9f8c6667c2e71abf5f0886c0a93186","tests/header_map.rs":"4b52dfd11e37353ecc242220a3db7ea8b000c373ae33f3a527c3cfeb020c6cc0","tests/header_map_fuzz.rs":"9fc39a62f89dc7794d1e29dbf70ac352b1ddf981501a59cfcca02f6fd11acd98","tests/status_code.rs":"112e27e367e2adc16d5734b6a523d6dd5208e69fd6b9e596d95111051881d10b"},"package":"1a10e5b573b9a0146545010f50772b9e8b1dd0a256564cc4307694c68832a2f5"}
\ No newline at end of file
+{"files":{"CHANGELOG.md":"94e6ec3c93b08d14b91eadadaed9a2f7cd3414ee186c47a413fd009b7b2a3a95","Cargo.toml":"bd026b9ffb632b8fcc70e325d51a2f7dbc8c4727f1115f2bbfe2a1868ce0e2b3","LICENSE-APACHE":"8bb1b50b0e5c9399ae33bd35fab2769010fa6c14e8860c729a52295d84896b7a","LICENSE-MIT":"dc91f8200e4b2a1f9261035d4c18c33c246911a6c0f7b543d75347e61b249cff","README.md":"f73e225735ebdcafa1ba79216261fe24828f873d8940c9f96adb37d933a93aaf","benches/header_map/basic.rs":"7e91c67c5ee59bb0f12bba735e4b2ed0b0fc2a4c0007c3920dfc66d266eeaeeb","benches/header_map/mod.rs":"601ab90cdb234f0d1e15c98d9d407f1dd44984d6abb0ecaccd9f64f1fc5255e2","benches/header_map/vec_map.rs":"6cee49372f891c21355d04c336ebd26971c42b78a2edb7e8281174d771856d2f","benches/header_name.rs":"ae65e76147a0251cf0191edbed5961c99cc9407f2eba006d8f59b4c2dc636c1e","benches/header_value.rs":"0b8fd23e545e805a4f5b37f83188a6b9b53748ea8d28dcb60ae79af1297e609d","benches/uri.rs":"5e3e5c4cbaa69390317a32b1e8f15aa4e9425466739dd81c3d3d379c47da1457","src/byte_str.rs":"87688714c2d8fb1086e362d1d239bd3353a7f4bc6839740eeea3fcbbfd3d71e5","src/convert.rs":"ec6d60146e9bd6782151142a3ee2dbc1c63b6938157639540454aa39a981dc75","src/error.rs":"d41cef53237f877a379b145aa9f920af39e1342af5e2454aead88e7878978e59","src/extensions.rs":"a850e041ccdec2e9f85ec923abfd1dd0abce491cd0cebf9bda8803b6721b6bd3","src/header/map.rs":"520caa2b0643e692f04f25225eaa731b9b306312dfcb328660c23cfe4ad4aae8","src/header/mod.rs":"59c0431016f797e4d700b5aabb9c6092c40acde3d2003d3c70bc373fa6fe37b2","src/header/name.rs":"cd320f63fc39f8120cf49f03f35286ed1ba2653c8961d7a001ad2ccff3612085","src/header/value.rs":"45107836fbe6da226702093510ad35bd5c2362f8e0d4bc53fd8d17d4eeb32467","src/lib.rs":"f51bd362412657c9bde73aa556a997a17bce83a82d944d0f63e8d61029b94556","src/method.rs":"73162e820717c788a06cbac94e199a52a09dd7040ce63243e38feaf6342ca642","src/request.rs":"38739f181ef3864d66d63639aa8de67e65f0bc4543c55c5226c5d28fb0d49688","src/response.rs":"8f54380bac712e5f912fee625c2a688a50666403c1080d14b1e4bf2c93cfbf25","src/status.rs":"319514b1c6f654d8934cdf4d3fc865e6f9a2525def5fde95a7c935f122b07345","src/uri/authority.rs":"12523634ab71c514e853e186448cf7cc73ce8dea688ad7d6270f7aaaecd4a5bf","src/uri/builder.rs":"6dc27c738fd57f0e44313c511dd1e14dcc9fa1362638a6b5255c73ef00307d90","src/uri/mod.rs":"f5c4b634f380003456d00a5f40e727b1c05512b4e2e796f26785472a9f25ec6e","src/uri/path.rs":"11e3a0b40e9b32e8a9d9018003d30ac36d12f876532b07af8aa72324c2374267","src/uri/port.rs":"a52c7d16d21f22897d5007c673dbd2a6fdfa550385cff663b6d7642893e4e71e","src/uri/scheme.rs":"2152ec76ad60c5de2182f3714f7ce2ee514d632d510917a7c4ddc8a9ec36292d","src/uri/tests.rs":"7da1c0a4ace29501b3a104094184f708321c979835e3aa82ab942fc8136f6c0c","src/version.rs":"d7cea6976335425a1fd10766083f9ac74b9f8c6667c2e71abf5f0886c0a93186","tests/header_map.rs":"4b52dfd11e37353ecc242220a3db7ea8b000c373ae33f3a527c3cfeb020c6cc0","tests/header_map_fuzz.rs":"0a1419849a14d346055d8560eb4c7d8c618a2b147874f636df911e981b5b3676","tests/status_code.rs":"112e27e367e2adc16d5734b6a523d6dd5208e69fd6b9e596d95111051881d10b"},"package":"d7e06e336150b178206af098a055e3621e8336027e2b4d126bda0bc64824baaf"}
\ No newline at end of file
diff --git a/third_party/rust_crates/vendor/http/CHANGELOG.md b/third_party/rust_crates/vendor/http/CHANGELOG.md
index 94e1851..04dc9da 100644
--- a/third_party/rust_crates/vendor/http/CHANGELOG.md
+++ b/third_party/rust_crates/vendor/http/CHANGELOG.md
@@ -1,3 +1,22 @@
+# 0.1.19 (October 15, 2019)
+
+* Allow `%` in IPv6 addresses in `Uri` (#343).
+
+# 0.1.18 (July 26, 2019)
+
+* Fix compilation of `HeaderName` parsing on WASM targets (#324).
+* Implement `HttpTryFrom<HashMap>` for `HeaderMap` (#326).
+* Export `http::header::HeaderValue` as `http::HeaderValue`.
+
+# 0.1.17 (April 5, 2019)
+
+* Add `Error::inner_ref()` to view the kind of error (#303)
+* Add `headers_ref()` and `headers_mut()` methods to `request::Builder` and `response::Builder` (#293)
+
+# 0.1.16 (February 19, 2019)
+
+* Fix `Uri` to permit more characters in the `path` (#296)
+
# 0.1.15 (January 22, 2019)
* Fix `Uri::host()` to include brackets of IPv6 literals (#292)
diff --git a/third_party/rust_crates/vendor/http/Cargo.toml b/third_party/rust_crates/vendor/http/Cargo.toml
index 272e819..7050a46 100644
--- a/third_party/rust_crates/vendor/http/Cargo.toml
+++ b/third_party/rust_crates/vendor/http/Cargo.toml
@@ -3,7 +3,7 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
-# to registry (e.g. crates.io) dependencies
+# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
@@ -12,10 +12,9 @@
[package]
name = "http"
-version = "0.1.15"
+version = "0.1.19"
authors = ["Alex Crichton <alex@alexcrichton.com>", "Carl Lerche <me@carllerche.com>", "Sean McArthur <sean@seanmonstar.com>"]
description = "A set of types for representing HTTP requests and responses.\n"
-homepage = "https://github.com/hyperium/http"
documentation = "https://docs.rs/http"
readme = "README.md"
keywords = ["http"]
@@ -28,6 +27,10 @@
path = "benches/header_map/mod.rs"
[[bench]]
+name = "header_name"
+path = "benches/header_name.rs"
+
+[[bench]]
name = "header_value"
path = "benches/header_value.rs"
@@ -42,6 +45,9 @@
[dependencies.itoa]
version = "0.4.1"
+[dev-dependencies.doc-comment]
+version = "0.3"
+
[dev-dependencies.indexmap]
version = "1.0"
diff --git a/third_party/rust_crates/vendor/http/benches/header_name.rs b/third_party/rust_crates/vendor/http/benches/header_name.rs
new file mode 100644
index 0000000..d65f7d9
--- /dev/null
+++ b/third_party/rust_crates/vendor/http/benches/header_name.rs
@@ -0,0 +1,157 @@
+#![feature(test)]
+
+extern crate bytes;
+extern crate http;
+extern crate test;
+
+use http::header::HeaderName;
+use test::Bencher;
+
+fn make_all_known_headers() -> Vec<Vec<u8>> {
+ // Standard request headers
+ vec![b"A-IM".to_vec(),
+ b"Accept".to_vec(),
+ b"Accept-Charset".to_vec(),
+ b"Accept-Datetime".to_vec(),
+ b"Accept-Encoding".to_vec(),
+ b"Accept-Language".to_vec(),
+ b"Access-Control-Request-Method".to_vec(),
+ b"Authorization".to_vec(),
+ b"Cache-Control".to_vec(),
+ b"Connection".to_vec(),
+ b"Permanent".to_vec(),
+ b"Content-Length".to_vec(),
+ b"Content-MD5".to_vec(),
+ b"Content-Type".to_vec(),
+ b"Cookie".to_vec(),
+ b"Date".to_vec(),
+ b"Expect".to_vec(),
+ b"Forwarded".to_vec(),
+ b"From".to_vec(),
+ b"Host".to_vec(),
+ b"Permanent".to_vec(),
+ b"HTTP2-Settings".to_vec(),
+ b"If-Match".to_vec(),
+ b"If-Modified-Since".to_vec(),
+ b"If-None-Match".to_vec(),
+ b"If-Range".to_vec(),
+ b"If-Unmodified-Since".to_vec(),
+ b"Max-Forwards".to_vec(),
+ b"Origin".to_vec(),
+ b"Pragma".to_vec(),
+ b"Proxy-Authorization".to_vec(),
+ b"Range".to_vec(),
+ b"Referer".to_vec(),
+ b"TE".to_vec(),
+ b"User-Agent".to_vec(),
+ b"Upgrade".to_vec(),
+ b"Via".to_vec(),
+ b"Warning".to_vec(),
+ // common_non_standard
+ b"Upgrade-Insecure-Requests".to_vec(),
+ b"Upgrade-Insecure-Requests".to_vec(),
+ b"X-Requested-With".to_vec(),
+ b"DNT".to_vec(),
+ b"X-Forwarded-For".to_vec(),
+ b"X-Forwarded-Host".to_vec(),
+ b"X-Forwarded-Proto".to_vec(),
+ b"Front-End-Https".to_vec(),
+ b"X-Http-Method-Override".to_vec(),
+ b"X-ATT-DeviceId".to_vec(),
+ b"X-Wap-Profile".to_vec(),
+ b"Proxy-Connection".to_vec(),
+ b"X-UIDH".to_vec(),
+ b"X-Csrf-Token".to_vec(),
+ b"X-Request-ID".to_vec(),
+ b"X-Correlation-ID".to_vec(),
+ b"Save-Data".to_vec(),
+ // standard_response_headers
+ b"Accept-Patch".to_vec(),
+ b"Accept-Ranges".to_vec(),
+ b"Access-Control-Allow-Credentials".to_vec(),
+ b"Access-Control-Allow-Headers".to_vec(),
+ b"Access-Control-Allow-Methods".to_vec(),
+ b"Access-Control-Allow-Origin".to_vec(),
+ b"Access-Control-Expose-Headers".to_vec(),
+ b"Access-Control-Max-Age".to_vec(),
+ b"Age".to_vec(),
+ b"Allow".to_vec(),
+ b"Alt-Svc".to_vec(),
+ b"Cache-Control".to_vec(),
+ b"Connection".to_vec(),
+ b"Content-Disposition".to_vec(),
+ b"Content-Encoding".to_vec(),
+ b"Content-Language".to_vec(),
+ b"Content-Length".to_vec(),
+ b"Content-Location".to_vec(),
+ b"Content-MD5".to_vec(),
+ b"Content-Range".to_vec(),
+ b"Content-Type".to_vec(),
+ b"Date".to_vec(),
+ b"Delta-Base".to_vec(),
+ b"ETag".to_vec(),
+ b"Expires".to_vec(),
+ b"IM".to_vec(),
+ b"Last-Modified".to_vec(),
+ b"Link".to_vec(),
+ b"Location".to_vec(),
+ b"P3P".to_vec(),
+ b"Permanent".to_vec(),
+ b"Pragma".to_vec(),
+ b"Proxy-Authenticate".to_vec(),
+ b"Public-Key-Pins".to_vec(),
+ b"Retry-After".to_vec(),
+ b"Server".to_vec(),
+ b"Set-Cookie".to_vec(),
+ b"Strict-Transport-Security".to_vec(),
+ b"Tk".to_vec(),
+ b"Trailer".to_vec(),
+ b"Transfer-Encoding".to_vec(),
+ b"Upgrade".to_vec(),
+ b"Vary".to_vec(),
+ b"Via".to_vec(),
+ b"Warning".to_vec(),
+ b"WWW-Authenticate".to_vec(),
+ b"X-Frame-Options".to_vec(),
+ // common_non_standard_response
+ b"Content-Security-Policy".to_vec(),
+ b"Refresh".to_vec(),
+ b"Status".to_vec(),
+ b"Timing-Allow-Origin".to_vec(),
+ b"X-Content-Duration".to_vec(),
+ b"X-Content-Security-Policy".to_vec(),
+ b"X-Content-Type-Options".to_vec(),
+ b"X-Correlation-ID".to_vec(),
+ b"X-Powered-By".to_vec(),
+ b"X-Request-ID".to_vec(),
+ b"X-UA-Compatible".to_vec(),
+ b"X-WebKit-CSP".to_vec(),
+ b"X-XSS-Protection".to_vec(),
+ ]
+}
+
+#[bench]
+fn header_name_easy(b: &mut Bencher) {
+ let name = b"Content-type";
+ b.iter(|| {
+ HeaderName::from_bytes(&name[..]).unwrap();
+ });
+}
+
+#[bench]
+fn header_name_bad(b: &mut Bencher) {
+ let name = b"bad header name";
+ b.iter(|| {
+ HeaderName::from_bytes(&name[..]).expect_err("Bad header name");
+ });
+}
+
+#[bench]
+fn header_name_various(b: &mut Bencher) {
+ let all_known_headers = make_all_known_headers();
+ b.iter(|| {
+ for name in &all_known_headers{
+ HeaderName::from_bytes(name.as_slice()).unwrap();
+ }
+ });
+}
diff --git a/third_party/rust_crates/vendor/http/benches/header_value.rs b/third_party/rust_crates/vendor/http/benches/header_value.rs
index d9d2055..aea0b20 100644
--- a/third_party/rust_crates/vendor/http/benches/header_value.rs
+++ b/third_party/rust_crates/vendor/http/benches/header_value.rs
@@ -5,7 +5,7 @@
extern crate test;
use bytes::Bytes;
-use http::header::HeaderValue;
+use http::HeaderValue;
use test::Bencher;
static SHORT: &'static [u8] = b"localhost";
diff --git a/third_party/rust_crates/vendor/http/src/convert.rs b/third_party/rust_crates/vendor/http/src/convert.rs
index 7f61c8c..4d937a6 100644
--- a/third_party/rust_crates/vendor/http/src/convert.rs
+++ b/third_party/rust_crates/vendor/http/src/convert.rs
@@ -1,5 +1,5 @@
use Error;
-use header::{HeaderName, HeaderValue};
+use header::{HeaderName, HeaderValue, HeaderMap};
use method::Method;
use sealed::Sealed;
use status::StatusCode;
@@ -62,3 +62,15 @@
Authority,
PathAndQuery,
}
+
+// HeaderMap<T> can't use reflexive easily due to the generic T
+
+impl<T> HttpTryFrom<HeaderMap<T>> for HeaderMap<T> {
+ type Error = Error;
+
+ fn try_from(t: Self) -> Result<Self, Self::Error> {
+ Ok(t)
+ }
+}
+
+impl<T> Sealed for HeaderMap<T> {}
diff --git a/third_party/rust_crates/vendor/http/src/error.rs b/third_party/rust_crates/vendor/http/src/error.rs
index 8834059..641c398 100644
--- a/third_party/rust_crates/vendor/http/src/error.rs
+++ b/third_party/rust_crates/vendor/http/src/error.rs
@@ -13,7 +13,6 @@
/// functions in this crate, but all other errors can be converted to this
/// error. Consumers of this crate can typically consume and work with this form
/// of error for conversions with the `?` operator.
-#[derive(Debug)]
pub struct Error {
inner: ErrorKind,
}
@@ -21,7 +20,6 @@
/// A `Result` typedef to use with the `http::Error` type
pub type Result<T> = result::Result<T, Error>;
-#[derive(Debug)]
enum ErrorKind {
StatusCode(status::InvalidStatusCode),
Method(method::InvalidMethod),
@@ -34,9 +32,43 @@
HeaderValueShared(header::InvalidHeaderValueBytes),
}
+impl fmt::Debug for Error {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_tuple("http::Error")
+ // Skip the noise of the ErrorKind enum
+ .field(&self.get_ref())
+ .finish()
+ }
+}
+
impl fmt::Display for Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- error::Error::description(self).fmt(f)
+ fmt::Display::fmt(self.get_ref(), f)
+ }
+}
+
+impl Error {
+ /// Return true if the underlying error has the same type as T.
+ pub fn is<T: error::Error + 'static>(&self) -> bool {
+ self.get_ref().is::<T>()
+ }
+
+ /// Return a reference to the lower level, inner error.
+ #[allow(warnings)]
+ pub fn get_ref(&self) -> &(error::Error + 'static) {
+ use self::ErrorKind::*;
+
+ match self.inner {
+ StatusCode(ref e) => e,
+ Method(ref e) => e,
+ Uri(ref e) => e,
+ UriShared(ref e) => e,
+ UriParts(ref e) => e,
+ HeaderName(ref e) => e,
+ HeaderNameShared(ref e) => e,
+ HeaderValue(ref e) => e,
+ HeaderValueShared(ref e) => e,
+ }
}
}
@@ -56,6 +88,13 @@
HeaderValueShared(ref e) => e.description(),
}
}
+
+ // Return any available cause from the inner error. Note the inner error is
+ // not itself the cause.
+ #[allow(warnings)]
+ fn cause(&self) -> Option<&error::Error> {
+ self.get_ref().cause()
+ }
}
impl From<status::InvalidStatusCode> for Error {
@@ -142,3 +181,23 @@
}
}
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn inner_error_is_invalid_status_code() {
+ if let Err(e) = status::StatusCode::from_u16(6666) {
+ let err: Error = e.into();
+ let ie = err.get_ref();
+ assert!(!ie.is::<header::InvalidHeaderValue>());
+ assert!( ie.is::<status::InvalidStatusCode>());
+ ie.downcast_ref::<status::InvalidStatusCode>().unwrap();
+
+ assert!(!err.is::<header::InvalidHeaderValue>());
+ assert!( err.is::<status::InvalidStatusCode>());
+ } else {
+ panic!("Bad status allowed!");
+ }
+ }
+}
diff --git a/third_party/rust_crates/vendor/http/src/extensions.rs b/third_party/rust_crates/vendor/http/src/extensions.rs
index 6cbf1e3..e8f928f 100644
--- a/third_party/rust_crates/vendor/http/src/extensions.rs
+++ b/third_party/rust_crates/vendor/http/src/extensions.rs
@@ -3,6 +3,8 @@
use std::hash::{BuildHasherDefault, Hasher};
use std::fmt;
+// `Box<Any>` is now `Box<dyn Any>`, but we can't change yet (minimum Rust)
+#[allow(warnings)]
type AnyMap = HashMap<TypeId, Box<Any + Send + Sync>, BuildHasherDefault<IdHasher>>;
// With TypeIds as keys, there's no need to hash them. They are already hashes
@@ -69,11 +71,13 @@
.get_or_insert_with(|| Box::new(HashMap::default()))
.insert(TypeId::of::<T>(), Box::new(val))
.and_then(|boxed| {
- //TODO: we can use unsafe and remove double checking the type id
+ #[allow(warnings)]
+ {
(boxed as Box<Any + 'static>)
.downcast()
.ok()
.map(|boxed| *boxed)
+ }
})
}
@@ -94,8 +98,12 @@
.map
.as_ref()
.and_then(|map| map.get(&TypeId::of::<T>()))
- //TODO: we can use unsafe and remove double checking the type id
- .and_then(|boxed| (&**boxed as &(Any + 'static)).downcast_ref())
+ .and_then(|boxed| {
+ #[allow(warnings)]
+ {
+ (&**boxed as &(Any + 'static)).downcast_ref()
+ }
+ })
}
/// Get a mutable reference to a type previously inserted on this `Extensions`.
@@ -115,8 +123,12 @@
.map
.as_mut()
.and_then(|map| map.get_mut(&TypeId::of::<T>()))
- //TODO: we can use unsafe and remove double checking the type id
- .and_then(|boxed| (&mut **boxed as &mut (Any + 'static)).downcast_mut())
+ .and_then(|boxed| {
+ #[allow(warnings)]
+ {
+ (&mut **boxed as &mut (Any + 'static)).downcast_mut()
+ }
+ })
}
@@ -139,11 +151,13 @@
.as_mut()
.and_then(|map| map.remove(&TypeId::of::<T>()))
.and_then(|boxed| {
- //TODO: we can use unsafe and remove double checking the type id
+ #[allow(warnings)]
+ {
(boxed as Box<Any + 'static>)
.downcast()
.ok()
.map(|boxed| *boxed)
+ }
})
}
diff --git a/third_party/rust_crates/vendor/http/src/header/map.rs b/third_party/rust_crates/vendor/http/src/header/map.rs
index 7264198..4462d37 100644
--- a/third_party/rust_crates/vendor/http/src/header/map.rs
+++ b/third_party/rust_crates/vendor/http/src/header/map.rs
@@ -1,18 +1,24 @@
-use super::HeaderValue;
-use super::name::{HeaderName, HdrName, InvalidHeaderName};
-
use std::{fmt, mem, ops, ptr, vec};
use std::collections::hash_map::RandomState;
-use std::hash::{BuildHasher, Hasher, Hash};
+use std::collections::HashMap;
+use std::hash::{BuildHasher, Hash, Hasher};
use std::iter::FromIterator;
use std::marker::PhantomData;
+use convert::{HttpTryFrom, HttpTryInto};
+use Error;
+
+use super::HeaderValue;
+use super::name::{HdrName, HeaderName, InvalidHeaderName};
+
pub use self::as_header_name::AsHeaderName;
pub use self::into_header_name::IntoHeaderName;
/// A set of HTTP headers
///
-/// `HeaderMap` is an multimap of `HeaderName` to values.
+/// `HeaderMap` is an multimap of [`HeaderName`] to values.
+///
+/// [`HeaderName`]: struct.HeaderName.html
///
/// # Examples
///
@@ -657,6 +663,12 @@
pub fn get<K>(&self, key: K) -> Option<&T>
where K: AsHeaderName
{
+ self.get2(&key)
+ }
+
+ fn get2<K>(&self, key: &K) -> Option<&T>
+ where K: AsHeaderName
+ {
match key.find(self) {
Some((_, found)) => {
let entry = &self.entries[found];
@@ -1712,6 +1724,39 @@
}
}
+/// Try to convert a `HashMap` into a `HeaderMap`.
+///
+/// # Examples
+///
+/// ```
+/// use std::collections::HashMap;
+/// use http::{HttpTryFrom, header::HeaderMap};
+///
+/// let mut map = HashMap::new();
+/// map.insert("X-Custom-Header".to_string(), "my value".to_string());
+///
+/// let headers: HeaderMap = HttpTryFrom::try_from(&map).expect("valid headers");
+/// assert_eq!(headers["X-Custom-Header"], "my value");
+/// ```
+impl<'a, K, V, T> HttpTryFrom<&'a HashMap<K, V>> for HeaderMap<T>
+ where
+ K: Eq + Hash,
+ HeaderName: HttpTryFrom<&'a K>,
+ T: HttpTryFrom<&'a V>
+{
+ type Error = Error;
+
+ fn try_from(c: &'a HashMap<K, V>) -> Result<Self, Self::Error> {
+ c.into_iter()
+ .map(|(k, v)| {
+ let name = k.http_try_into()?;
+ let value = v.http_try_into()?;
+ Ok((name, value))
+ })
+ .collect()
+ }
+}
+
impl<T> Extend<(Option<HeaderName>, T)> for HeaderMap<T> {
/// Extend a `HeaderMap` with the contents of another `HeaderMap`.
///
@@ -1854,7 +1899,10 @@
/// Using the index operator will cause a panic if the header you're querying isn't set.
#[inline]
fn index(&self, index: K) -> &T {
- self.get(index).expect("no entry found for key")
+ match self.get2(&index) {
+ Some(val) => val,
+ None => panic!("no entry found for key {:?}", index.as_str()),
+ }
}
}
@@ -3150,7 +3198,7 @@
use super::{Entry, HdrName, HeaderMap, HeaderName, InvalidHeaderName};
/// A marker trait used to identify values that can be used as search keys
- /// to a `HeaderMap`.
+ /// to a `HeaderMap`.
pub trait AsHeaderName: Sealed {}
// All methods are on this pub(super) trait, instead of `AsHeaderName`,
@@ -3167,6 +3215,9 @@
#[doc(hidden)]
fn find<T>(&self, map: &HeaderMap<T>) -> Option<(usize, usize)>;
+
+ #[doc(hidden)]
+ fn as_str(&self) -> &str;
}
// ==== impls ====
@@ -3183,6 +3234,11 @@
fn find<T>(&self, map: &HeaderMap<T>) -> Option<(usize, usize)> {
map.find(self)
}
+
+ #[doc(hidden)]
+ fn as_str(&self) -> &str {
+ <HeaderName>::as_str(self)
+ }
}
impl AsHeaderName for HeaderName {}
@@ -3199,6 +3255,11 @@
fn find<T>(&self, map: &HeaderMap<T>) -> Option<(usize, usize)> {
map.find(*self)
}
+
+ #[doc(hidden)]
+ fn as_str(&self) -> &str {
+ <HeaderName>::as_str(*self)
+ }
}
impl<'a> AsHeaderName for &'a HeaderName {}
@@ -3215,6 +3276,11 @@
fn find<T>(&self, map: &HeaderMap<T>) -> Option<(usize, usize)> {
HdrName::from_bytes(self.as_bytes(), move |hdr| map.find(&hdr)).unwrap_or(None)
}
+
+ #[doc(hidden)]
+ fn as_str(&self) -> &str {
+ self
+ }
}
impl<'a> AsHeaderName for &'a str {}
@@ -3231,6 +3297,11 @@
fn find<T>(&self, map: &HeaderMap<T>) -> Option<(usize, usize)> {
Sealed::find(&self.as_str(), map)
}
+
+ #[doc(hidden)]
+ fn as_str(&self) -> &str {
+ self
+ }
}
impl AsHeaderName for String {}
@@ -3247,6 +3318,11 @@
fn find<T>(&self, map: &HeaderMap<T>) -> Option<(usize, usize)> {
Sealed::find(*self, map)
}
+
+ #[doc(hidden)]
+ fn as_str(&self) -> &str {
+ *self
+ }
}
impl<'a> AsHeaderName for &'a String {}
diff --git a/third_party/rust_crates/vendor/http/src/header/name.rs b/third_party/rust_crates/vendor/http/src/header/name.rs
index 5497867..df4d2a88 100644
--- a/third_party/rust_crates/vendor/http/src/header/name.rs
+++ b/third_party/rust_crates/vendor/http/src/header/name.rs
@@ -56,7 +56,6 @@
}
/// A possible error when converting a `HeaderName` from another type.
-#[derive(Debug)]
pub struct InvalidHeaderName {
_priv: (),
}
@@ -1043,18 +1042,26 @@
0, 0, 0, 0, 0, 0 // 25x
];
+#[cfg(any(not(debug_assertions), not(target_arch = "wasm32")))]
macro_rules! eq {
- ($v:ident[$n:expr] == $a:tt) => {
- $v[$n] == $a
+ (($($cmp:expr,)*) $v:ident[$n:expr] ==) => {
+ $($cmp) && *
};
- ($v:ident[$n:expr] == $a:tt $($rest:tt)+) => {
- $v[$n] == $a && eq!($v[($n+1)] == $($rest)+)
+ (($($cmp:expr,)*) $v:ident[$n:expr] == $a:tt $($rest:tt)*) => {
+ eq!(($($cmp,)* $v[$n] == $a,) $v[$n+1] == $($rest)*)
};
- ($v:ident == $a:tt $($rest:tt)*) => {
- $v[0] == $a && eq!($v[1] == $($rest)*)
+ ($v:ident == $($rest:tt)+) => {
+ eq!(() $v[0] == $($rest)+)
+ };
+ ($v:ident[$n:expr] == $($rest:tt)+) => {
+ eq!(() $v[$n] == $($rest)+)
};
}
+#[cfg(any(not(debug_assertions), not(target_arch = "wasm32")))]
+/// This version is best under optimized mode, however in a wasm debug compile,
+/// the `eq` macro expands to 1 + 1 + 1 + 1... and wasm explodes when this chain gets too long
+/// See https://github.com/DenisKolodin/yew/issues/478
fn parse_hdr<'a>(data: &'a [u8], b: &'a mut [u8; 64], table: &[u8; 256])
-> Result<HdrName<'a>, InvalidHeaderName>
{
@@ -1517,6 +1524,128 @@
}
}
+#[cfg(all(debug_assertions, target_arch = "wasm32"))]
+/// This version works best in debug mode in wasm
+fn parse_hdr<'a>(
+ data: &'a [u8],
+ b: &'a mut [u8; 64],
+ table: &[u8; 256],
+) -> Result<HdrName<'a>, InvalidHeaderName> {
+ use self::StandardHeader::*;
+
+ let len = data.len();
+
+ let validate = |buf: &'a [u8], len: usize| {
+ let buf = &buf[..len];
+ if buf.iter().any(|&b| b == 0) {
+ Err(InvalidHeaderName::new())
+ } else {
+ Ok(HdrName::custom(buf, true))
+ }
+ };
+
+ assert!(
+ len < super::MAX_HEADER_NAME_LEN,
+ "header name too long -- max length is {}",
+ super::MAX_HEADER_NAME_LEN
+ );
+
+ match len {
+ 0 => Err(InvalidHeaderName::new()),
+ len if len > 64 => Ok(HdrName::custom(data, false)),
+ len => {
+ // Read from data into the buffer - transforming using `table` as we go
+ data.iter().zip(b.iter_mut()).for_each(|(index, out)| *out = table[*index as usize]);
+ match &b[0..len] {
+ b"te" => Ok(Te.into()),
+ b"age" => Ok(Age.into()),
+ b"via" => Ok(Via.into()),
+ b"dnt" => Ok(Dnt.into()),
+ b"date" => Ok(Date.into()),
+ b"etag" => Ok(Etag.into()),
+ b"from" => Ok(From.into()),
+ b"host" => Ok(Host.into()),
+ b"link" => Ok(Link.into()),
+ b"vary" => Ok(Vary.into()),
+ b"allow" => Ok(Allow.into()),
+ b"range" => Ok(Range.into()),
+ b"accept" => Ok(Accept.into()),
+ b"cookie" => Ok(Cookie.into()),
+ b"expect" => Ok(Expect.into()),
+ b"origin" => Ok(Origin.into()),
+ b"pragma" => Ok(Pragma.into()),
+ b"server" => Ok(Server.into()),
+ b"alt-svc" => Ok(AltSvc.into()),
+ b"expires" => Ok(Expires.into()),
+ b"referer" => Ok(Referer.into()),
+ b"refresh" => Ok(Refresh.into()),
+ b"trailer" => Ok(Trailer.into()),
+ b"upgrade" => Ok(Upgrade.into()),
+ b"warning" => Ok(Warning.into()),
+ b"if-match" => Ok(IfMatch.into()),
+ b"if-range" => Ok(IfRange.into()),
+ b"location" => Ok(Location.into()),
+ b"forwarded" => Ok(Forwarded.into()),
+ b"connection" => Ok(Connection.into()),
+ b"set-cookie" => Ok(SetCookie.into()),
+ b"user-agent" => Ok(UserAgent.into()),
+ b"retry-after" => Ok(RetryAfter.into()),
+ b"content-type" => Ok(ContentType.into()),
+ b"max-forwards" => Ok(MaxForwards.into()),
+ b"accept-ranges" => Ok(AcceptRanges.into()),
+ b"authorization" => Ok(Authorization.into()),
+ b"cache-control" => Ok(CacheControl.into()),
+ b"content-range" => Ok(ContentRange.into()),
+ b"if-none-match" => Ok(IfNoneMatch.into()),
+ b"last-modified" => Ok(LastModified.into()),
+ b"accept-charset" => Ok(AcceptCharset.into()),
+ b"content-length" => Ok(ContentLength.into()),
+ b"accept-encoding" => Ok(AcceptEncoding.into()),
+ b"accept-language" => Ok(AcceptLanguage.into()),
+ b"public-key-pins" => Ok(PublicKeyPins.into()),
+ b"x-frame-options" => Ok(XFrameOptions.into()),
+ b"referrer-policy" => Ok(ReferrerPolicy.into()),
+ b"content-language" => Ok(ContentLanguage.into()),
+ b"content-location" => Ok(ContentLocation.into()),
+ b"content-encoding" => Ok(ContentEncoding.into()),
+ b"www-authenticate" => Ok(WwwAuthenticate.into()),
+ b"x-xss-protection" => Ok(XXssProtection.into()),
+ b"transfer-encoding" => Ok(TransferEncoding.into()),
+ b"if-modified-since" => Ok(IfModifiedSince.into()),
+ b"sec-websocket-key" => Ok(SecWebSocketKey.into()),
+ b"proxy-authenticate" => Ok(ProxyAuthenticate.into()),
+ b"content-disposition" => Ok(ContentDisposition.into()),
+ b"if-unmodified-since" => Ok(IfUnmodifiedSince.into()),
+ b"proxy-authorization" => Ok(ProxyAuthorization.into()),
+ b"sec-websocket-accept" => Ok(SecWebSocketAccept.into()),
+ b"sec-websocket-version" => Ok(SecWebSocketVersion.into()),
+ b"access-control-max-age" => Ok(AccessControlMaxAge.into()),
+ b"x-content-type-options" => Ok(XContentTypeOptions.into()),
+ b"x-dns-prefetch-control" => Ok(XDnsPrefetchControl.into()),
+ b"sec-websocket-protocol" => Ok(SecWebSocketProtocol.into()),
+ b"content-security-policy" => Ok(ContentSecurityPolicy.into()),
+ b"sec-websocket-extensions" => Ok(SecWebSocketExtensions.into()),
+ b"strict-transport-security" => Ok(StrictTransportSecurity.into()),
+ b"upgrade-insecure-requests" => Ok(UpgradeInsecureRequests.into()),
+ b"access-control-allow-origin" => Ok(AccessControlAllowOrigin.into()),
+ b"public-key-pins-report-only" => Ok(PublicKeyPinsReportOnly.into()),
+ b"access-control-allow-headers" => Ok(AccessControlAllowHeaders.into()),
+ b"access-control-allow-methods" => Ok(AccessControlAllowMethods.into()),
+ b"access-control-expose-headers" => Ok(AccessControlExposeHeaders.into()),
+ b"access-control-request-method" => Ok(AccessControlRequestMethod.into()),
+ b"access-control-request-headers" => Ok(AccessControlRequestHeaders.into()),
+ b"access-control-allow-credentials" => Ok(AccessControlAllowCredentials.into()),
+ b"content-security-policy-report-only" => {
+ Ok(ContentSecurityPolicyReportOnly.into())
+ }
+ other => validate(other, len),
+ }
+ }
+ }
+}
+
+
+
impl<'a> From<StandardHeader> for HdrName<'a> {
fn from(hdr: StandardHeader) -> HdrName<'a> {
HdrName { inner: Repr::Standard(hdr) }
@@ -1527,6 +1656,7 @@
/// Converts a slice of bytes to an HTTP header name.
///
/// This function normalizes the input.
+ #[allow(deprecated)]
pub fn from_bytes(src: &[u8]) -> Result<HeaderName, InvalidHeaderName> {
let mut buf = unsafe { mem::uninitialized() };
match parse_hdr(src, &mut buf, &HEADER_CHARS)?.inner {
@@ -1575,6 +1705,7 @@
/// // Parsing a header that contains uppercase characters
/// assert!(HeaderName::from_lowercase(b"Content-Length").is_err());
/// ```
+ #[allow(deprecated)]
pub fn from_lowercase(src: &[u8]) -> Result<HeaderName, InvalidHeaderName> {
let mut buf = unsafe { mem::uninitialized() };
match parse_hdr(src, &mut buf, &HEADER_CHARS_H2)?.inner {
@@ -1633,6 +1764,7 @@
/// let a = HeaderName::from_static("foobar");
/// let b = HeaderName::from_static("FOOBAR"); // This line panics!
/// ```
+ #[allow(deprecated)]
pub fn from_static(src: &'static str) -> HeaderName {
let bytes = src.as_bytes();
let mut buf = unsafe { mem::uninitialized() };
@@ -1769,6 +1901,14 @@
}
}
+impl<'a> HttpTryFrom<&'a String> for HeaderName {
+ type Error = InvalidHeaderName;
+ #[inline]
+ fn try_from(s: &'a String) -> Result<Self, Self::Error> {
+ Self::from_bytes(s.as_bytes())
+ }
+}
+
impl<'a> HttpTryFrom<&'a [u8]> for HeaderName {
type Error = InvalidHeaderName;
#[inline]
@@ -1874,6 +2014,14 @@
}
}
+impl fmt::Debug for InvalidHeaderName {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_struct("InvalidHeaderName")
+ // skip _priv noise
+ .finish()
+ }
+}
+
impl fmt::Display for InvalidHeaderName {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
@@ -1910,6 +2058,7 @@
}
}
+ #[allow(deprecated)]
pub fn from_bytes<F, U>(hdr: &[u8], f: F) -> Result<U, InvalidHeaderName>
where F: FnOnce(HdrName) -> U,
{
@@ -1918,6 +2067,7 @@
Ok(f(hdr))
}
+ #[allow(deprecated)]
pub fn from_static<F, U>(hdr: &'static str, f: F) -> U
where F: FnOnce(HdrName) -> U,
{
diff --git a/third_party/rust_crates/vendor/http/src/header/value.rs b/third_party/rust_crates/vendor/http/src/header/value.rs
index a56baf7..25b0078 100644
--- a/third_party/rust_crates/vendor/http/src/header/value.rs
+++ b/third_party/rust_crates/vendor/http/src/header/value.rs
@@ -25,7 +25,6 @@
/// A possible error when converting a `HeaderValue` from a string or byte
/// slice.
-#[derive(Debug)]
pub struct InvalidHeaderValue {
_priv: (),
}
@@ -521,6 +520,14 @@
}
}
+impl<'a> HttpTryFrom<&'a String> for HeaderValue {
+ type Error = InvalidHeaderValue;
+ #[inline]
+ fn try_from(s: &'a String) -> Result<Self, Self::Error> {
+ Self::from_bytes(s.as_bytes())
+ }
+}
+
impl<'a> HttpTryFrom<&'a [u8]> for HeaderValue {
type Error = InvalidHeaderValue;
@@ -581,6 +588,14 @@
b >= 32 && b != 127 || b == b'\t'
}
+impl fmt::Debug for InvalidHeaderValue {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_struct("InvalidHeaderValue")
+ // skip _priv noise
+ .finish()
+ }
+}
+
impl fmt::Display for InvalidHeaderValue {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
self.description().fmt(f)
diff --git a/third_party/rust_crates/vendor/http/src/lib.rs b/third_party/rust_crates/vendor/http/src/lib.rs
index 788ec97..a7759e3 100644
--- a/third_party/rust_crates/vendor/http/src/lib.rs
+++ b/third_party/rust_crates/vendor/http/src/lib.rs
@@ -1,4 +1,4 @@
-#![doc(html_root_url = "https://docs.rs/http/0.1.15")]
+#![doc(html_root_url = "https://docs.rs/http/0.1.19")]
//! A general purpose library of common HTTP types
//!
@@ -55,8 +55,8 @@
//! to edit the request/response:
//!
//! ```
-//! use http::{Response, StatusCode};
-//! use http::header::{CONTENT_TYPE, HeaderValue};
+//! use http::{HeaderValue, Response, StatusCode};
+//! use http::header::CONTENT_TYPE;
//!
//! fn add_server_headers<T>(response: &mut Response<T>) {
//! response.headers_mut()
@@ -118,7 +118,7 @@
//! function:
//!
//! ```
-//! use http::header::HeaderValue;
+//! use http::HeaderValue;
//!
//! let value = HeaderValue::from_static("text/html");
//! assert_eq!(value.as_bytes(), b"text/html");
@@ -127,7 +127,7 @@
//! And header values can also be parsed like names:
//!
//! ```
-//! use http::header::HeaderValue;
+//! use http::HeaderValue;
//!
//! let value = "text/html";
//! let value = value.parse::<HeaderValue>().unwrap();
@@ -151,7 +151,7 @@
//!
//! let uri = "https://www.rust-lang.org/index.html".parse::<Uri>().unwrap();
//!
-//! assert_eq!(uri.scheme(), Some("https"));
+//! assert_eq!(uri.scheme_str(), Some("https"));
//! assert_eq!(uri.host(), Some("www.rust-lang.org"));
//! assert_eq!(uri.path(), "/index.html");
//! assert_eq!(uri.query(), None);
@@ -163,6 +163,13 @@
extern crate fnv;
extern crate itoa;
+#[cfg(test)]
+#[macro_use]
+extern crate doc_comment;
+
+#[cfg(test)]
+doctest!("../README.md");
+
pub mod header;
pub mod method;
pub mod request;
@@ -179,7 +186,8 @@
pub use convert::HttpTryFrom;
pub use error::{Error, Result};
pub use extensions::Extensions;
-pub use header::HeaderMap;
+#[doc(no_inline)]
+pub use header::{HeaderMap, HeaderValue};
pub use method::Method;
pub use request::Request;
pub use response::Response;
diff --git a/third_party/rust_crates/vendor/http/src/method.rs b/third_party/rust_crates/vendor/http/src/method.rs
index 7ba5ebf..702b08a 100644
--- a/third_party/rust_crates/vendor/http/src/method.rs
+++ b/third_party/rust_crates/vendor/http/src/method.rs
@@ -45,7 +45,6 @@
pub struct Method(Inner);
/// A possible error value when converting `Method` from bytes.
-#[derive(Debug)]
pub struct InvalidMethod {
_priv: (),
}
@@ -390,6 +389,14 @@
}
}
+impl fmt::Debug for InvalidMethod {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_struct("InvalidMethod")
+ // skip _priv noise
+ .finish()
+ }
+}
+
impl fmt::Display for InvalidMethod {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.description())
diff --git a/third_party/rust_crates/vendor/http/src/request.rs b/third_party/rust_crates/vendor/http/src/request.rs
index 2fc1163d..ac76470 100644
--- a/third_party/rust_crates/vendor/http/src/request.rs
+++ b/third_party/rust_crates/vendor/http/src/request.rs
@@ -565,7 +565,6 @@
&mut self.head.headers
}
-
/// Returns a reference to the associated extensions.
///
/// # Examples
@@ -940,6 +939,36 @@
}
}
+ /// Get header on this request builder.
+ /// when builder has error returns None
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # use http::*;
+ /// # use http::header::HeaderValue;
+ /// # use http::request::Builder;
+ /// let mut req = Request::builder();
+ /// {
+ /// let headers = req.headers_mut().unwrap();
+ /// headers.insert("Accept", HeaderValue::from_static("text/html"));
+ /// headers.insert("X-Custom-Foo", HeaderValue::from_static("bar"));
+ /// }
+ /// let headers = req.headers_ref().unwrap();
+ /// assert_eq!( headers["Accept"], "text/html" );
+ /// assert_eq!( headers["X-Custom-Foo"], "bar" );
+ /// ```
+ pub fn headers_mut(&mut self) -> Option<&mut HeaderMap<HeaderValue>> {
+ if self.err.is_some() {
+ return None;
+ }
+ match self.head
+ {
+ Some(ref mut head) => Some(&mut head.headers),
+ None => None
+ }
+ }
+
/// Adds an extension to this builder
///
/// # Examples
diff --git a/third_party/rust_crates/vendor/http/src/response.rs b/third_party/rust_crates/vendor/http/src/response.rs
index e628cf6..fc87750 100644
--- a/third_party/rust_crates/vendor/http/src/response.rs
+++ b/third_party/rust_crates/vendor/http/src/response.rs
@@ -630,6 +630,63 @@
self
}
+ /// Get header on this response builder.
+ /// when builder has error returns None
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # use http::*;
+ /// # use http::header::HeaderValue;
+ /// # use http::response::Builder;
+ /// let mut res = Response::builder();
+ /// res.header("Accept", "text/html")
+ /// .header("X-Custom-Foo", "bar");
+ /// let headers = res.headers_ref().unwrap();
+ /// assert_eq!( headers["Accept"], "text/html" );
+ /// assert_eq!( headers["X-Custom-Foo"], "bar" );
+ /// ```
+ pub fn headers_ref(&self) -> Option<&HeaderMap<HeaderValue>> {
+ if self.err.is_some() {
+ return None;
+ }
+ match self.head
+ {
+ Some(ref head) => Some(&head.headers),
+ None => None
+ }
+ }
+
+ /// Get header on this response builder.
+ /// when builder has error returns None
+ ///
+ /// # Example
+ ///
+ /// ```
+ /// # use http::*;
+ /// # use http::header::HeaderValue;
+ /// # use http::response::Builder;
+ /// let mut res = Response::builder();
+ /// {
+ /// let headers = res.headers_mut().unwrap();
+ /// headers.insert("Accept", HeaderValue::from_static("text/html"));
+ /// headers.insert("X-Custom-Foo", HeaderValue::from_static("bar"));
+ /// }
+ /// let headers = res.headers_ref().unwrap();
+ /// assert_eq!( headers["Accept"], "text/html" );
+ /// assert_eq!( headers["X-Custom-Foo"], "bar" );
+ /// ```
+ pub fn headers_mut(&mut self) -> Option<&mut HeaderMap<HeaderValue>> {
+ if self.err.is_some() {
+ return None;
+ }
+ match self.head
+ {
+ Some(ref mut head) => Some(&mut head.headers),
+ None => None
+ }
+ }
+
/// Adds an extension to this builder
///
/// # Examples
diff --git a/third_party/rust_crates/vendor/http/src/status.rs b/third_party/rust_crates/vendor/http/src/status.rs
index 162e8ce..ef95c90 100644
--- a/third_party/rust_crates/vendor/http/src/status.rs
+++ b/third_party/rust_crates/vendor/http/src/status.rs
@@ -46,7 +46,6 @@
///
/// This error indicates that the supplied input was not a valid number, was less
/// than 100, or was greater than 599.
-#[derive(Debug)]
pub struct InvalidStatusCode {
_priv: (),
}
@@ -284,14 +283,6 @@
}
}
-impl InvalidStatusCode {
- fn new() -> InvalidStatusCode {
- InvalidStatusCode {
- _priv: (),
- }
- }
-}
-
macro_rules! status_codes {
(
$(
@@ -512,6 +503,22 @@
(511, NETWORK_AUTHENTICATION_REQUIRED, "Network Authentication Required");
}
+impl InvalidStatusCode {
+ fn new() -> InvalidStatusCode {
+ InvalidStatusCode {
+ _priv: (),
+ }
+ }
+}
+
+impl fmt::Debug for InvalidStatusCode {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ f.debug_struct("InvalidStatusCode")
+ // skip _priv noise
+ .finish()
+ }
+}
+
impl fmt::Display for InvalidStatusCode {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str(self.description())
diff --git a/third_party/rust_crates/vendor/http/src/uri/authority.rs b/third_party/rust_crates/vendor/http/src/uri/authority.rs
index 724712c..0564f2b5 100644
--- a/third_party/rust_crates/vendor/http/src/uri/authority.rs
+++ b/third_party/rust_crates/vendor/http/src/uri/authority.rs
@@ -103,15 +103,20 @@
}
b':' => {
colon_cnt += 1;
- },
+ }
b'[' => {
start_bracket = true;
+ if has_percent {
+ // Something other than the userinfo has a `%`, so reject it.
+ return Err(ErrorKind::InvalidAuthority.into());
+ }
}
b']' => {
end_bracket = true;
// Those were part of an IPv6 hostname, so forget them...
colon_cnt = 0;
+ has_percent = false;
}
b'@' => {
at_sign_pos = Some(i);
@@ -127,8 +132,11 @@
// the userinfo can have a percent-encoded username and password,
// so record that a `%` was found. If this turns out to be
// part of the userinfo, this flag will be cleared.
+ // Also per https://tools.ietf.org/html/rfc6874, percent-encoding can
+ // be used to indicate a zone identifier.
// If the flag hasn't been cleared at the end, that means this
- // was part of the hostname, and will fail with an error.
+ // was part of the hostname (and not part of an IPv6 address), and
+ // will fail with an error.
has_percent = true;
}
0 => {
@@ -612,4 +620,20 @@
let err = Authority::parse_non_empty(b"a%2f:b%2f@example%2f.com").unwrap_err();
assert_eq!(err.0, ErrorKind::InvalidAuthority);
}
+
+ #[test]
+ fn allows_percent_in_ipv6_address() {
+ let authority_str = "[fe80::1:2:3:4%25eth0]";
+ let result: Authority = authority_str.parse().unwrap();
+ assert_eq!(result, authority_str);
+ }
+
+ #[test]
+ fn rejects_percent_outside_ipv6_address() {
+ let err = Authority::parse_non_empty(b"1234%20[fe80::1:2:3:4]").unwrap_err();
+ assert_eq!(err.0, ErrorKind::InvalidAuthority);
+
+ let err = Authority::parse_non_empty(b"[fe80::1:2:3:4]%20").unwrap_err();
+ assert_eq!(err.0, ErrorKind::InvalidAuthority);
+ }
}
diff --git a/third_party/rust_crates/vendor/http/src/uri/path.rs b/third_party/rust_crates/vendor/http/src/uri/path.rs
index 5013626..2cafbf89 100644
--- a/third_party/rust_crates/vendor/http/src/uri/path.rs
+++ b/third_party/rust_crates/vendor/http/src/uri/path.rs
@@ -5,7 +5,7 @@
use byte_str::ByteStr;
use convert::HttpTryFrom;
-use super::{ErrorKind, InvalidUri, InvalidUriBytes, URI_CHARS};
+use super::{ErrorKind, InvalidUri, InvalidUriBytes};
/// Represents the path component of a URI
#[derive(Clone)]
@@ -41,43 +41,76 @@
/// ```
pub fn from_shared(mut src: Bytes) -> Result<Self, InvalidUriBytes> {
let mut query = NONE;
+ let mut fragment = None;
- let mut i = 0;
+ // block for iterator borrow
+ //
+ // allow: `...` pattersn are now `..=`, but we cannot update yet
+ // because of minimum Rust version
+ #[allow(warnings)]
+ {
+ let mut iter = src.as_ref().iter().enumerate();
- while i < src.len() {
- let b = src[i];
+ // path ...
+ for (i, &b) in &mut iter {
+ // See https://url.spec.whatwg.org/#path-state
+ match b {
+ b'?' => {
+ debug_assert_eq!(query, NONE);
+ query = i as u16;
+ break;
+ }
+ b'#' => {
+ fragment = Some(i);
+ break;
+ },
- match URI_CHARS[b as usize] {
- 0 if b == b'%' => {}
- 0 if query != NONE => {
- // While queries *should* be percent-encoded, most
- // bytes are actually allowed...
- // See https://url.spec.whatwg.org/#query-state
- //
- // Allowed: 0x21 / 0x24 - 0x3B / 0x3D / 0x3F - 0x7E
+ // This is the range of bytes that don't need to be
+ // percent-encoded in the path. If it should have been
+ // percent-encoded, then error.
+ 0x21 |
+ 0x24...0x3B |
+ 0x3D |
+ 0x40...0x5F |
+ 0x61...0x7A |
+ 0x7C |
+ 0x7E => {},
+
+ _ => return Err(ErrorKind::InvalidUriChar.into()),
+ }
+ }
+
+ // query ...
+ if query != NONE {
+
+ // allow: `...` pattersn are now `..=`, but we cannot update yet
+ // because of minimum Rust version
+ #[allow(warnings)]
+ for (i, &b) in iter {
match b {
+ // While queries *should* be percent-encoded, most
+ // bytes are actually allowed...
+ // See https://url.spec.whatwg.org/#query-state
+ //
+ // Allowed: 0x21 / 0x24 - 0x3B / 0x3D / 0x3F - 0x7E
0x21 |
0x24...0x3B |
0x3D |
0x3F...0x7E => {},
+
+ b'#' => {
+ fragment = Some(i);
+ break;
+ },
+
_ => return Err(ErrorKind::InvalidUriChar.into()),
}
}
- 0 => return Err(ErrorKind::InvalidUriChar.into()),
- b'?' => {
- if query == NONE {
- query = i as u16;
- }
- }
- b'#' => {
- // TODO: truncate
- src.split_off(i);
- break;
- }
- _ => {}
}
+ }
- i += 1;
+ if let Some(i) = fragment {
+ src.truncate(i);
}
Ok(PathAndQuery {
diff --git a/third_party/rust_crates/vendor/http/src/uri/tests.rs b/third_party/rust_crates/vendor/http/src/uri/tests.rs
index 70f63a6..71f9351 100644
--- a/third_party/rust_crates/vendor/http/src/uri/tests.rs
+++ b/third_party/rust_crates/vendor/http/src/uri/tests.rs
@@ -27,7 +27,12 @@
#[test]
fn $test_name() {
let orig_str = $str;
- let uri = Uri::from_str(orig_str).unwrap();
+ let uri = match Uri::from_str(orig_str) {
+ Ok(uri) => uri,
+ Err(err) => {
+ panic!("parse error {:?} from {:?}", err, orig_str);
+ },
+ };
$(
assert_eq!(uri.$method(), $value, "{}: uri = {:?}", stringify!($method), uri);
)+
@@ -370,6 +375,14 @@
}
test_parse! {
+ test_path_permissive,
+ "/foo=bar|baz\\^~%",
+ [],
+
+ path = "/foo=bar|baz\\^~%",
+}
+
+test_parse! {
test_query_permissive,
"/?foo={bar|baz}\\^`",
[],
diff --git a/third_party/rust_crates/vendor/http/tests/header_map_fuzz.rs b/third_party/rust_crates/vendor/http/tests/header_map_fuzz.rs
index b3b6588..03318cdf 100644
--- a/third_party/rust_crates/vendor/http/tests/header_map_fuzz.rs
+++ b/third_party/rust_crates/vendor/http/tests/header_map_fuzz.rs
@@ -255,7 +255,7 @@
}
Action::Remove { name, val } => {
// Just to help track the state, load all associated values.
- map.get_all(&name).iter().collect::<Vec<_>>();
+ let _ = map.get_all(&name).iter().collect::<Vec<_>>();
let actual = map.remove(&name);
assert_eq!(actual, val);