Make `http` v0 usage more evident (#3711)

Also fixes IntelliJ lints

This PR is not intended to change any behavior. If you see me doing that
somewhere, then it's a mistake.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
This commit is contained in:
Zelda Hessler 2024-06-25 09:09:00 -05:00 committed by GitHub
parent 31a4b8e648
commit 21c6cc7e10
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
55 changed files with 727 additions and 482 deletions

View File

@ -149,7 +149,7 @@ dependencies = [
[[package]]
name = "aws-runtime"
version = "1.3.0"
version = "1.3.1"
dependencies = [
"arbitrary",
"aws-credential-types",
@ -166,7 +166,9 @@ dependencies = [
"fastrand",
"futures-util",
"http 0.2.12",
"http 1.1.0",
"http-body 0.4.6",
"http-body 1.0.0",
"percent-encoding",
"pin-project-lite",
"proptest",
@ -262,7 +264,7 @@ dependencies = [
[[package]]
name = "aws-smithy-http"
version = "0.60.8"
version = "0.60.9"
dependencies = [
"aws-smithy-runtime-api",
"aws-smithy-types",
@ -319,7 +321,7 @@ dependencies = [
[[package]]
name = "aws-smithy-runtime-api"
version = "1.7.0"
version = "1.7.1"
dependencies = [
"aws-smithy-async",
"aws-smithy-types",

View File

@ -90,7 +90,7 @@ dependencies = [
[[package]]
name = "aws-runtime"
version = "1.3.0"
version = "1.2.3"
dependencies = [
"aws-credential-types",
"aws-sigv4",
@ -172,7 +172,7 @@ dependencies = [
[[package]]
name = "aws-sigv4"
version = "1.2.3"
version = "1.2.2"
dependencies = [
"aws-credential-types",
"aws-smithy-http",
@ -249,7 +249,7 @@ dependencies = [
[[package]]
name = "aws-smithy-runtime"
version = "1.6.1"
version = "1.6.0"
dependencies = [
"aws-smithy-async",
"aws-smithy-http",
@ -322,21 +322,22 @@ dependencies = [
[[package]]
name = "aws-types"
version = "1.3.3"
version = "1.3.1"
dependencies = [
"aws-credential-types",
"aws-smithy-async",
"aws-smithy-runtime-api",
"aws-smithy-types",
"http 0.2.12",
"rustc_version",
"tracing",
]
[[package]]
name = "backtrace"
version = "0.3.73"
version = "0.3.72"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a"
checksum = "17c6a35df3749d2e8bb1b7b21a976d82b15548788d2735b9d82f329268f71a11"
dependencies = [
"addr2line",
"cc",
@ -467,6 +468,17 @@ dependencies = [
"subtle",
]
[[package]]
name = "displaydoc"
version = "0.2.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "487585f4d0c6655fe74905e2504d8ad6908e4db67f744eb140876906c2f3175d"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "either"
version = "1.12.0"
@ -682,9 +694,9 @@ dependencies = [
[[package]]
name = "httparse"
version = "1.9.4"
version = "1.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9"
checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904"
[[package]]
name = "httpdate"
@ -734,13 +746,133 @@ dependencies = [
]
[[package]]
name = "idna"
version = "0.5.0"
name = "icu_collections"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "634d9b1461af396cad843f47fdba5597a4f9e6ddd4bfb6ff5d85028c25cb12f6"
checksum = "db2fa452206ebee18c4b5c2274dbf1de17008e874b4dc4f0aea9d01ca79e4526"
dependencies = [
"unicode-bidi",
"unicode-normalization",
"displaydoc",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_locid"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "13acbb8371917fc971be86fc8057c41a64b521c184808a698c02acc242dbf637"
dependencies = [
"displaydoc",
"litemap",
"tinystr",
"writeable",
"zerovec",
]
[[package]]
name = "icu_locid_transform"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01d11ac35de8e40fdeda00d9e1e9d92525f3f9d887cdd7aa81d727596788b54e"
dependencies = [
"displaydoc",
"icu_locid",
"icu_locid_transform_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_locid_transform_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdc8ff3388f852bede6b579ad4e978ab004f139284d7b28715f773507b946f6e"
[[package]]
name = "icu_normalizer"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19ce3e0da2ec68599d193c93d088142efd7f9c5d6fc9b803774855747dc6a84f"
dependencies = [
"displaydoc",
"icu_collections",
"icu_normalizer_data",
"icu_properties",
"icu_provider",
"smallvec",
"utf16_iter",
"utf8_iter",
"write16",
"zerovec",
]
[[package]]
name = "icu_normalizer_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f8cafbf7aa791e9b22bec55a167906f9e1215fd475cd22adfcf660e03e989516"
[[package]]
name = "icu_properties"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f8ac670d7422d7f76b32e17a5db556510825b29ec9154f235977c9caba61036"
dependencies = [
"displaydoc",
"icu_collections",
"icu_locid_transform",
"icu_properties_data",
"icu_provider",
"tinystr",
"zerovec",
]
[[package]]
name = "icu_properties_data"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67a8effbc3dd3e4ba1afa8ad918d5684b8868b3b26500753effea8d2eed19569"
[[package]]
name = "icu_provider"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6ed421c8a8ef78d3e2dbc98a973be2f3770cb42b606e3ab18d6237c4dfde68d9"
dependencies = [
"displaydoc",
"icu_locid",
"icu_provider_macros",
"stable_deref_trait",
"tinystr",
"writeable",
"yoke",
"zerofrom",
"zerovec",
]
[[package]]
name = "icu_provider_macros"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1ec89e9337638ecdc08744df490b221a7399bf8d164eb52a665454e60e075ad6"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "idna"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4716a3a0933a1d01c2f72450e89596eb51dd34ef3c211ccd875acdf1f8fe47ed"
dependencies = [
"icu_normalizer",
"icu_properties",
"smallvec",
"utf8_iter",
]
[[package]]
@ -772,6 +904,12 @@ version = "0.2.155"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c"
[[package]]
name = "litemap"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "643cb0b8d4fcc284004d5fd0d67ccf61dfffadb7f75e1e71bc420f4688a3a704"
[[package]]
name = "lock_api"
version = "0.4.12"
@ -799,15 +937,15 @@ dependencies = [
[[package]]
name = "memchr"
version = "2.7.4"
version = "2.7.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d"
[[package]]
name = "miniz_oxide"
version = "0.7.4"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08"
checksum = "87dfd01fe195c66b572b37921ad8803d010623c0aca821bea2302239d155cdae"
dependencies = [
"adler",
]
@ -869,9 +1007,9 @@ dependencies = [
[[package]]
name = "object"
version = "0.36.0"
version = "0.35.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "576dfe1fc8f9df304abb159d767a29d0476f7750fbf8aa7ad07816004a207434"
checksum = "b8ec7ab813848ba4522158d5517a6093db1ded27575b070f4177b8d12b41db5e"
dependencies = [
"memchr",
]
@ -983,9 +1121,9 @@ dependencies = [
[[package]]
name = "proc-macro2"
version = "1.0.86"
version = "1.0.85"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77"
checksum = "22244ce15aa966053a896d1accb3a6e68469b97c7f33f284b99f0d576879fc23"
dependencies = [
"unicode-ident",
]
@ -1001,9 +1139,9 @@ dependencies = [
[[package]]
name = "redox_syscall"
version = "0.5.2"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c82cf8cff14456045f55ec4241383baeff27af886adb72ffb2162f99911de0fd"
checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e"
dependencies = [
"bitflags",
]
@ -1217,7 +1355,7 @@ checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.67",
"syn 2.0.66",
]
[[package]]
@ -1293,10 +1431,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
[[package]]
name = "subtle"
version = "2.6.0"
name = "stable_deref_trait"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d0208408ba0c3df17ed26eb06992cb1a1268d41b2c0e12e65203fbe3972cee5"
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
[[package]]
name = "subtle"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "81cdd64d312baedb58e21336b31bc043b77e01cc99033ce76ef539f78e965ebc"
[[package]]
name = "syn"
@ -1311,15 +1455,26 @@ dependencies = [
[[package]]
name = "syn"
version = "2.0.67"
version = "2.0.66"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff8655ed1d86f3af4ee3fd3263786bc14245ad17c4c7e85ba7187fb3ae028c90"
checksum = "c42f3f41a2de00b01c0aaad383c5a45241efc8b2d1eda5661812fda5f3cdcff5"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "synstructure"
version = "0.13.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8af7666ab7b6390ab78131fb5b0fce11d6b7a6951602017c35fa82800708971"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]
[[package]]
name = "thiserror"
version = "1.0.61"
@ -1337,7 +1492,7 @@ checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.67",
"syn 2.0.66",
]
[[package]]
@ -1381,20 +1536,15 @@ dependencies = [
]
[[package]]
name = "tinyvec"
version = "1.6.0"
name = "tinystr"
version = "0.7.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50"
checksum = "9117f5d4db391c1cf6927e7bea3db74b9a1c1add8f7eda9ffd5364f40f57b82f"
dependencies = [
"tinyvec_macros",
"displaydoc",
"zerovec",
]
[[package]]
name = "tinyvec_macros"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]]
name = "tokio"
version = "1.38.0"
@ -1422,7 +1572,7 @@ checksum = "5f5ae998a069d4b5aba8ee9dad856af7d520c3699e6159b185c2acd48155d39a"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.67",
"syn 2.0.66",
]
[[package]]
@ -1473,7 +1623,7 @@ checksum = "34704c8d6ebcbc939824180af020566b01a7c01f80641264eba0999f6c2b6be7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.67",
"syn 2.0.66",
]
[[package]]
@ -1546,7 +1696,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "04659ddb06c87d233c566112c1c9c5b9e98256d9af50ec3bc9c8327f873a7568"
dependencies = [
"quote",
"syn 2.0.67",
"syn 2.0.66",
]
[[package]]
@ -1561,27 +1711,12 @@ version = "1.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
[[package]]
name = "unicode-bidi"
version = "0.3.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75"
[[package]]
name = "unicode-ident"
version = "1.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
[[package]]
name = "unicode-normalization"
version = "0.1.23"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a56d1686db2308d901306f92a263857ef59ea39678a5458e7cb17f01415101f5"
dependencies = [
"tinyvec",
]
[[package]]
name = "untrusted"
version = "0.9.0"
@ -1590,9 +1725,9 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
[[package]]
name = "url"
version = "2.5.2"
version = "2.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c"
checksum = "f7c25da092f0a868cdf09e8674cd3b7ef3a7d92a24253e663a2fb85e2496de56"
dependencies = [
"form_urlencoded",
"idna",
@ -1605,6 +1740,18 @@ version = "2.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "daf8dba3b7eb870caf1ddeed7bc9d2a049f3cfdfae7cb521b087cc33ae4c49da"
[[package]]
name = "utf16_iter"
version = "1.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8232dd3cdaed5356e0f716d285e4b40b932ac434100fe9b7e0e8e935b9e6246"
[[package]]
name = "utf8_iter"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
[[package]]
name = "uuid"
version = "1.8.0"
@ -1811,6 +1958,18 @@ version = "0.52.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0"
[[package]]
name = "write16"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d1890f4022759daae28ed4fe62859b1236caebfc61ede2f63ed4e695f3f6d936"
[[package]]
name = "writeable"
version = "0.5.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e9df38ee2d2c3c5948ea468a8406ff0db0b29ae1ffde1bcf20ef305bcc95c51"
[[package]]
name = "xmlparser"
version = "0.13.6"
@ -1823,8 +1982,75 @@ version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
[[package]]
name = "yoke"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c5b1314b079b0930c31e3af543d8ee1757b1951ae1e1565ec704403a7240ca5"
dependencies = [
"serde",
"stable_deref_trait",
"yoke-derive",
"zerofrom",
]
[[package]]
name = "yoke-derive"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "28cc31741b18cb6f1d5ff12f5b7523e3d6eb0852bbbad19d73905511d9849b95"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
"synstructure",
]
[[package]]
name = "zerofrom"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "91ec111ce797d0e0784a1116d0ddcdbea84322cd79e5d5ad173daeba4f93ab55"
dependencies = [
"zerofrom-derive",
]
[[package]]
name = "zerofrom-derive"
version = "0.1.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0ea7b4a3637ea8669cedf0f1fd5c286a17f3de97b8dd5a70a6c167a1730e63a5"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
"synstructure",
]
[[package]]
name = "zeroize"
version = "1.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
[[package]]
name = "zerovec"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bb2cc8827d6c0994478a15c53f374f46fbd41bea663d809b14744bc42e6b109c"
dependencies = [
"yoke",
"zerofrom",
"zerovec-derive",
]
[[package]]
name = "zerovec-derive"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "97cf56601ee5052b4417d90c8755c6683473c926039908196cf35d99f893ebe7"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.66",
]

View File

@ -1,6 +1,6 @@
[package]
name = "aws-runtime"
version = "1.3.0"
version = "1.3.1"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
description = "Runtime support code for the AWS SDK. This crate isn't intended to be used directly."
edition = "2021"
@ -10,6 +10,7 @@ repository = "https://github.com/smithy-lang/smithy-rs"
[features]
event-stream = ["dep:aws-smithy-eventstream", "aws-sigv4/sign-eventstream"]
http-02x = []
http-1x = ["dep:http-1x", "dep:http-body-1x"]
test-util = []
sigv4a = ["aws-sigv4/sigv4a"]
@ -25,8 +26,10 @@ aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types" }
aws-types = { path = "../aws-types" }
bytes = "1.1"
fastrand = "2.0.0"
http = "0.2.3"
http-body = "0.4.5"
http-02x = { package = "http", version = "0.2.3" }
http-body-04x = { package = "http-body", version = "0.4.5" }
http-1x = { package = "http", version = "1.1.0", optional = true }
http-body-1x = { package = "http-body", version = "1.0.0", optional = true }
percent-encoding = "2.1.0"
pin-project-lite = "0.2.9"
tracing = "0.1"

View File

@ -251,7 +251,7 @@ fn apply_signing_instructions(
) -> Result<(), BoxError> {
let (new_headers, new_query) = instructions.into_parts();
for header in new_headers.into_iter() {
let mut value = http::HeaderValue::from_str(header.value()).unwrap();
let mut value = http_02x::HeaderValue::from_str(header.value()).unwrap();
value.set_sensitive(header.sensitive());
request.headers_mut().insert(header.name(), value);
}

View File

@ -4,8 +4,8 @@
*/
use bytes::{Bytes, BytesMut};
use http::{HeaderMap, HeaderValue};
use http_body::{Body, SizeHint};
use http_02x::{HeaderMap, HeaderValue};
use http_body_04x::{Body, SizeHint};
use pin_project_lite::pin_project;
use std::pin::Pin;
@ -357,8 +357,8 @@ mod tests {
use aws_smithy_types::body::SdkBody;
use bytes::{Buf, Bytes};
use bytes_utils::SegmentedBuf;
use http::{HeaderMap, HeaderValue};
use http_body::{Body, SizeHint};
use http_02x::{HeaderMap, HeaderValue};
use http_body_04x::{Body, SizeHint};
use pin_project_lite::pin_project;
use std::io::Read;

View File

@ -7,7 +7,7 @@ use std::fmt::Debug;
use std::sync::{Arc, Mutex};
use fastrand::Rng;
use http::{HeaderName, HeaderValue};
use http_02x::{HeaderName, HeaderValue};
use aws_smithy_runtime_api::box_error::BoxError;
use aws_smithy_runtime_api::client::interceptors::context::BeforeTransmitInterceptorContextMut;

View File

@ -9,7 +9,7 @@ use aws_smithy_runtime_api::client::interceptors::Intercept;
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_types::config_bag::ConfigBag;
use aws_types::os_shim_internal::Env;
use http::HeaderValue;
use http_02x::HeaderValue;
use percent_encoding::{percent_encode, CONTROLS};
use std::borrow::Cow;
@ -83,7 +83,7 @@ mod tests {
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
use aws_smithy_types::body::SdkBody;
use aws_types::os_shim_internal::Env;
use http::HeaderValue;
use http_02x::HeaderValue;
use proptest::{prelude::*, proptest};
use serde::Deserialize;
use std::collections::HashMap;
@ -150,7 +150,7 @@ mod tests {
fn check(test_case: TestCase) {
let rc = RuntimeComponentsBuilder::for_tests().build().unwrap();
let env = test_case.env();
let mut request = http::Request::builder();
let mut request = http_02x::Request::builder();
for (name, value) in test_case.request_headers_before() {
request = request.header(name, value);
}

View File

@ -15,7 +15,7 @@ use aws_smithy_types::date_time::Format;
use aws_smithy_types::retry::RetryConfig;
use aws_smithy_types::timeout::TimeoutConfig;
use aws_smithy_types::DateTime;
use http::{HeaderName, HeaderValue};
use http_02x::{HeaderName, HeaderValue};
use std::borrow::Cow;
use std::time::Duration;
@ -188,7 +188,7 @@ mod tests {
use aws_smithy_types::retry::RetryConfig;
use aws_smithy_types::timeout::TimeoutConfig;
use http::HeaderValue;
use http_02x::HeaderValue;
use std::time::Duration;
fn expect_header<'a>(context: &'a InterceptorContext, header_name: &str) -> &'a str {

View File

@ -216,7 +216,7 @@ mod test {
fn classify_generic() {
let policy = AwsErrorCodeClassifier::<ErrorMetadata>::new();
let err = ErrorMetadata::builder().code("SlowDown").build();
let test_response = http::Response::new("OK").map(SdkBody::from);
let test_response = http_02x::Response::new("OK").map(SdkBody::from);
let mut ctx = InterceptorContext::new(Input::doesnt_matter());
ctx.set_response(test_response.try_into().unwrap());
@ -229,7 +229,7 @@ mod test {
fn test_retry_after_header() {
let policy = AwsErrorCodeClassifier::<ErrorMetadata>::new();
let err = ErrorMetadata::builder().code("SlowDown").build();
let res = http::Response::builder()
let res = http_02x::Response::builder()
.header("x-amz-retry-after", "5000")
.body("retry later")
.unwrap()

View File

@ -6,8 +6,7 @@
use std::borrow::Cow;
use std::fmt;
use http::header::{InvalidHeaderValue, USER_AGENT};
use http::{HeaderName, HeaderValue};
use http_02x::header::{HeaderName, HeaderValue, InvalidHeaderValue, USER_AGENT};
use aws_smithy_runtime_api::box_error::BoxError;
use aws_smithy_runtime_api::client::http::HttpClient;

130
rust-runtime/Cargo.lock generated
View File

@ -145,7 +145,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e16838e6c9e12125face1c1eff1343c75e3ff540de98ff7ebd61874a89bcfeb9"
dependencies = [
"aws-smithy-async 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"zeroize",
]
@ -202,8 +202,8 @@ dependencies = [
"aws-sigv4",
"aws-smithy-async 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-eventstream 0.60.4 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-types",
"bytes",
@ -229,10 +229,10 @@ dependencies = [
"aws-smithy-async 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-checksums 0.60.10",
"aws-smithy-eventstream 0.60.4 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8",
"aws-smithy-json 0.60.7 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime 1.5.5",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-xml 0.60.8 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-types",
@ -259,8 +259,8 @@ checksum = "31eed8d45759b2c5fe7fd304dd70739060e9e0de509209036eabea14d0720cce"
dependencies = [
"aws-credential-types",
"aws-smithy-eventstream 0.60.4 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes",
"crypto-bigint 0.5.5",
@ -308,7 +308,7 @@ version = "0.60.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c5b30ea96823b8b25fb6471643a516e1bd475fd5575304e6240aea179f213216"
dependencies = [
"aws-smithy-http 0.60.8 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes",
"crc32c",
@ -327,7 +327,7 @@ dependencies = [
name = "aws-smithy-checksums"
version = "0.60.11"
dependencies = [
"aws-smithy-http 0.60.8",
"aws-smithy-http 0.60.9",
"aws-smithy-types 1.2.0",
"bytes",
"bytes-utils",
@ -354,7 +354,7 @@ version = "0.60.3"
name = "aws-smithy-compression"
version = "0.0.1"
dependencies = [
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"bytes",
"bytes-utils",
@ -395,11 +395,11 @@ dependencies = [
[[package]]
name = "aws-smithy-experimental"
version = "0.1.2"
version = "0.1.3"
dependencies = [
"aws-smithy-async 1.2.1",
"aws-smithy-runtime 1.6.1",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"h2 0.4.5",
"http 1.1.0",
@ -417,10 +417,31 @@ dependencies = [
[[package]]
name = "aws-smithy-http"
version = "0.60.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08"
dependencies = [
"aws-smithy-eventstream 0.60.4 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes",
"bytes-utils",
"futures-core",
"http 0.2.12",
"http-body 0.4.6",
"once_cell",
"percent-encoding",
"pin-project-lite",
"pin-utils",
"tracing",
]
[[package]]
name = "aws-smithy-http"
version = "0.60.9"
dependencies = [
"async-stream",
"aws-smithy-eventstream 0.60.4",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"bytes",
"bytes-utils",
@ -438,27 +459,6 @@ dependencies = [
"tracing",
]
[[package]]
name = "aws-smithy-http"
version = "0.60.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a7de001a1b9a25601016d8057ea16e31a45fdca3751304c8edf4ad72e706c08"
dependencies = [
"aws-smithy-eventstream 0.60.4 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes",
"bytes-utils",
"futures-core",
"http 0.2.12",
"http-body 0.4.6",
"once_cell",
"percent-encoding",
"pin-project-lite",
"pin-utils",
"tracing",
]
[[package]]
name = "aws-smithy-http-auth"
version = "0.60.3"
@ -467,9 +467,9 @@ version = "0.60.3"
name = "aws-smithy-http-server"
version = "0.62.0"
dependencies = [
"aws-smithy-http 0.60.8",
"aws-smithy-http 0.60.9",
"aws-smithy-json 0.60.7",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"aws-smithy-xml 0.60.8",
"bytes",
@ -497,7 +497,7 @@ dependencies = [
name = "aws-smithy-http-server-python"
version = "0.62.1"
dependencies = [
"aws-smithy-http 0.60.8",
"aws-smithy-http 0.60.9",
"aws-smithy-http-server",
"aws-smithy-json 0.60.7",
"aws-smithy-types 1.2.0",
@ -559,7 +559,7 @@ name = "aws-smithy-mocks-experimental"
version = "0.2.1"
dependencies = [
"aws-sdk-s3",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"tokio",
]
@ -569,7 +569,7 @@ name = "aws-smithy-protocol-test"
version = "0.60.7"
dependencies = [
"assert-json-diff",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"http 0.2.12",
"pretty_assertions",
"regex-lite",
@ -585,7 +585,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31e8279cb24640c7349f2bda6ca818d5fcc85129386bd73c1d0999430d6ddf2"
dependencies = [
"assert-json-diff",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0",
"http 0.2.12",
"pretty_assertions",
"regex-lite",
@ -609,9 +609,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d0d3965f6417a92a6d1009c5958a67042f57e46342afb37ca58f9ad26744ec73"
dependencies = [
"aws-smithy-async 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-http 0.60.8",
"aws-smithy-protocol-test 0.60.7 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes",
"fastrand",
@ -639,9 +639,9 @@ version = "1.6.1"
dependencies = [
"approx",
"aws-smithy-async 1.2.1",
"aws-smithy-http 0.60.8",
"aws-smithy-http 0.60.9",
"aws-smithy-protocol-test 0.60.7",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"bytes",
"fastrand",
@ -668,22 +668,6 @@ dependencies = [
"tracing-test",
]
[[package]]
name = "aws-smithy-runtime-api"
version = "1.7.0"
dependencies = [
"aws-smithy-async 1.2.1",
"aws-smithy-types 1.2.0",
"bytes",
"http 0.2.12",
"http 1.1.0",
"pin-project-lite",
"proptest",
"tokio",
"tracing",
"zeroize",
]
[[package]]
name = "aws-smithy-runtime-api"
version = "1.7.0"
@ -701,6 +685,22 @@ dependencies = [
"zeroize",
]
[[package]]
name = "aws-smithy-runtime-api"
version = "1.7.1"
dependencies = [
"aws-smithy-async 1.2.1",
"aws-smithy-types 1.2.0",
"bytes",
"http 0.2.12",
"http 1.1.0",
"pin-project-lite",
"proptest",
"tokio",
"tracing",
"zeroize",
]
[[package]]
name = "aws-smithy-types"
version = "1.2.0"
@ -776,8 +776,8 @@ dependencies = [
name = "aws-smithy-wasm"
version = "0.1.3"
dependencies = [
"aws-smithy-http 0.60.8",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-http 0.60.9",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"bytes",
"http 1.1.0",
@ -812,7 +812,7 @@ checksum = "2009a9733865d0ebf428a314440bbe357cc10d0c16d86a8e15d32e9b47c1e80e"
dependencies = [
"aws-credential-types",
"aws-smithy-async 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-types 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc_version",
"tracing",
@ -1923,9 +1923,9 @@ name = "inlineable"
version = "0.1.0"
dependencies = [
"aws-smithy-compression",
"aws-smithy-http 0.60.8",
"aws-smithy-http 0.60.9",
"aws-smithy-json 0.60.7",
"aws-smithy-runtime-api 1.7.0",
"aws-smithy-runtime-api 1.7.1",
"aws-smithy-types 1.2.0",
"aws-smithy-xml 0.60.8",
"bytes",

View File

@ -1,6 +1,6 @@
[package]
name = "aws-smithy-experimental"
version = "0.1.2"
version = "0.1.3"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>"]
description = "Experiments for the smithy-rs ecosystem"
edition = "2021"

View File

@ -3,6 +3,12 @@
* SPDX-License-Identifier: Apache-2.0
*/
#![cfg(any(
feature = "crypto-ring",
feature = "crypto-aws-lc",
feature = "crypto-aws-lc-fips"
))]
use aws_smithy_async::time::SystemTimeSource;
use aws_smithy_experimental::hyper_1_0::{CryptoMode, HyperClientBuilder};
use aws_smithy_runtime_api::client::dns::{DnsFuture, ResolveDns, ResolveDnsError};
@ -77,6 +83,7 @@ async fn custom_dns_client() {
assert_eq!(resolver.count.load(Ordering::Relaxed), 1);
}
#[cfg(feature = "crypto-ring")]
async fn smoke_test_client(client: &dyn HttpClient) -> Result<(), Box<dyn Error>> {
let connector_settings = HttpConnectorSettings::builder().build();
let runtime_components = RuntimeComponentsBuilder::for_tests()

View File

@ -1,6 +1,6 @@
[package]
name = "aws-smithy-http"
version = "0.60.8"
version = "0.60.9"
authors = [
"AWS Rust SDK Team <aws-sdk-rust@amazon.com>",
"Russell Cohen <rcoh@amazon.com>",
@ -20,8 +20,8 @@ aws-smithy-runtime-api = { path = "../aws-smithy-runtime-api", features = ["clie
aws-smithy-types = { path = "../aws-smithy-types", features = ["byte-stream-poll-next", "http-body-0-4-x"] }
bytes = "1"
bytes-utils = "0.1"
http = "0.2.3"
http-body = "0.4.4"
http-02x = { package = "http", version = "0.2.3" }
http-body-04x = { package = "http-body", version = "0.4.4" }
once_cell = "1.10"
percent-encoding = "2.1.0"
pin-project-lite = "0.2.9"

View File

@ -8,7 +8,7 @@
#![allow(deprecated)]
use crate::endpoint::error::InvalidEndpointError;
use http::uri::{Authority, Uri};
use http_02x::uri::{Authority, Uri};
use std::borrow::Cow;
use std::result::Result as StdResult;
use std::str::FromStr;

View File

@ -12,7 +12,6 @@ use aws_smithy_types::event_stream::{Message, RawMessage};
use bytes::Buf;
use bytes::Bytes;
use bytes_utils::SegmentedBuf;
use http_body::Body;
use std::error::Error as StdError;
use std::fmt;
use std::marker::PhantomData;
@ -153,6 +152,8 @@ impl<T, E> Receiver<T, E> {
}
async fn buffer_next_chunk(&mut self) -> Result<(), SdkError<E, RawMessage>> {
use http_body_04x::Body;
if !self.buffer.is_eos() {
let next_chunk = self
.body

View File

@ -8,7 +8,7 @@
use aws_smithy_types::date_time::Format;
use aws_smithy_types::primitive::Parse;
use aws_smithy_types::DateTime;
use http::header::{HeaderMap, HeaderName, HeaderValue};
use http_02x::header::{HeaderMap, HeaderName, HeaderValue};
use std::borrow::Cow;
use std::convert::TryFrom;
use std::error::Error;
@ -152,13 +152,13 @@ where
/// Given an HTTP request, set a request header if that header was not already set.
pub fn set_request_header_if_absent<V>(
request: http::request::Builder,
request: http_02x::request::Builder,
key: HeaderName,
value: V,
) -> http::request::Builder
) -> http_02x::request::Builder
where
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<http::Error>,
<HeaderValue as TryFrom<V>>::Error: Into<http_02x::Error>,
{
if !request
.headers_ref()
@ -173,13 +173,13 @@ where
/// Given an HTTP response, set a response header if that header was not already set.
pub fn set_response_header_if_absent<V>(
response: http::response::Builder,
response: http_02x::response::Builder,
key: HeaderName,
value: V,
) -> http::response::Builder
) -> http_02x::response::Builder
where
HeaderValue: TryFrom<V>,
<HeaderValue as TryFrom<V>>::Error: Into<http::Error>,
<HeaderValue as TryFrom<V>>::Error: Into<http_02x::Error>,
{
if !response
.headers_ref()
@ -332,24 +332,21 @@ pub fn append_merge_header_maps(
#[cfg(test)]
mod test {
use std::collections::HashMap;
use aws_smithy_types::{date_time::Format, DateTime};
use http::header::{HeaderMap, HeaderName, HeaderValue};
use super::quote_header_value;
use crate::header::{
append_merge_header_maps, headers_for_prefix, many_dates, read_many_from_str,
read_many_primitive, set_request_header_if_absent, set_response_header_if_absent,
ParseError,
};
use super::quote_header_value;
use aws_smithy_runtime_api::http::Request;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_smithy_types::{date_time::Format, DateTime};
use http_02x::header::{HeaderMap, HeaderName, HeaderValue};
use std::collections::HashMap;
#[test]
fn put_on_request_if_absent() {
let builder = http::Request::builder().header("foo", "bar");
let builder = http_02x::Request::builder().header("foo", "bar");
let builder = set_request_header_if_absent(builder, HeaderName::from_static("foo"), "baz");
let builder =
set_request_header_if_absent(builder, HeaderName::from_static("other"), "value");
@ -366,7 +363,7 @@ mod test {
#[test]
fn put_on_response_if_absent() {
let builder = http::Response::builder().header("foo", "bar");
let builder = http_02x::Response::builder().header("foo", "bar");
let builder = set_response_header_if_absent(builder, HeaderName::from_static("foo"), "baz");
let builder =
set_response_header_if_absent(builder, HeaderName::from_static("other"), "value");
@ -387,7 +384,7 @@ mod test {
#[test]
fn parse_floats() {
let test_request = http::Request::builder()
let test_request = http_02x::Request::builder()
.header("X-Float-Multi", "0.0,Infinity,-Infinity,5555.5")
.header("X-Float-Error", "notafloat")
.body(())
@ -425,7 +422,7 @@ mod test {
#[test]
fn test_many_dates() {
let test_request = http::Request::builder()
let test_request = http_02x::Request::builder()
.header("Empty", "")
.header("SingleHttpDate", "Wed, 21 Oct 2015 07:28:00 GMT")
.header(
@ -477,7 +474,7 @@ mod test {
#[test]
fn read_many_strings() {
let test_request = http::Request::builder()
let test_request = http_02x::Request::builder()
.header("Empty", "")
.header("Foo", " foo")
.header("FooTrailing", "foo ")
@ -528,7 +525,7 @@ mod test {
#[test]
fn read_many_bools() {
let test_request = http::Request::builder()
let test_request = http_02x::Request::builder()
.header("X-Bool-Multi", "true,false")
.header("X-Bool-Multi", "true")
.header("X-Bool", "true")
@ -594,7 +591,7 @@ mod test {
#[test]
fn check_read_many_i16() {
let test_request = http::Request::builder()
let test_request = http_02x::Request::builder()
.header("X-Multi", "123,456")
.header("X-Multi", "789")
.header("X-Num", "777")
@ -661,7 +658,7 @@ mod test {
#[test]
fn test_prefix_headers() {
let test_request = Request::try_from(
http::Request::builder()
http_02x::Request::builder()
.header("X-Prefix-A", "123,456")
.header("X-Prefix-B", "789")
.header("X-Prefix-C", "777")

View File

@ -41,7 +41,7 @@ pub fn fmt_timestamp(t: &DateTime, format: Format) -> Result<String, DateTimeFor
#[cfg(test)]
mod test {
use crate::label::{fmt_string, EncodingStrategy};
use http::Uri;
use http_02x::Uri;
use proptest::proptest;
#[test]

View File

@ -65,7 +65,7 @@ impl<'a> Writer<'a> {
#[cfg(test)]
mod test {
use crate::query::{fmt_string, Writer};
use http::Uri;
use http_02x::Uri;
use proptest::proptest;
#[test]

View File

@ -4,8 +4,8 @@
*/
use crate::query::fmt_string as percent_encode_query;
use http::uri::InvalidUri;
use http::Uri;
use http_02x::uri::InvalidUri;
use http_02x::Uri;
/// Utility for updating the query string in a [`Uri`].
#[allow(missing_debug_implementations)]
@ -82,7 +82,7 @@ impl QueryWriter {
#[cfg(test)]
mod test {
use super::QueryWriter;
use http::Uri;
use http_02x::Uri;
#[test]
fn empty_uri() {

View File

@ -1,6 +1,6 @@
[package]
name = "aws-smithy-runtime-api"
version = "1.7.0"
version = "1.7.1"
authors = ["AWS Rust SDK Team <aws-sdk-rust@amazon.com>", "Zelda Hessler <zhessler@amazon.com>"]
description = "Smithy runtime types."
edition = "2021"
@ -21,8 +21,8 @@ http-1x = []
aws-smithy-async = { path = "../aws-smithy-async" }
aws-smithy-types = { path = "../aws-smithy-types" }
bytes = "1"
http = "0.2.9"
http1 = { package = "http", version = "1" }
http-02x = { package = "http", version = "0.2.9" }
http-1x = { package = "http", version = "1" }
pin-project-lite = "0.2"
tokio = { version = "1.25", features = ["sync"] }
tracing = "0.1"

View File

@ -12,7 +12,7 @@ use aws_smithy_types::config_bag::{Storable, StoreReplace};
use aws_smithy_types::endpoint::Endpoint;
use aws_smithy_types::type_erasure::TypeErasedBox;
use error::InvalidEndpointError;
use http::uri::Authority;
use http_02x::uri::Authority;
use std::fmt;
use std::str::FromStr;
use std::sync::Arc;

View File

@ -485,8 +485,8 @@ impl fmt::Display for RewindResult {
mod tests {
use super::*;
use aws_smithy_types::body::SdkBody;
use http::header::{AUTHORIZATION, CONTENT_LENGTH};
use http::{HeaderValue, Uri};
use http_02x::header::{AUTHORIZATION, CONTENT_LENGTH};
use http_02x::{HeaderValue, Uri};
#[test]
fn test_success_transitions() {
@ -508,7 +508,7 @@ mod tests {
context.enter_transmit_phase();
let _ = context.take_request();
context.set_response(
http::Response::builder()
http_02x::Response::builder()
.body(SdkBody::empty())
.unwrap()
.try_into()
@ -547,7 +547,7 @@ mod tests {
context.enter_serialization_phase();
let _ = context.take_input();
context.set_request(
http::Request::builder()
http_02x::Request::builder()
.header("test", "the-original-un-mutated-request")
.body(SdkBody::empty())
.unwrap()
@ -571,7 +571,7 @@ mod tests {
request.headers().get("test").unwrap()
);
context.set_response(
http::Response::builder()
http_02x::Response::builder()
.body(SdkBody::empty())
.unwrap()
.try_into()
@ -593,7 +593,7 @@ mod tests {
context.enter_transmit_phase();
let _ = context.take_request();
context.set_response(
http::Response::builder()
http_02x::Response::builder()
.body(SdkBody::empty())
.unwrap()
.try_into()
@ -612,7 +612,7 @@ mod tests {
#[test]
fn try_clone_clones_all_data() {
let request: HttpRequest = http::Request::builder()
let request: HttpRequest = http_02x::Request::builder()
.uri(Uri::from_static("https://www.amazon.com"))
.method("POST")
.header(CONTENT_LENGTH, 456)

View File

@ -309,7 +309,7 @@ mod tests {
use crate::shared::IntoShared;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::ConfigBag;
use http::HeaderValue;
use http_02x::HeaderValue;
use std::borrow::Cow;
#[derive(Debug)]
@ -389,7 +389,7 @@ mod tests {
impl HttpConnector for Connector1 {
fn call(&self, _: HttpRequest) -> HttpConnectorFuture {
HttpConnectorFuture::new(async {
Ok(http::Response::builder()
Ok(http_02x::Response::builder()
.status(200)
.header("rp1", "1")
.body(SdkBody::empty())

View File

@ -6,8 +6,8 @@
//! Error types for HTTP requests/responses.
use crate::box_error::BoxError;
use http::header::{InvalidHeaderName, InvalidHeaderValue};
use http::uri::InvalidUri;
use http_02x::header::{InvalidHeaderName, InvalidHeaderValue};
use http_02x::uri::InvalidUri;
use std::error::Error;
use std::fmt::{Debug, Display, Formatter};
use std::str::Utf8Error;

View File

@ -4,12 +4,11 @@
*/
use crate::http::HttpError;
use http as http0;
#[derive(Default, Debug)]
pub(crate) struct Extensions {
extensions_02x: http0::Extensions,
extensions_1x: http1::Extensions,
extensions_02x: http_02x::Extensions,
extensions_1x: http_1x::Extensions,
}
impl Extensions {
@ -24,8 +23,8 @@ impl Extensions {
}
}
impl From<http0::Extensions> for Extensions {
fn from(value: http0::Extensions) -> Self {
impl From<http_02x::Extensions> for Extensions {
fn from(value: http_02x::Extensions) -> Self {
Self {
extensions_02x: value,
extensions_1x: Default::default(),
@ -33,8 +32,8 @@ impl From<http0::Extensions> for Extensions {
}
}
impl From<http1::Extensions> for Extensions {
fn from(value: http1::Extensions) -> Self {
impl From<http_1x::Extensions> for Extensions {
fn from(value: http_1x::Extensions) -> Self {
Self {
extensions_02x: Default::default(),
extensions_1x: value,
@ -42,7 +41,7 @@ impl From<http1::Extensions> for Extensions {
}
}
impl TryFrom<Extensions> for http0::Extensions {
impl TryFrom<Extensions> for http_02x::Extensions {
type Error = HttpError;
fn try_from(value: Extensions) -> Result<Self, Self::Error> {
@ -54,7 +53,7 @@ impl TryFrom<Extensions> for http0::Extensions {
}
}
impl TryFrom<Extensions> for http1::Extensions {
impl TryFrom<Extensions> for http_1x::Extensions {
type Error = HttpError;
fn try_from(value: Extensions) -> Result<Self, Self::Error> {

View File

@ -6,9 +6,6 @@
//! Types for HTTP headers
use crate::http::error::HttpError;
use http as http0;
use http0::header::Iter;
use http0::HeaderMap;
use std::borrow::Cow;
use std::fmt::Debug;
use std::str::FromStr;
@ -16,7 +13,7 @@ use std::str::FromStr;
/// An immutable view of headers
#[derive(Clone, Default, Debug)]
pub struct Headers {
pub(super) headers: HeaderMap<HeaderValue>,
pub(super) headers: http_02x::HeaderMap<HeaderValue>,
}
impl<'a> IntoIterator for &'a Headers {
@ -32,7 +29,7 @@ impl<'a> IntoIterator for &'a Headers {
/// An Iterator over headers
pub struct HeadersIter<'a> {
inner: Iter<'a, HeaderValue>,
inner: http_02x::header::Iter<'a, HeaderValue>,
}
impl<'a> Iterator for HeadersIter<'a> {
@ -50,13 +47,13 @@ impl Headers {
}
#[cfg(feature = "http-1x")]
pub(crate) fn http1_headermap(self) -> http1::HeaderMap {
let mut headers = http1::HeaderMap::new();
pub(crate) fn http1_headermap(self) -> http_1x::HeaderMap {
let mut headers = http_1x::HeaderMap::new();
headers.reserve(self.headers.len());
headers.extend(self.headers.into_iter().map(|(k, v)| {
(
k.map(|n| {
http1::HeaderName::from_bytes(n.as_str().as_bytes()).expect("proven valid")
http_1x::HeaderName::from_bytes(n.as_str().as_bytes()).expect("proven valid")
}),
v.into_http1x(),
)
@ -65,8 +62,8 @@ impl Headers {
}
#[cfg(feature = "http-02x")]
pub(crate) fn http0_headermap(self) -> http0::HeaderMap {
let mut headers = http0::HeaderMap::new();
pub(crate) fn http0_headermap(self) -> http_02x::HeaderMap {
let mut headers = http_02x::HeaderMap::new();
headers.reserve(self.headers.len());
headers.extend(self.headers.into_iter().map(|(k, v)| (k, v.into_http02x())));
headers
@ -75,7 +72,7 @@ impl Headers {
/// Returns the value for a given key
///
/// If multiple values are associated, the first value is returned
/// See [HeaderMap::get]
/// See [HeaderMap::get](http_02x::HeaderMap::get)
pub fn get(&self, key: impl AsRef<str>) -> Option<&str> {
self.headers.get(key.as_ref()).map(|v| v.as_ref())
}
@ -180,10 +177,10 @@ impl Headers {
}
#[cfg(feature = "http-02x")]
impl TryFrom<HeaderMap> for Headers {
impl TryFrom<http_02x::HeaderMap> for Headers {
type Error = HttpError;
fn try_from(value: HeaderMap) -> Result<Self, Self::Error> {
fn try_from(value: http_02x::HeaderMap) -> Result<Self, Self::Error> {
if let Some(e) = value
.values()
.filter_map(|value| std::str::from_utf8(value.as_bytes()).err())
@ -191,7 +188,7 @@ impl TryFrom<HeaderMap> for Headers {
{
Err(HttpError::header_was_not_a_string(e))
} else {
let mut string_safe_headers: HeaderMap<HeaderValue> = Default::default();
let mut string_safe_headers: http_02x::HeaderMap<HeaderValue> = Default::default();
string_safe_headers.extend(
value
.into_iter()
@ -205,10 +202,10 @@ impl TryFrom<HeaderMap> for Headers {
}
#[cfg(feature = "http-1x")]
impl TryFrom<http1::HeaderMap> for Headers {
impl TryFrom<http_1x::HeaderMap> for Headers {
type Error = HttpError;
fn try_from(value: http1::HeaderMap) -> Result<Self, Self::Error> {
fn try_from(value: http_1x::HeaderMap) -> Result<Self, Self::Error> {
if let Some(e) = value
.values()
.filter_map(|value| std::str::from_utf8(value.as_bytes()).err())
@ -216,11 +213,12 @@ impl TryFrom<http1::HeaderMap> for Headers {
{
Err(HttpError::header_was_not_a_string(e))
} else {
let mut string_safe_headers: http0::HeaderMap<HeaderValue> = Default::default();
let mut string_safe_headers: http_02x::HeaderMap<HeaderValue> = Default::default();
string_safe_headers.extend(value.into_iter().map(|(k, v)| {
(
k.map(|v| {
http0::HeaderName::from_bytes(v.as_str().as_bytes()).expect("known valid")
http_02x::HeaderName::from_bytes(v.as_str().as_bytes())
.expect("known valid")
}),
HeaderValue::from_http1x(v).expect("validated above"),
)
@ -245,7 +243,7 @@ mod sealed {
fn as_str(&self) -> Result<&str, HttpError>;
/// If a component is already internally represented as a `http02x::HeaderName`, return it
fn repr_as_http02x_header_name(self) -> Result<http0::HeaderName, Self>
fn repr_as_http02x_header_name(self) -> Result<http_02x::HeaderName, Self>
where
Self: Sized,
{
@ -283,7 +281,7 @@ mod sealed {
}
}
impl AsHeaderComponent for http0::HeaderValue {
impl AsHeaderComponent for http_02x::HeaderValue {
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError> {
Ok(Cow::Owned(
std::str::from_utf8(self.as_bytes())
@ -297,7 +295,7 @@ mod sealed {
}
}
impl AsHeaderComponent for http0::HeaderName {
impl AsHeaderComponent for http_02x::HeaderName {
fn into_maybe_static(self) -> Result<MaybeStatic, HttpError> {
Ok(self.to_string().into())
}
@ -306,7 +304,7 @@ mod sealed {
Ok(self.as_ref())
}
fn repr_as_http02x_header_name(self) -> Result<http0::HeaderName, Self>
fn repr_as_http02x_header_name(self) -> Result<http_02x::HeaderName, Self>
where
Self: Sized,
{
@ -329,14 +327,14 @@ mod header_value {
#[derive(Debug, Clone)]
enum Inner {
H0(http0::HeaderValue),
H0(http_02x::HeaderValue),
#[allow(dead_code)]
H1(http1::HeaderValue),
H1(http_1x::HeaderValue),
}
impl HeaderValue {
#[allow(dead_code)]
pub(crate) fn from_http02x(value: http0::HeaderValue) -> Result<Self, Utf8Error> {
pub(crate) fn from_http02x(value: http_02x::HeaderValue) -> Result<Self, Utf8Error> {
let _ = std::str::from_utf8(value.as_bytes())?;
Ok(Self {
_private: Inner::H0(value),
@ -344,7 +342,7 @@ mod header_value {
}
#[allow(dead_code)]
pub(crate) fn from_http1x(value: http1::HeaderValue) -> Result<Self, Utf8Error> {
pub(crate) fn from_http1x(value: http_1x::HeaderValue) -> Result<Self, Utf8Error> {
let _ = std::str::from_utf8(value.as_bytes())?;
Ok(Self {
_private: Inner::H1(value),
@ -352,18 +350,18 @@ mod header_value {
}
#[allow(dead_code)]
pub(crate) fn into_http02x(self) -> http0::HeaderValue {
pub(crate) fn into_http02x(self) -> http_02x::HeaderValue {
match self._private {
Inner::H0(v) => v,
Inner::H1(v) => http0::HeaderValue::from_maybe_shared(v).expect("unreachable"),
Inner::H1(v) => http_02x::HeaderValue::from_maybe_shared(v).expect("unreachable"),
}
}
#[allow(dead_code)]
pub(crate) fn into_http1x(self) -> http1::HeaderValue {
pub(crate) fn into_http1x(self) -> http_1x::HeaderValue {
match self._private {
Inner::H1(v) => v,
Inner::H0(v) => http1::HeaderValue::from_maybe_shared(v).expect("unreachable"),
Inner::H0(v) => http_1x::HeaderValue::from_maybe_shared(v).expect("unreachable"),
}
}
}
@ -404,7 +402,7 @@ mod header_value {
fn try_from(value: String) -> Result<Self, Self::Error> {
Ok(HeaderValue::from_http02x(
http0::HeaderValue::try_from(value).map_err(HttpError::invalid_header_value)?,
http_02x::HeaderValue::try_from(value).map_err(HttpError::invalid_header_value)?,
)
.expect("input was a string"))
}
@ -418,7 +416,7 @@ type MaybeStatic = Cow<'static, str>;
fn header_name(
name: impl AsHeaderComponent,
panic_safe: bool,
) -> Result<http0::HeaderName, HttpError> {
) -> Result<http_02x::HeaderName, HttpError> {
name.repr_as_http02x_header_name().or_else(|name| {
name.into_maybe_static().and_then(|mut cow| {
if cow.chars().any(|c| c.is_ascii_uppercase()) {
@ -426,11 +424,11 @@ fn header_name(
}
match cow {
Cow::Borrowed(s) if panic_safe => {
http0::HeaderName::try_from(s).map_err(HttpError::invalid_header_name)
http_02x::HeaderName::try_from(s).map_err(HttpError::invalid_header_name)
}
Cow::Borrowed(staticc) => Ok(http0::HeaderName::from_static(staticc)),
Cow::Borrowed(staticc) => Ok(http_02x::HeaderName::from_static(staticc)),
Cow::Owned(s) => {
http0::HeaderName::try_from(s).map_err(HttpError::invalid_header_name)
http_02x::HeaderName::try_from(s).map_err(HttpError::invalid_header_name)
}
}
})
@ -440,11 +438,11 @@ fn header_name(
fn header_value(value: MaybeStatic, panic_safe: bool) -> Result<HeaderValue, HttpError> {
let header = match value {
Cow::Borrowed(b) if panic_safe => {
http0::HeaderValue::try_from(b).map_err(HttpError::invalid_header_value)?
http_02x::HeaderValue::try_from(b).map_err(HttpError::invalid_header_value)?
}
Cow::Borrowed(b) => http0::HeaderValue::from_static(b),
Cow::Borrowed(b) => http_02x::HeaderValue::from_static(b),
Cow::Owned(s) => {
http0::HeaderValue::try_from(s).map_err(HttpError::invalid_header_value)?
http_02x::HeaderValue::try_from(s).map_err(HttpError::invalid_header_value)?
}
};
HeaderValue::from_http02x(header).map_err(HttpError::new)
@ -511,7 +509,7 @@ mod tests {
.try_insert(
"foo",
// Valid header value with invalid UTF-8
http0::HeaderValue::from_bytes(&[0xC0, 0x80]).unwrap()
http_02x::HeaderValue::from_bytes(&[0xC0, 0x80]).unwrap()
)
.is_err());
}
@ -527,7 +525,7 @@ mod tests {
.try_insert(
"foo",
// Valid header value with invalid UTF-8
http0::HeaderValue::from_bytes(&[0xC0, 0x80]).unwrap()
http_02x::HeaderValue::from_bytes(&[0xC0, 0x80]).unwrap()
)
.is_err());
}

View File

@ -9,9 +9,6 @@ use crate::http::extensions::Extensions;
use crate::http::Headers;
use crate::http::HttpError;
use aws_smithy_types::body::SdkBody;
use http as http0;
use http0::uri::PathAndQuery;
use http0::Method;
use std::borrow::Cow;
/// Parts struct useful for structural decomposition that the [`Request`] type can be converted into.
@ -30,7 +27,7 @@ pub struct RequestParts<B = SdkBody> {
pub struct Request<B = SdkBody> {
body: B,
uri: Uri,
method: Method,
method: http_02x::Method,
extensions: Extensions,
headers: Headers,
}
@ -44,8 +41,8 @@ pub struct Uri {
#[derive(Debug, Clone)]
enum ParsedUri {
H0(http0::Uri),
H1(http1::Uri),
H0(http_02x::Uri),
H1(http_1x::Uri),
}
impl ParsedUri {
@ -79,7 +76,7 @@ impl Uri {
///
/// An `endpoint` MUST NOT contain a query
pub fn set_endpoint(&mut self, endpoint: &str) -> Result<(), HttpError> {
let endpoint: http0::Uri = endpoint.parse().map_err(HttpError::invalid_uri)?;
let endpoint: http_02x::Uri = endpoint.parse().map_err(HttpError::invalid_uri)?;
let endpoint = endpoint.into_parts();
let authority = endpoint
.authority
@ -87,7 +84,7 @@ impl Uri {
let scheme = endpoint
.scheme
.ok_or_else(|| HttpError::new("endpoint must have scheme"))?;
let new_uri = http0::Uri::builder()
let new_uri = http_02x::Uri::builder()
.authority(authority)
.scheme(scheme)
.path_and_query(merge_paths(endpoint.path_and_query, &self.parsed).as_ref())
@ -108,7 +105,7 @@ impl Uri {
self.parsed.query()
}
fn from_http0x_uri(uri: http0::Uri) -> Self {
fn from_http0x_uri(uri: http_02x::Uri) -> Self {
Self {
as_string: uri.to_string(),
parsed: ParsedUri::H0(uri),
@ -116,7 +113,7 @@ impl Uri {
}
#[allow(dead_code)]
fn from_http1x_uri(uri: http1::Uri) -> Self {
fn from_http1x_uri(uri: http_1x::Uri) -> Self {
Self {
as_string: uri.to_string(),
parsed: ParsedUri::H1(uri),
@ -124,7 +121,7 @@ impl Uri {
}
#[allow(dead_code)]
fn into_h0(self) -> http0::Uri {
fn into_h0(self) -> http_02x::Uri {
match self.parsed {
ParsedUri::H0(uri) => uri,
ParsedUri::H1(_uri) => self.as_string.parse().unwrap(),
@ -132,7 +129,10 @@ impl Uri {
}
}
fn merge_paths(endpoint_path: Option<PathAndQuery>, uri: &ParsedUri) -> Cow<'_, str> {
fn merge_paths(
endpoint_path: Option<http_02x::uri::PathAndQuery>,
uri: &ParsedUri,
) -> Cow<'_, str> {
let uri_path_and_query = uri.path_and_query();
let endpoint_path = match endpoint_path {
None => return Cow::Borrowed(uri_path_and_query),
@ -173,26 +173,26 @@ impl<'a> TryFrom<&'a str> for Uri {
}
#[cfg(feature = "http-02x")]
impl From<http0::Uri> for Uri {
fn from(value: http::Uri) -> Self {
impl From<http_02x::Uri> for Uri {
fn from(value: http_02x::Uri) -> Self {
Uri::from_http0x_uri(value)
}
}
#[cfg(feature = "http-02x")]
impl<B> TryInto<http0::Request<B>> for Request<B> {
impl<B> TryInto<http_02x::Request<B>> for Request<B> {
type Error = HttpError;
fn try_into(self) -> Result<http::Request<B>, Self::Error> {
fn try_into(self) -> Result<http_02x::Request<B>, Self::Error> {
self.try_into_http02x()
}
}
#[cfg(feature = "http-1x")]
impl<B> TryInto<http1::Request<B>> for Request<B> {
impl<B> TryInto<http_1x::Request<B>> for Request<B> {
type Error = HttpError;
fn try_into(self) -> Result<http1::Request<B>, Self::Error> {
fn try_into(self) -> Result<http_1x::Request<B>, Self::Error> {
self.try_into_http1x()
}
}
@ -203,8 +203,8 @@ impl<B> Request<B> {
/// Depending on the internal storage type, this operation may be free or it may have an internal
/// cost.
#[cfg(feature = "http-02x")]
pub fn try_into_http02x(self) -> Result<http0::Request<B>, HttpError> {
let mut req = http::Request::builder()
pub fn try_into_http02x(self) -> Result<http_02x::Request<B>, HttpError> {
let mut req = http_02x::Request::builder()
.uri(self.uri.into_h0())
.method(self.method)
.body(self.body)
@ -219,8 +219,8 @@ impl<B> Request<B> {
/// Depending on the internal storage type, this operation may be free or it may have an internal
/// cost.
#[cfg(feature = "http-1x")]
pub fn try_into_http1x(self) -> Result<http1::Request<B>, HttpError> {
let mut req = http1::Request::builder()
pub fn try_into_http1x(self) -> Result<http_1x::Request<B>, HttpError> {
let mut req = http_1x::Request::builder()
.uri(self.uri.as_string)
.method(self.method.as_str())
.body(self.body)
@ -245,8 +245,8 @@ impl<B> Request<B> {
pub fn new(body: B) -> Self {
Self {
body,
uri: Uri::from_http0x_uri(http0::Uri::from_static("/")),
method: Method::GET,
uri: Uri::from_http0x_uri(http_02x::Uri::from_static("/")),
method: http_02x::Method::GET,
extensions: Default::default(),
headers: Default::default(),
}
@ -353,10 +353,10 @@ impl Request<SdkBody> {
}
#[cfg(feature = "http-02x")]
impl<B> TryFrom<http0::Request<B>> for Request<B> {
impl<B> TryFrom<http_02x::Request<B>> for Request<B> {
type Error = HttpError;
fn try_from(value: http::Request<B>) -> Result<Self, Self::Error> {
fn try_from(value: http_02x::Request<B>) -> Result<Self, Self::Error> {
let (parts, body) = value.into_parts();
let headers = Headers::try_from(parts.headers)?;
Ok(Self {
@ -370,16 +370,16 @@ impl<B> TryFrom<http0::Request<B>> for Request<B> {
}
#[cfg(feature = "http-1x")]
impl<B> TryFrom<http1::Request<B>> for Request<B> {
impl<B> TryFrom<http_1x::Request<B>> for Request<B> {
type Error = HttpError;
fn try_from(value: http1::Request<B>) -> Result<Self, Self::Error> {
fn try_from(value: http_1x::Request<B>) -> Result<Self, Self::Error> {
let (parts, body) = value.into_parts();
let headers = Headers::try_from(parts.headers)?;
Ok(Self {
body,
uri: Uri::from_http1x_uri(parts.uri),
method: Method::from_bytes(parts.method.as_str().as_bytes()).expect("valid"),
method: http_02x::Method::from_bytes(parts.method.as_str().as_bytes()).expect("valid"),
extensions: parts.extensions.into(),
headers,
})
@ -388,18 +388,16 @@ impl<B> TryFrom<http1::Request<B>> for Request<B> {
#[cfg(all(test, feature = "http-02x", feature = "http-1x"))]
mod test {
use super::*;
use aws_smithy_types::body::SdkBody;
use http::header::{AUTHORIZATION, CONTENT_LENGTH};
use http::Uri;
use http_02x::header::{AUTHORIZATION, CONTENT_LENGTH};
#[test]
fn non_ascii_requests() {
let request = http::Request::builder()
let request = http_02x::Request::builder()
.header("k", "😹")
.body(SdkBody::empty())
.unwrap();
let request: Request = request
let request: super::Request = request
.try_into()
.expect("failed to convert a non-string header");
assert_eq!(request.headers().get("k"), Some("😹"))
@ -407,7 +405,7 @@ mod test {
#[test]
fn request_can_be_created() {
let req = http::Request::builder()
let req = http_02x::Request::builder()
.uri("http://foo.com")
.body(SdkBody::from("hello"))
.unwrap();
@ -422,7 +420,7 @@ mod test {
#[test]
fn uri_mutations() {
let req = http::Request::builder()
let req = http_02x::Request::builder()
.uri("http://foo.com")
.body(SdkBody::from("hello"))
.unwrap();
@ -437,7 +435,7 @@ mod test {
#[test]
#[should_panic]
fn header_panics() {
let req = http::Request::builder()
let req = http_02x::Request::builder()
.uri("http://foo.com")
.body(SdkBody::from("hello"))
.unwrap();
@ -451,8 +449,8 @@ mod test {
#[test]
fn try_clone_clones_all_data() {
let request = ::http::Request::builder()
.uri(Uri::from_static("https://www.amazon.com"))
let request = http_02x::Request::builder()
.uri(http_02x::Uri::from_static("https://www.amazon.com"))
.method("POST")
.header(CONTENT_LENGTH, 456)
.header(AUTHORIZATION, "Token: hello")
@ -473,8 +471,8 @@ mod test {
#[test]
fn valid_round_trips() {
let request = || {
http::Request::builder()
.uri(Uri::from_static("https://www.amazon.com"))
http_02x::Request::builder()
.uri(http_02x::Uri::from_static("https://www.amazon.com"))
.method("POST")
.header(CONTENT_LENGTH, 456)
.header(AUTHORIZATION, "Token: hello")
@ -502,7 +500,7 @@ mod test {
}
#[track_caller]
fn check_roundtrip(req: impl Fn() -> http0::Request<SdkBody>) {
fn check_roundtrip(req: impl Fn() -> http_02x::Request<SdkBody>) {
let mut container = super::Request::try_from(req()).unwrap();
container.add_extension(5_u32);
let mut h1 = container

View File

@ -8,8 +8,6 @@
use crate::http::extensions::Extensions;
use crate::http::{Headers, HttpError};
use aws_smithy_types::body::SdkBody;
#[allow(unused)]
use http as http0;
use std::fmt;
/// HTTP response status code
@ -51,28 +49,28 @@ impl TryFrom<u16> for StatusCode {
}
#[cfg(feature = "http-02x")]
impl From<http0::StatusCode> for StatusCode {
fn from(value: http0::StatusCode) -> Self {
impl From<http_02x::StatusCode> for StatusCode {
fn from(value: http_02x::StatusCode) -> Self {
Self(value.as_u16())
}
}
#[cfg(feature = "http-02x")]
impl From<StatusCode> for http0::StatusCode {
impl From<StatusCode> for http_02x::StatusCode {
fn from(value: StatusCode) -> Self {
Self::from_u16(value.0).unwrap()
}
}
#[cfg(feature = "http-1x")]
impl From<http1::StatusCode> for StatusCode {
fn from(value: http1::StatusCode) -> Self {
impl From<http_1x::StatusCode> for StatusCode {
fn from(value: http_1x::StatusCode) -> Self {
Self(value.as_u16())
}
}
#[cfg(feature = "http-1x")]
impl From<StatusCode> for http1::StatusCode {
impl From<StatusCode> for http_1x::StatusCode {
fn from(value: StatusCode) -> Self {
Self::from_u16(value.0).unwrap()
}
@ -105,10 +103,10 @@ impl<B> Response<B> {
/// Depending on the internal storage type, this operation may be free or it may have an internal
/// cost.
#[cfg(feature = "http-02x")]
pub fn try_into_http02x(self) -> Result<http0::Response<B>, HttpError> {
let mut res = http::Response::builder()
pub fn try_into_http02x(self) -> Result<http_02x::Response<B>, HttpError> {
let mut res = http_02x::Response::builder()
.status(
http0::StatusCode::from_u16(self.status.into())
http_02x::StatusCode::from_u16(self.status.into())
.expect("validated upon construction"),
)
.body(self.body)
@ -123,10 +121,10 @@ impl<B> Response<B> {
/// Depending on the internal storage type, this operation may be free or it may have an internal
/// cost.
#[cfg(feature = "http-1x")]
pub fn try_into_http1x(self) -> Result<http1::Response<B>, HttpError> {
let mut res = http1::Response::builder()
pub fn try_into_http1x(self) -> Result<http_1x::Response<B>, HttpError> {
let mut res = http_1x::Response::builder()
.status(
http1::StatusCode::from_u16(self.status.into())
http_1x::StatusCode::from_u16(self.status.into())
.expect("validated upon construction"),
)
.body(self.body)
@ -205,10 +203,10 @@ impl Response<SdkBody> {
}
#[cfg(feature = "http-02x")]
impl<B> TryFrom<http0::Response<B>> for Response<B> {
impl<B> TryFrom<http_02x::Response<B>> for Response<B> {
type Error = HttpError;
fn try_from(value: http0::Response<B>) -> Result<Self, Self::Error> {
fn try_from(value: http_02x::Response<B>) -> Result<Self, Self::Error> {
let (parts, body) = value.into_parts();
let headers = Headers::try_from(parts.headers)?;
Ok(Self {
@ -221,10 +219,10 @@ impl<B> TryFrom<http0::Response<B>> for Response<B> {
}
#[cfg(feature = "http-1x")]
impl<B> TryFrom<http1::Response<B>> for Response<B> {
impl<B> TryFrom<http_1x::Response<B>> for Response<B> {
type Error = HttpError;
fn try_from(value: http1::Response<B>) -> Result<Self, Self::Error> {
fn try_from(value: http_1x::Response<B>) -> Result<Self, Self::Error> {
let (parts, body) = value.into_parts();
let headers = Headers::try_from(parts.headers)?;
Ok(Self {
@ -243,7 +241,7 @@ mod test {
#[test]
fn non_ascii_responses() {
let response = http::Response::builder()
let response = http_02x::Response::builder()
.status(200)
.header("k", "😹")
.body(SdkBody::empty())
@ -256,7 +254,7 @@ mod test {
#[test]
fn response_can_be_created() {
let req = http::Response::builder()
let req = http_02x::Response::builder()
.status(200)
.body(SdkBody::from("hello"))
.unwrap();
@ -283,12 +281,12 @@ mod test {
}
#[track_caller]
fn check_roundtrip(req: impl Fn() -> http0::Response<SdkBody>) {
fn check_roundtrip(req: impl Fn() -> http_02x::Response<SdkBody>) {
let mut container = super::Response::try_from(req()).unwrap();
container.add_extension(5_u32);
let mut h1 = container
.try_into_http1x()
.expect("failed converting to http1x");
.expect("failed converting to http_1x");
assert_eq!(h1.extensions().get::<u32>(), Some(&5));
h1.extensions_mut().remove::<u32>();
@ -296,7 +294,7 @@ mod test {
container.add_extension(5_u32);
let mut h0 = container
.try_into_http02x()
.expect("failed converting back to http0x");
.expect("failed converting back to http_02x");
assert_eq!(h0.extensions().get::<u32>(), Some(&5));
h0.extensions_mut().remove::<u32>();
resp_eq!(h0, req());
@ -305,7 +303,7 @@ mod test {
#[test]
fn valid_round_trips() {
let response = || {
http::Response::builder()
http_02x::Response::builder()
.status(200)
.header("k", "v")
.header("multi", "v1")
@ -319,7 +317,7 @@ mod test {
#[test]
#[should_panic]
fn header_panics() {
let res = http::Response::builder()
let res = http_02x::Response::builder()
.status(200)
.body(SdkBody::from("hello"))
.unwrap();
@ -334,7 +332,7 @@ mod test {
#[test]
fn cant_cross_convert_with_extensions_h0_h1() {
let resp_h0 = || {
http::Response::builder()
http_02x::Response::builder()
.status(200)
.extension(5_u32)
.body(SdkBody::from("hello"))
@ -355,7 +353,7 @@ mod test {
#[test]
fn cant_cross_convert_with_extensions_h1_h0() {
let resp_h1 = || {
http1::Response::builder()
http_1x::Response::builder()
.status(200)
.extension(5_u32)
.body(SdkBody::from("hello"))

View File

@ -5,7 +5,7 @@
//! Conversion traits for converting an unshared type into a shared type.
//!
//! The standard [`From`](std::convert::From)/[`Into`](std::convert::Into) traits can't be
//! The standard [`From`]/[`Into`] traits can't be
//! used for this purpose due to the blanket implementation of `Into`.
//!
//! This implementation also adds a [`maybe_shared`] method and [`impl_shared_conversions`](crate::impl_shared_conversions)

View File

@ -31,9 +31,9 @@ bytes = "1"
# We probably need to update unit tests using the `fastrand` crate when that happens
fastrand = "2.0.0"
h2 = { version = "0.3", default-features = false, optional = true }
http = { version = "0.2.8" }
http-body-0-4 = { package = "http-body", version = "0.4.4" }
http-body-1 = { package = "http-body", version = "1" }
http-02x = { package = "http", version = "0.2.8" }
http-body-04x = { package = "http-body", version = "0.4.4" }
http-body-1x = { package = "http-body", version = "1" }
# This avoids bringing `httparse` 1.9.0 and 1.9.1 through `hyper-0-14` that break unit tests of runtime crates
httparse = "1.8.0"
hyper-0-14 = { package = "hyper", version = "0.14.26", default-features = false, optional = true }

View File

@ -20,7 +20,6 @@ use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_runtime_api::client::runtime_components::{GetIdentityResolver, RuntimeComponents};
use aws_smithy_types::base64::encode;
use aws_smithy_types::config_bag::ConfigBag;
use http::HeaderValue;
/// Destination for the API key
#[derive(Copy, Clone, Debug)]
@ -163,8 +162,8 @@ impl Sign for BasicAuthSigner {
.data::<Login>()
.ok_or("HTTP basic auth requires a `Login` identity")?;
request.headers_mut().insert(
http::header::AUTHORIZATION,
HeaderValue::from_str(&format!(
http_02x::header::AUTHORIZATION,
http_02x::HeaderValue::from_str(&format!(
"Basic {}",
encode(format!("{}:{}", login.user(), login.password()))
))
@ -222,10 +221,10 @@ impl Sign for BearerAuthSigner {
.data::<Token>()
.ok_or("HTTP bearer auth requires a `Token` identity")?;
request.headers_mut().insert(
http::header::AUTHORIZATION,
HeaderValue::from_str(&format!("Bearer {}", token.token())).map_err(|_| {
"Bearer token contains characters that can't be included in a HTTP header"
})?,
http_02x::header::AUTHORIZATION,
http_02x::HeaderValue::from_str(&format!("Bearer {}", token.token())).map_err(
|_| "Bearer token contains characters that can't be included in a HTTP header",
)?,
);
Ok(())
}
@ -298,7 +297,7 @@ mod tests {
let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
let config_bag = ConfigBag::base();
let identity = Identity::new(Token::new("some-token", None), None);
let mut request: HttpRequest = http::Request::builder()
let mut request: HttpRequest = http_02x::Request::builder()
.uri("http://example.com/Foobaz")
.body(SdkBody::empty())
.unwrap()
@ -330,7 +329,7 @@ mod tests {
let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
let config_bag = ConfigBag::base();
let identity = Identity::new(Token::new("some-token", None), None);
let mut request: HttpRequest = http::Request::builder()
let mut request: HttpRequest = http_02x::Request::builder()
.uri("http://example.com/Foobaz")
.body(SdkBody::empty())
.unwrap()
@ -358,7 +357,7 @@ mod tests {
let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
let config_bag = ConfigBag::base();
let identity = Identity::new(Login::new("Aladdin", "open sesame", None), None);
let mut request = http::Request::builder()
let mut request = http_02x::Request::builder()
.body(SdkBody::empty())
.unwrap()
.try_into()
@ -386,7 +385,7 @@ mod tests {
let config_bag = ConfigBag::base();
let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
let identity = Identity::new(Token::new("some-token", None), None);
let mut request = http::Request::builder()
let mut request = http_02x::Request::builder()
.body(SdkBody::empty())
.unwrap()
.try_into()
@ -413,7 +412,7 @@ mod tests {
let config_bag = ConfigBag::base();
let runtime_components = RuntimeComponentsBuilder::for_tests().build().unwrap();
let identity = Identity::new(Token::new("some-token", None), None);
let mut request = http::Request::builder()
let mut request = http_02x::Request::builder()
.header("Authorization", "wrong")
.body(SdkBody::empty())
.unwrap()

View File

@ -6,7 +6,6 @@
//! Code for applying endpoints to a request.
use aws_smithy_runtime_api::client::endpoint::{error::InvalidEndpointError, EndpointPrefix};
use http::uri::{Authority, Uri};
use std::borrow::Cow;
use std::result::Result as StdResult;
use std::str::FromStr;
@ -15,8 +14,8 @@ use std::str::FromStr;
///
/// This method mutates `uri` by setting the `endpoint` on it
pub fn apply_endpoint(
uri: &mut Uri,
endpoint: &Uri,
uri: &mut http_02x::Uri,
endpoint: &http_02x::Uri,
prefix: Option<&EndpointPrefix>,
) -> StdResult<(), InvalidEndpointError> {
let prefix = prefix.map(EndpointPrefix::as_str).unwrap_or("");
@ -30,14 +29,14 @@ pub fn apply_endpoint(
} else {
Cow::Borrowed(authority)
};
let authority = Authority::from_str(&authority).map_err(|err| {
let authority = http_02x::uri::Authority::from_str(&authority).map_err(|err| {
InvalidEndpointError::failed_to_construct_authority(authority.into_owned(), err)
})?;
let scheme = *endpoint
.scheme()
.as_ref()
.ok_or_else(InvalidEndpointError::endpoint_must_have_scheme)?;
let new_uri = Uri::builder()
let new_uri = http_02x::Uri::builder()
.authority(authority)
.scheme(scheme.clone())
.path_and_query(merge_paths(endpoint, uri).as_ref())
@ -47,7 +46,7 @@ pub fn apply_endpoint(
Ok(())
}
fn merge_paths<'a>(endpoint: &'a Uri, uri: &'a Uri) -> Cow<'a, str> {
fn merge_paths<'a>(endpoint: &'a http_02x::Uri, uri: &'a http_02x::Uri) -> Cow<'a, str> {
if let Some(query) = endpoint.path_and_query().and_then(|pq| pq.query()) {
tracing::warn!(query = %query, "query specified in endpoint will be ignored during endpoint resolution");
}

View File

@ -18,7 +18,7 @@ use aws_smithy_runtime_api::http::Response;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::{ConfigBag, Storable, StoreReplace};
use bytes::Buf;
use http_body_1::{Frame, SizeHint};
use http_body_1x::{Frame, SizeHint};
use pin_project_lite::pin_project;
use std::borrow::Cow;
use std::error::Error;
@ -70,8 +70,8 @@ impl ContentLengthEnforcingBody<SdkBody> {
impl<
E: Into<aws_smithy_types::body::Error>,
Data: Buf,
InnerBody: http_body_1::Body<Error = E, Data = Data>,
> http_body_1::Body for ContentLengthEnforcingBody<InnerBody>
InnerBody: http_body_1x::Body<Error = E, Data = Data>,
> http_body_1x::Body for ContentLengthEnforcingBody<InnerBody>
{
type Data = Data;
type Error = aws_smithy_types::body::Error;
@ -217,9 +217,9 @@ mod test {
use aws_smithy_types::byte_stream::ByteStream;
use aws_smithy_types::error::display::DisplayErrorContext;
use bytes::Bytes;
use http::header::CONTENT_LENGTH;
use http_body_0_4::Body;
use http_body_1::Frame;
use http_02x::header::CONTENT_LENGTH;
use http_body_04x::Body;
use http_body_1x::Frame;
use std::error::Error;
use std::pin::Pin;
use std::task::{Context, Poll};
@ -230,6 +230,7 @@ mod test {
}
impl ManyFrameBody {
#[allow(clippy::new_ret_no_self)]
fn new(input: impl Into<String>) -> SdkBody {
let mut data = input.into().as_bytes().to_vec();
data.reverse();
@ -237,7 +238,7 @@ mod test {
}
}
impl http_body_1::Body for ManyFrameBody {
impl http_body_1x::Body for ManyFrameBody {
type Data = Bytes;
type Error = <SdkBody as Body>::Error;

View File

@ -8,14 +8,14 @@ use crate::client::http::body::minimum_throughput::{
throughput::ThroughputReport, Throughput, ThroughputReadingBody,
};
use aws_smithy_async::rt::sleep::AsyncSleep;
use http_body_0_4::Body;
use http_body_04x::Body;
use std::future::Future;
use std::pin::{pin, Pin};
use std::task::{Context, Poll};
const ZERO_THROUGHPUT: Throughput = Throughput::new_bytes_per_second(0);
// Helper trait for interpretting the throughput report.
// Helper trait for interpreting the throughput report.
trait DownloadReport {
fn minimum_throughput_violated(self, minimum_throughput: Throughput) -> (bool, Throughput);
}
@ -140,18 +140,18 @@ where
fn poll_trailers(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
) -> Poll<Result<Option<http_02x::HeaderMap>, Self::Error>> {
let this = self.as_mut().project();
this.inner.poll_trailers(cx)
}
fn size_hint(&self) -> http_body_0_4::SizeHint {
self.inner.size_hint()
}
fn is_end_stream(&self) -> bool {
self.inner.is_end_stream()
}
fn size_hint(&self) -> http_body_04x::SizeHint {
self.inner.size_hint()
}
}
impl<B> Body for ThroughputReadingBody<B>
@ -208,16 +208,16 @@ where
fn poll_trailers(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
) -> Poll<Result<Option<http_02x::HeaderMap>, Self::Error>> {
let this = self.as_mut().project();
this.inner.poll_trailers(cx)
}
fn size_hint(&self) -> http_body_0_4::SizeHint {
self.inner.size_hint()
}
fn is_end_stream(&self) -> bool {
self.inner.is_end_stream()
}
fn size_hint(&self) -> http_body_04x::SizeHint {
self.inner.size_hint()
}
}

View File

@ -25,14 +25,11 @@ use aws_smithy_types::config_bag::ConfigBag;
use aws_smithy_types::error::display::DisplayErrorContext;
use aws_smithy_types::retry::ErrorKind;
use h2::Reason;
use http::{Extensions, Uri};
use hyper_0_14::client::connect::{capture_connection, CaptureConnection, Connection, HttpInfo};
use hyper_0_14::service::Service;
use std::borrow::Cow;
use std::collections::HashMap;
use std::error::Error;
use std::fmt;
use std::fmt::Debug;
use std::sync::RwLock;
use std::time::Duration;
use tokio::io::{AsyncRead, AsyncWrite};
@ -41,8 +38,6 @@ use tokio::io::{AsyncRead, AsyncWrite};
mod default_connector {
use aws_smithy_async::rt::sleep::SharedAsyncSleep;
use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
use hyper_0_14::client::HttpConnector;
use hyper_rustls::HttpsConnector;
// Creating a `with_native_roots` HTTP client takes 300ms on OS X. Cache this so that we
// don't need to repeatedly incur that cost.
@ -50,7 +45,7 @@ mod default_connector {
hyper_rustls::HttpsConnector<hyper_0_14::client::HttpConnector>,
> = once_cell::sync::Lazy::new(default_tls);
fn default_tls() -> HttpsConnector<HttpConnector> {
fn default_tls() -> hyper_rustls::HttpsConnector<hyper_0_14::client::HttpConnector> {
use hyper_rustls::ConfigBuilderExt;
hyper_rustls::HttpsConnectorBuilder::new()
.with_tls_config(
@ -168,7 +163,7 @@ impl HyperConnectorBuilder {
pub fn build<C>(self, tcp_connector: C) -> HyperConnector
where
C: Clone + Send + Sync + 'static,
C: Service<Uri>,
C: hyper_0_14::service::Service<http_02x::Uri>,
C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
C::Future: Unpin + Send + 'static,
C::Error: Into<BoxError>,
@ -286,7 +281,7 @@ impl<C> fmt::Debug for Adapter<C> {
fn extract_smithy_connection(capture_conn: &CaptureConnection) -> Option<ConnectionMetadata> {
let capture_conn = capture_conn.clone();
if let Some(conn) = capture_conn.clone().connection_metadata().as_ref() {
let mut extensions = Extensions::new();
let mut extensions = http_02x::Extensions::new();
conn.get_extras(&mut extensions);
let http_info = extensions.get::<HttpInfo>();
let mut builder = ConnectionMetadata::builder()
@ -311,12 +306,14 @@ fn extract_smithy_connection(capture_conn: &CaptureConnection) -> Option<Connect
impl<C> HttpConnector for Adapter<C>
where
C: Clone + Send + Sync + 'static,
C: hyper_0_14::service::Service<Uri>,
C: hyper_0_14::service::Service<http_02x::Uri>,
C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
C::Future: Unpin + Send + 'static,
C::Error: Into<BoxError>,
{
fn call(&self, request: HttpRequest) -> HttpConnectorFuture {
use hyper_0_14::service::Service;
let mut request = match request.try_into_http02x() {
Ok(request) => request,
Err(err) => {
@ -439,25 +436,11 @@ impl<C, F> HttpClient for HyperClient<F>
where
F: Fn() -> C + Send + Sync,
C: Clone + Send + Sync + 'static,
C: Service<Uri>,
C: hyper_0_14::service::Service<http_02x::Uri>,
C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
C::Future: Unpin + Send + 'static,
C::Error: Into<BoxError>,
{
fn validate_base_client_config(
&self,
_: &RuntimeComponentsBuilder,
_: &ConfigBag,
) -> Result<(), BoxError> {
// Initialize the TCP connector at this point so that native certs load
// at client initialization time instead of upon first request. We do it
// here rather than at construction so that it won't run if this is not
// the selected HTTP client for the base config (for example, if this was
// the default HTTP client, and it was overridden by a later plugin).
let _ = (self.tcp_connector_fn)();
Ok(())
}
fn http_connector(
&self,
settings: &HttpConnectorSettings,
@ -491,6 +474,20 @@ where
connector.expect("cache populated above")
}
fn validate_base_client_config(
&self,
_: &RuntimeComponentsBuilder,
_: &ConfigBag,
) -> Result<(), BoxError> {
// Initialize the TCP connector at this point so that native certs load
// at client initialization time instead of upon first request. We do it
// here rather than at construction so that it won't run if this is not
// the selected HTTP client for the base config (for example, if this was
// the default HTTP client, and it was overridden by a later plugin).
let _ = (self.tcp_connector_fn)();
Ok(())
}
fn connector_metadata(&self) -> Option<ConnectorMetadata> {
Some(ConnectorMetadata::new("hyper", Some(Cow::Borrowed("0.x"))))
}
@ -597,7 +594,7 @@ impl HyperClientBuilder {
pub fn build<C>(self, tcp_connector: C) -> SharedHttpClient
where
C: Clone + Send + Sync + 'static,
C: Service<Uri>,
C: hyper_0_14::service::Service<http_02x::Uri>,
C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
C::Future: Unpin + Send + 'static,
C::Error: Into<BoxError>,
@ -609,7 +606,7 @@ impl HyperClientBuilder {
where
F: Fn() -> C + Send + Sync + 'static,
C: Clone + Send + Sync + 'static,
C: Service<Uri>,
C: hyper_0_14::service::Service<http_02x::Uri>,
C::Response: Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
C::Future: Unpin + Send + 'static,
C::Error: Into<BoxError>,
@ -627,7 +624,6 @@ mod timeout_middleware {
use aws_smithy_async::rt::sleep::Sleep;
use aws_smithy_async::rt::sleep::{AsyncSleep, SharedAsyncSleep};
use aws_smithy_runtime_api::box_error::BoxError;
use http::Uri;
use pin_project_lite::pin_project;
use std::error::Error;
use std::fmt::Formatter;
@ -763,9 +759,9 @@ mod timeout_middleware {
}
}
impl<I> hyper_0_14::service::Service<Uri> for ConnectTimeout<I>
impl<I> hyper_0_14::service::Service<http_02x::Uri> for ConnectTimeout<I>
where
I: hyper_0_14::service::Service<Uri>,
I: hyper_0_14::service::Service<http_02x::Uri>,
I::Error: Into<BoxError>,
{
type Response = I::Response;
@ -776,7 +772,7 @@ mod timeout_middleware {
self.inner.poll_ready(cx).map_err(|err| err.into())
}
fn call(&mut self, req: Uri) -> Self::Future {
fn call(&mut self, req: http_02x::Uri) -> Self::Future {
match &self.timeout {
Some((sleep, duration)) => {
let sleep = sleep.sleep(*duration);
@ -793,9 +789,9 @@ mod timeout_middleware {
}
}
impl<I, B> hyper_0_14::service::Service<http::Request<B>> for HttpReadTimeout<I>
impl<I, B> hyper_0_14::service::Service<http_02x::Request<B>> for HttpReadTimeout<I>
where
I: hyper_0_14::service::Service<http::Request<B>, Error = hyper_0_14::Error>,
I: hyper_0_14::service::Service<http_02x::Request<B>, Error = hyper_0_14::Error>,
{
type Response = I::Response;
type Error = BoxError;
@ -805,7 +801,7 @@ mod timeout_middleware {
self.inner.poll_ready(cx).map_err(|err| err.into())
}
fn call(&mut self, req: http::Request<B>) -> Self::Future {
fn call(&mut self, req: http_02x::Request<B>) -> Self::Future {
match &self.timeout {
Some((sleep, duration)) => {
let sleep = sleep.sleep(*duration);
@ -824,15 +820,22 @@ mod timeout_middleware {
#[cfg(test)]
mod test {
use super::super::*;
use super::*;
use crate::client::http::hyper_014::HyperConnector;
use aws_smithy_async::assert_elapsed;
use aws_smithy_async::future::never::Never;
use aws_smithy_async::rt::sleep::{SharedAsyncSleep, TokioSleep};
use aws_smithy_runtime_api::box_error::BoxError;
use aws_smithy_runtime_api::client::http::HttpConnectorSettings;
use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_runtime_api::client::result::ConnectorError;
use aws_smithy_types::error::display::DisplayErrorContext;
use hyper_0_14::client::connect::Connected;
use hyper_0_14::client::connect::{Connected, Connection};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
use std::time::Duration;
use tokio::io::ReadBuf;
use tokio::io::{AsyncRead, AsyncWrite};
use tokio::net::TcpStream;
#[allow(unused)]
@ -849,7 +852,7 @@ mod timeout_middleware {
#[non_exhaustive]
#[derive(Clone, Default, Debug)]
struct NeverConnects;
impl hyper_0_14::service::Service<Uri> for NeverConnects {
impl hyper_0_14::service::Service<http_02x::Uri> for NeverConnects {
type Response = TcpStream;
type Error = ConnectorError;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
@ -858,7 +861,7 @@ mod timeout_middleware {
Poll::Ready(Ok(()))
}
fn call(&mut self, _uri: Uri) -> Self::Future {
fn call(&mut self, _uri: http_02x::Uri) -> Self::Future {
Box::pin(async move {
Never::new().await;
unreachable!()
@ -869,7 +872,7 @@ mod timeout_middleware {
/// A service that will connect but never send any data
#[derive(Clone, Debug, Default)]
struct NeverReplies;
impl hyper_0_14::service::Service<Uri> for NeverReplies {
impl hyper_0_14::service::Service<http_02x::Uri> for NeverReplies {
type Response = EmptyStream;
type Error = BoxError;
type Future = std::future::Ready<Result<Self::Response, Self::Error>>;
@ -878,7 +881,7 @@ mod timeout_middleware {
Poll::Ready(Ok(()))
}
fn call(&mut self, _req: Uri) -> Self::Future {
fn call(&mut self, _req: http_02x::Uri) -> Self::Future {
std::future::ready(Ok(EmptyStream))
}
}
@ -992,17 +995,20 @@ mod timeout_middleware {
#[cfg(all(test, feature = "test-util"))]
mod test {
use super::*;
use crate::client::http::hyper_014::{HyperClientBuilder, HyperConnector};
use crate::client::http::test_util::NeverTcpConnector;
use aws_smithy_async::time::SystemTimeSource;
use aws_smithy_runtime_api::box_error::BoxError;
use aws_smithy_runtime_api::client::http::{HttpClient, HttpConnectorSettings};
use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
use http::Uri;
use hyper_0_14::client::connect::{Connected, Connection};
use std::io::{Error, ErrorKind};
use std::pin::Pin;
use std::sync::atomic::{AtomicU32, Ordering};
use std::sync::Arc;
use std::task::{Context, Poll};
use std::time::Duration;
use tokio::io::{AsyncRead, AsyncWrite, ReadBuf};
#[tokio::test]
@ -1120,7 +1126,7 @@ mod test {
inner: T,
}
impl<T> hyper_0_14::service::Service<Uri> for TestConnection<T>
impl<T> hyper_0_14::service::Service<http_02x::Uri> for TestConnection<T>
where
T: Clone + Connection,
{
@ -1132,7 +1138,7 @@ mod test {
Poll::Ready(Ok(()))
}
fn call(&mut self, _req: Uri) -> Self::Future {
fn call(&mut self, _req: http_02x::Uri) -> Self::Future {
std::future::ready(Ok(self.inner.clone()))
}
}

View File

@ -17,7 +17,7 @@ use tokio::sync::oneshot;
#[derive(Debug)]
struct Inner {
response: Option<http::Response<SdkBody>>,
response: Option<http_02x::Response<SdkBody>>,
sender: Option<oneshot::Sender<HttpRequest>>,
}
@ -101,13 +101,13 @@ impl CaptureRequestReceiver {
/// );
/// ```
pub fn capture_request(
response: Option<http::Response<SdkBody>>,
response: Option<http_02x::Response<SdkBody>>,
) -> (CaptureRequestHandler, CaptureRequestReceiver) {
let (tx, rx) = oneshot::channel();
(
CaptureRequestHandler(Arc::new(Mutex::new(Inner {
response: Some(response.unwrap_or_else(|| {
http::Response::builder()
http_02x::Response::builder()
.status(200)
.body(SdkBody::empty())
.expect("unreachable")

View File

@ -13,7 +13,6 @@ use aws_smithy_runtime_api::client::orchestrator::{HttpRequest, HttpResponse};
use aws_smithy_runtime_api::http::Headers;
use aws_smithy_types::base64;
use bytes::Bytes;
use http::HeaderMap;
use indexmap::IndexMap;
use serde::{Deserialize, Serialize};
use std::collections::HashMap;
@ -129,9 +128,9 @@ pub struct Response {
headers: IndexMap<String, Vec<String>>,
}
impl From<&Request> for http::Request<()> {
impl From<&Request> for http_02x::Request<()> {
fn from(request: &Request) -> Self {
let mut builder = http::Request::builder().uri(request.uri.as_str());
let mut builder = http_02x::Request::builder().uri(request.uri.as_str());
for (k, values) in request.headers.iter() {
for v in values {
builder = builder.header(k, v);
@ -163,7 +162,7 @@ fn headers_to_map_http(headers: &Headers) -> IndexMap<String, Vec<String>> {
out
}
fn headers_to_map_02x(headers: &HeaderMap) -> IndexMap<String, Vec<String>> {
fn headers_to_map_02x(headers: &http_02x::HeaderMap) -> IndexMap<String, Vec<String>> {
let mut out: IndexMap<_, Vec<_>> = IndexMap::new();
for (header_name, header_value) in headers.iter() {
let entry = out.entry(header_name.to_string()).or_default();
@ -189,8 +188,8 @@ fn headers_to_map(headers: &Headers) -> IndexMap<String, Vec<String>> {
out
}
impl<'a, B> From<&'a http::Response<B>> for Response {
fn from(resp: &'a http::Response<B>) -> Self {
impl<'a, B> From<&'a http_02x::Response<B>> for Response {
fn from(resp: &'a http_02x::Response<B>) -> Self {
let status = resp.status().as_u16();
let headers = headers_to_map_02x(resp.headers());
Self { status, headers }
@ -312,7 +311,6 @@ mod tests {
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::byte_stream::ByteStream;
use bytes::Bytes;
use http::Uri;
use std::error::Error;
use std::fs;
@ -354,7 +352,7 @@ mod tests {
network_traffic.correct_content_lengths();
let inner = ReplayingClient::new(network_traffic.events.clone());
let connection = RecordingClient::new(SharedHttpConnector::new(inner.clone()));
let req = http::Request::post("https://www.example.com")
let req = http_02x::Request::post("https://www.example.com")
.body(SdkBody::from("hello world"))
.unwrap();
let mut resp = connection.call(req.try_into().unwrap()).await.expect("ok");
@ -371,7 +369,7 @@ mod tests {
let requests = inner.take_requests().await;
assert_eq!(
requests[0].uri(),
&Uri::from_static("https://www.example.com")
&http_02x::Uri::from_static("https://www.example.com")
);
assert_eq!(
requests[0].body(),

View File

@ -15,7 +15,7 @@ use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_runtime_api::shared::IntoShared;
use aws_smithy_types::body::SdkBody;
use http_body_0_4::Body;
use http_body_04x::Body;
use std::path::Path;
use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::{Arc, Mutex, MutexGuard};

View File

@ -16,8 +16,6 @@ use aws_smithy_runtime_api::shared::IntoShared;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::error::display::DisplayErrorContext;
use bytes::{Bytes, BytesMut};
use http::Request;
use http_body_0_4::Body;
use std::collections::{HashMap, VecDeque};
use std::error::Error;
use std::fmt;
@ -56,9 +54,9 @@ impl<T> Waitable<T> {
#[derive(Clone)]
pub struct ReplayingClient {
live_events: Arc<Mutex<HashMap<ConnectionId, VecDeque<Event>>>>,
verifiable_events: Arc<HashMap<ConnectionId, Request<Bytes>>>,
verifiable_events: Arc<HashMap<ConnectionId, http_02x::Request<Bytes>>>,
num_events: Arc<AtomicUsize>,
recorded_requests: Arc<Mutex<HashMap<ConnectionId, Waitable<http::Request<Bytes>>>>>,
recorded_requests: Arc<Mutex<HashMap<ConnectionId, Waitable<http_02x::Request<Bytes>>>>>,
}
// Ideally, this would just derive Debug, but that makes the tests in aws-config think they found AWS secrets
@ -165,7 +163,7 @@ impl ReplayingClient {
}
/// Return all the recorded requests for further analysis
pub async fn take_requests(self) -> Vec<http::Request<Bytes>> {
pub async fn take_requests(self) -> Vec<http_02x::Request<Bytes>> {
let mut recorded_requests =
std::mem::take(self.recorded_requests.lock().unwrap().deref_mut());
let mut out = Vec::with_capacity(recorded_requests.len());
@ -211,7 +209,7 @@ impl ReplayingClient {
let initial_request = events.iter().next().expect("must have one event");
let request = match &initial_request.action {
Action::Request { request } => {
http::Request::from(request).map(|_| Bytes::from(body))
http_02x::Request::from(request).map(|_| Bytes::from(body))
}
_ => panic!("invalid first event"),
};
@ -273,6 +271,8 @@ async fn replay_body(events: VecDeque<Event>, mut sender: hyper_0_14::body::Send
impl HttpConnector for ReplayingClient {
fn call(&self, mut request: HttpRequest) -> HttpConnectorFuture {
use http_body_04x::Body;
let event_id = self.next_id();
tracing::debug!("received event {}: {request:?}", event_id.0);
let mut events = match self.live_events.lock().unwrap().remove(&event_id) {
@ -322,7 +322,7 @@ impl HttpConnector for ReplayingClient {
Action::Response {
response: Ok(response),
} => {
let mut builder = http::Response::builder().status(response.status);
let mut builder = http_02x::Response::builder().status(response.status);
for (name, values) in response.headers {
for value in values {
builder = builder.header(&name, &value);

View File

@ -22,10 +22,10 @@ use std::sync::Arc;
///
/// ```rust
/// use aws_smithy_runtime::client::http::test_util::infallible_client_fn;
/// let http_client = infallible_client_fn(|_req| http::Response::builder().status(200).body("OK!").unwrap());
/// let http_client = infallible_client_fn(|_req| http_02x::Response::builder().status(200).body("OK!").unwrap());
/// ```
pub fn infallible_client_fn<B>(
f: impl Fn(http::Request<SdkBody>) -> http::Response<B> + Send + Sync + 'static,
f: impl Fn(http_02x::Request<SdkBody>) -> http_02x::Response<B> + Send + Sync + 'static,
) -> SharedHttpClient
where
B: Into<SdkBody>,
@ -37,7 +37,7 @@ where
struct InfallibleClientFn {
#[allow(clippy::type_complexity)]
response: Arc<
dyn Fn(http::Request<SdkBody>) -> Result<http::Response<SdkBody>, ConnectorError>
dyn Fn(http_02x::Request<SdkBody>) -> Result<http_02x::Response<SdkBody>, ConnectorError>
+ Send
+ Sync,
>,
@ -51,7 +51,7 @@ impl fmt::Debug for InfallibleClientFn {
impl InfallibleClientFn {
fn new<B: Into<SdkBody>>(
f: impl Fn(http::Request<SdkBody>) -> http::Response<B> + Send + Sync + 'static,
f: impl Fn(http_02x::Request<SdkBody>) -> http_02x::Response<B> + Send + Sync + 'static,
) -> Self {
Self {
response: Arc::new(move |request| Ok(f(request).map(|b| b.into()))),

View File

@ -75,7 +75,7 @@ impl NeverTcpConnector {
}
#[cfg(feature = "connector-hyper-0-14-x")]
impl hyper_0_14::service::Service<http::Uri> for NeverTcpConnector {
impl hyper_0_14::service::Service<http_02x::Uri> for NeverTcpConnector {
type Response = connection::NeverTcpConnection;
type Error = aws_smithy_runtime_api::box_error::BoxError;
type Future = std::pin::Pin<
@ -89,7 +89,7 @@ impl hyper_0_14::service::Service<http::Uri> for NeverTcpConnector {
std::task::Poll::Ready(Ok(()))
}
fn call(&mut self, _: http::Uri) -> Self::Future {
fn call(&mut self, _: http_02x::Uri) -> Self::Future {
Box::pin(async {
Never::new().await;
unreachable!()
@ -148,7 +148,6 @@ mod connection {
#[cfg(all(test, feature = "connector-hyper-0-14-x"))]
#[tokio::test]
async fn never_tcp_connector_plugs_into_hyper_014() {
use super::*;
use crate::client::http::hyper_014::HyperClientBuilder;
use aws_smithy_async::rt::sleep::TokioSleep;
use aws_smithy_async::time::SystemTimeSource;

View File

@ -12,7 +12,7 @@ use aws_smithy_runtime_api::client::orchestrator::{HttpRequest, HttpResponse};
use aws_smithy_runtime_api::client::result::ConnectorError;
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_runtime_api::shared::IntoShared;
use http::header::CONTENT_TYPE;
use http_02x::header::CONTENT_TYPE;
use std::ops::Deref;
use std::sync::{Arc, Mutex, MutexGuard};
@ -125,9 +125,9 @@ impl ValidateRequest {
/// ReplayEvent::new(
/// // If `assert_requests_match` is called later, then this request will be matched
/// // against the actual request that was made.
/// http::Request::builder().uri("http://localhost:1234/foo").body(SdkBody::empty()).unwrap(),
/// http_02x::Request::builder().uri("http://localhost:1234/foo").body(SdkBody::empty()).unwrap(),
/// // This response will be given to the first request regardless of whether it matches the request above.
/// http::Response::builder().status(200).body(SdkBody::empty()).unwrap(),
/// http_02x::Response::builder().status(200).body(SdkBody::empty()).unwrap(),
/// ),
/// // The next ReplayEvent covers the second request/response pair...
/// ]);
@ -145,7 +145,7 @@ impl ValidateRequest {
/// http_client.assert_requests_match(&[]);
/// ```
///
/// [`assert_requests_match`]: crate::client::http::test_util::StaticReplayClient::assert_requests_match
/// [`assert_requests_match`]: StaticReplayClient::assert_requests_match
/// [DVR]: crate::client::http::test_util::dvr
#[derive(Clone, Debug)]
pub struct StaticReplayClient {
@ -223,11 +223,11 @@ impl StaticReplayClient {
req.assert_matches(i, ignore_headers)
}
let remaining_requests = self.data.lock().unwrap();
let number_of_remaining_requests = remaining_requests.len();
let actual_requests = self.requests().len();
assert!(
remaining_requests.is_empty(),
"Expected {number_of_remaining_requests} additional requests (only {actual_requests} sent)",
"Expected {} additional requests (only {} sent)",
remaining_requests.len(),
self.requests().len()
);
}
}

View File

@ -45,11 +45,9 @@ use aws_smithy_async::future::BoxFuture;
use aws_smithy_runtime_api::client::http::SharedHttpClient;
use aws_smithy_runtime_api::shared::IntoShared;
use bytes::Bytes;
use http::{Request, Response};
use hyper_0_14::client::connect::dns::Name;
use hyper_0_14::server::conn::AddrStream;
use hyper_0_14::service::{make_service_fn, service_fn, Service};
use hyper_0_14::{Body, Server};
use std::collections::HashSet;
use std::convert::Infallible;
use std::error::Error;
@ -220,7 +218,7 @@ impl WireMockServer {
tracing::info!("established connection: {:?}", connection);
wire_log.lock().unwrap().push(RecordedEvent::NewConnection);
async move {
Ok::<_, Infallible>(service_fn(move |_: Request<hyper_0_14::Body>| {
Ok::<_, Infallible>(service_fn(move |_: http_02x::Request<hyper_0_14::Body>| {
if poisoned_conns.lock().unwrap().contains(&remote_addr) {
tracing::error!("poisoned connection {:?} was reused!", &remote_addr);
panic!("poisoned connection was reused!");
@ -246,7 +244,7 @@ impl WireMockServer {
}))
}
});
let server = Server::from_tcp(listener)
let server = hyper_0_14::Server::from_tcp(listener)
.unwrap()
.serve(make_service)
.with_graceful_shutdown(async {
@ -306,9 +304,11 @@ impl WireMockServer {
}
}
async fn generate_response_event(event: ReplayedEvent) -> Result<Response<Body>, Infallible> {
async fn generate_response_event(
event: ReplayedEvent,
) -> Result<http_02x::Response<hyper_0_14::Body>, Infallible> {
let resp = match event {
ReplayedEvent::HttpResponse { status, body } => http::Response::builder()
ReplayedEvent::HttpResponse { status, body } => http_02x::Response::builder()
.status(status)
.body(hyper_0_14::Body::from(body))
.unwrap(),

View File

@ -198,7 +198,7 @@ fn apply_configuration(
// do that without a breaking change. By overwriting the value in the config bag with a merged
// version, we can achieve a very similar behavior. `MergeTimeoutConfig`
let resolved_timeout_config = cfg.load::<MergeTimeoutConfig>();
tracing::debug!(
debug!(
"timeout settings for this operation: {:?}",
resolved_timeout_config
);
@ -464,15 +464,15 @@ async fn finally_op(
#[cfg(all(test, feature = "test-util"))]
mod tests {
use super::*;
use crate::client::auth::no_auth::{NoAuthRuntimePlugin, NO_AUTH_SCHEME_ID};
use crate::client::http::test_util::NeverClient;
use crate::client::orchestrator::endpoints::StaticUriEndpointResolver;
use crate::client::orchestrator::{invoke, invoke_with_stop_point, StopPoint};
use crate::client::retries::strategy::NeverRetryStrategy;
use crate::client::test_util::{
deserializer::CannedResponseDeserializer, serializer::CannedRequestSerializer,
};
use ::http::{Response, StatusCode};
use aws_smithy_runtime_api::box_error::BoxError;
use aws_smithy_runtime_api::client::auth::static_resolver::StaticAuthSchemeOptionResolver;
use aws_smithy_runtime_api::client::auth::{
AuthSchemeOptionResolverParams, SharedAuthSchemeOptionResolver,
@ -488,15 +488,23 @@ mod tests {
BeforeDeserializationInterceptorContextRef, BeforeSerializationInterceptorContextMut,
BeforeSerializationInterceptorContextRef, BeforeTransmitInterceptorContextMut,
BeforeTransmitInterceptorContextRef, FinalizerInterceptorContextMut,
FinalizerInterceptorContextRef,
FinalizerInterceptorContextRef, Input, Output,
};
use aws_smithy_runtime_api::client::interceptors::{Intercept, SharedInterceptor};
use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_runtime_api::client::orchestrator::{HttpRequest, OrchestratorError};
use aws_smithy_runtime_api::client::retries::SharedRetryStrategy;
use aws_smithy_runtime_api::client::runtime_components::RuntimeComponentsBuilder;
use aws_smithy_runtime_api::client::runtime_components::{
RuntimeComponents, RuntimeComponentsBuilder,
};
use aws_smithy_runtime_api::client::runtime_plugin::{RuntimePlugin, RuntimePlugins};
use aws_smithy_runtime_api::client::ser_de::{
SharedRequestSerializer, SharedResponseDeserializer,
};
use aws_smithy_runtime_api::shared::IntoShared;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::{ConfigBag, FrozenLayer, Layer};
use aws_smithy_types::timeout::TimeoutConfig;
use http_02x::{Response, StatusCode};
use std::borrow::Cow;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
@ -527,7 +535,7 @@ mod tests {
impl HttpConnector for OkConnector {
fn call(&self, _request: HttpRequest) -> HttpConnectorFuture {
HttpConnectorFuture::ready(Ok(::http::Response::builder()
HttpConnectorFuture::ready(Ok(http_02x::Response::builder()
.status(200)
.body(SdkBody::empty())
.expect("OK response is valid")

View File

@ -325,7 +325,7 @@ mod tests {
) -> Result<(), BoxError> {
request
.headers_mut()
.insert(http::header::AUTHORIZATION, "success!");
.insert(http_02x::header::AUTHORIZATION, "success!");
Ok(())
}
}
@ -565,7 +565,7 @@ mod tests {
let mut ctx = InterceptorContext::new(Input::doesnt_matter());
ctx.enter_serialization_phase();
ctx.set_request(
http::Request::builder()
http_02x::Request::builder()
.body(SdkBody::empty())
.unwrap()
.try_into()

View File

@ -12,9 +12,9 @@ use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_runtime_api::{box_error::BoxError, client::endpoint::EndpointPrefix};
use aws_smithy_types::config_bag::ConfigBag;
use aws_smithy_types::endpoint::Endpoint;
use http::header::HeaderName;
use http::uri::PathAndQuery;
use http::{HeaderValue, Uri};
use http_02x::header::HeaderName;
use http_02x::uri::PathAndQuery;
use http_02x::{HeaderValue, Uri};
use std::borrow::Cow;
use std::fmt::Debug;
use std::str::FromStr;
@ -147,7 +147,9 @@ fn apply_endpoint(
#[cfg(test)]
mod test {
use super::*;
use aws_smithy_runtime_api::client::endpoint::EndpointPrefix;
use aws_smithy_runtime_api::client::orchestrator::HttpRequest;
use aws_smithy_types::endpoint::Endpoint;
#[test]
fn test_apply_endpoint() {

View File

@ -7,7 +7,7 @@ use aws_smithy_runtime_api::client::orchestrator::{HttpResponse, SensitiveOutput
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::ConfigBag;
use bytes::{Buf, Bytes};
use http_body_0_4::Body;
use http_body_04x::Body;
use pin_utils::pin_mut;
use tracing::trace;

View File

@ -449,7 +449,7 @@ mod tests {
#[tokio::test]
async fn operation() {
let (connector, request_rx) = capture_request(Some(
http::Response::builder()
http_02x::Response::builder()
.status(418)
.body(SdkBody::from(&b"I'm a teapot!"[..]))
.unwrap(),
@ -486,21 +486,21 @@ mod tests {
async fn operation_retries() {
let connector = StaticReplayClient::new(vec![
ReplayEvent::new(
http::Request::builder()
http_02x::Request::builder()
.uri("http://localhost:1234/")
.body(SdkBody::from(&b"what are you?"[..]))
.unwrap(),
http::Response::builder()
http_02x::Response::builder()
.status(503)
.body(SdkBody::from(&b""[..]))
.unwrap(),
),
ReplayEvent::new(
http::Request::builder()
http_02x::Request::builder()
.uri("http://localhost:1234/")
.body(SdkBody::from(&b"what are you?"[..]))
.unwrap(),
http::Response::builder()
http_02x::Response::builder()
.status(418)
.body(SdkBody::from(&b"I'm a teapot!"[..]))
.unwrap(),

View File

@ -241,7 +241,7 @@ mod test {
#[test]
fn classify_by_response_status() {
let policy = HttpStatusCodeClassifier::default();
let res = http::Response::builder()
let res = http_02x::Response::builder()
.status(500)
.body("error!")
.unwrap()
@ -254,7 +254,7 @@ mod test {
#[test]
fn classify_by_response_status_not_retryable() {
let policy = HttpStatusCodeClassifier::default();
let res = http::Response::builder()
let res = http_02x::Response::builder()
.status(408)
.body("error!")
.unwrap()

View File

@ -147,7 +147,7 @@ async fn wire_level_test(
.serializer({
let endpoint_url = mock.endpoint_url();
move |_| {
let request = http::Request::builder()
let request = http_02x::Request::builder()
.uri(endpoint_url.clone())
// Make the body non-replayable since we don't actually want to retry
.body(SdkBody::from_body_0_4(SdkBody::from("body")))

View File

@ -42,7 +42,7 @@ pub use aws_smithy_types::{
body::SdkBody, error::display::DisplayErrorContext, timeout::TimeoutConfig,
};
pub use bytes::Bytes;
pub use http_body_0_4::Body;
pub use http_body_04x::Body;
pub use pin_utils::pin_mut;
pub use std::{
collections::VecDeque,
@ -87,7 +87,8 @@ impl HttpClient for FakeServer {
struct ChannelBody {
receiver: tokio::sync::mpsc::Receiver<Bytes>,
}
impl http_body_0_4::Body for ChannelBody {
impl Body for ChannelBody {
type Data = Bytes;
type Error = Infallible;
@ -96,7 +97,7 @@ impl http_body_0_4::Body for ChannelBody {
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
match self.receiver.poll_recv(cx) {
Poll::Ready(value) => Poll::Ready(value.map(|v| Ok(v))),
Poll::Ready(value) => Poll::Ready(value.map(Ok)),
Poll::Pending => Poll::Pending,
}
}
@ -104,7 +105,7 @@ impl http_body_0_4::Body for ChannelBody {
fn poll_trailers(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
) -> Poll<Result<Option<http_02x::HeaderMap>, Self::Error>> {
unreachable!()
}
}

View File

@ -34,7 +34,7 @@ async fn download_success() {
let result = eagerly_consume(response_body).await;
server.await.unwrap();
result.ok().expect("response MUST NOT timeout");
result.expect("response MUST NOT timeout");
}
/// Scenario: Download takes a some time to start, but then goes normally.
@ -62,7 +62,7 @@ async fn download_slow_start() {
let result = eagerly_consume(response_body).await;
server.await.unwrap();
result.ok().expect("response MUST NOT timeout");
result.expect("response MUST NOT timeout");
}
/// Scenario: Download starts fine, and then slowly falls below minimum throughput.
@ -166,7 +166,7 @@ async fn download_stall_recovery_in_grace_period() {
let result = eagerly_consume(response_body).await;
server.await.unwrap();
result.ok().expect("response MUST NOT timeout");
result.expect("response MUST NOT timeout");
}
/// Scenario: The server sends data fast enough, but the customer doesn't consume the
@ -191,7 +191,7 @@ async fn user_downloads_data_too_slowly() {
let result = slowly_consume(time, response_body).await;
server.await.unwrap();
result.ok().expect("response MUST NOT timeout");
result.expect("response MUST NOT timeout");
}
use download_test_tools::*;
@ -200,7 +200,13 @@ mod download_test_tools {
use crate::stalled_stream_common::*;
fn response(body: SdkBody) -> HttpResponse {
HttpResponse::try_from(http::Response::builder().status(200).body(body).unwrap()).unwrap()
HttpResponse::try_from(
http_02x::Response::builder()
.status(200)
.body(body)
.unwrap(),
)
.unwrap()
}
pub fn operation(
@ -228,7 +234,7 @@ mod download_test_tools {
}
}
let operation = Operation::builder()
Operation::builder()
.service_name("test")
.operation_name("test")
.http_client(FakeServer(http_connector.into_shared()))
@ -246,8 +252,7 @@ mod download_test_tools {
.interceptor(StalledStreamProtectionInterceptor::default())
.sleep_impl(sleep)
.time_source(time)
.build();
operation
.build()
}
/// Fake server/connector that responds with a channel body.
@ -280,7 +285,7 @@ mod download_test_tools {
if let Err(err) = result {
return Err(err);
} else {
tracing::info!("consumed bytes from the response body");
info!("consumed bytes from the response body");
}
}
Ok(())
@ -296,7 +301,7 @@ mod download_test_tools {
if let Err(err) = result {
return Err(err);
} else {
tracing::info!("consumed bytes from the response body");
info!("consumed bytes from the response body");
tick!(time, Duration::from_secs(10));
}
}

View File

@ -14,7 +14,7 @@ use aws_smithy_types::byte_stream::ByteStream;
use bytes::{BufMut, Bytes, BytesMut};
use hyper_0_14::server::conn::AddrStream;
use hyper_0_14::service::{make_service_fn, service_fn, Service};
use hyper_0_14::{Body, Server};
use hyper_0_14::Server;
use std::convert::Infallible;
use std::net::TcpListener;
use std::time::Duration;
@ -39,7 +39,7 @@ async fn stalled_stream_performance() {
let listener = TcpListener::bind("127.0.0.1:0").unwrap();
let make_service = make_service_fn(move |_connection: &AddrStream| async move {
Ok::<_, Infallible>(service_fn(
move |_: http::Request<hyper_0_14::Body>| async move {
move |_: http_02x::Request<hyper_0_14::Body>| async move {
let (mut sender, body) = hyper_0_14::Body::channel();
tokio::task::spawn(async move {
for _i in 0..(data_size / block_size) {
@ -49,7 +49,7 @@ async fn stalled_stream_performance() {
.expect("failed to write data");
}
});
Ok::<_, Infallible>(http::Response::new(body))
Ok::<_, Infallible>(http_02x::Response::new(body))
},
))
});
@ -80,9 +80,9 @@ async fn stalled_stream_performance() {
async fn make_request(address: &str, wrap_body: bool) -> Duration {
let mut client = hyper_0_14::Client::new();
let req = ::http::Request::builder()
let req = ::http_02x::Request::builder()
.uri(address)
.body(Body::empty())
.body(hyper_0_14::Body::empty())
.unwrap();
let resp = client.call(req).await;
let body = resp.unwrap().into_body();

View File

@ -254,7 +254,7 @@ mod upload_test_tools {
pub fn successful_response() -> HttpResponse {
HttpResponse::try_from(
http::Response::builder()
http_02x::Response::builder()
.status(200)
.body(SdkBody::empty())
.unwrap(),
@ -267,7 +267,7 @@ mod upload_test_tools {
time: TickAdvanceTime,
sleep: TickAdvanceSleep,
) -> Operation<SdkBody, StatusCode, Infallible> {
let operation = Operation::builder()
Operation::builder()
.service_name("test")
.operation_name("test")
.http_client(FakeServer(http_connector.into_shared()))
@ -285,8 +285,7 @@ mod upload_test_tools {
.interceptor(StalledStreamProtectionInterceptor::default())
.sleep_impl(sleep)
.time_source(time)
.build();
operation
.build()
}
/// Creates a fake HttpConnector implementation that calls the given async $body_fn