Skip to content

Commit

Permalink
revert http 1.x upgrade to aws-smithy-http crate
Browse files Browse the repository at this point in the history
  • Loading branch information
aajtodd committed Nov 7, 2024
1 parent b8513e9 commit 7102aad
Show file tree
Hide file tree
Showing 35 changed files with 1,788 additions and 1,009 deletions.
380 changes: 314 additions & 66 deletions aws/rust-runtime/Cargo.lock

Large diffs are not rendered by default.

361 changes: 305 additions & 56 deletions aws/rust-runtime/aws-config/Cargo.lock

Large diffs are not rendered by default.

11 changes: 5 additions & 6 deletions aws/rust-runtime/aws-inlineable/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ publish = false
repository = "https://github.com/smithy-lang/smithy-rs"

[features]
http_1x = ["dep:http-body-1x", "aws-smithy-runtime-api/http-1x"]
http_1x = ["dep:http-1x", "dep:http-body-1x", "aws-smithy-runtime-api/http-1x"]

[dependencies]
aws-credential-types = { path = "../aws-credential-types" }
Expand All @@ -21,17 +21,16 @@ aws-sigv4 = { path = "../aws-sigv4" }
aws-types = { path = "../aws-types" }
aws-smithy-async = { path = "../../../rust-runtime/aws-smithy-async", features = ["rt-tokio"] }
aws-smithy-checksums = { path = "../../../rust-runtime/aws-smithy-checksums" }
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http", features = ["compat"] }
aws-smithy-http = { path = "../../../rust-runtime/aws-smithy-http" }
aws-smithy-runtime = { path = "../../../rust-runtime/aws-smithy-runtime", features = ["client"] }
aws-smithy-runtime-api = { path = "../../../rust-runtime/aws-smithy-runtime-api", features = ["client"] }
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types", features = ["http-body-1-x"] }
aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types", features = ["http-body-0-4-x"] }
bytes = "1"
fastrand = "2.0.0"
hex = "0.4.3"
# FIXME(hyper1) - due to the way codegen generates crate dependencies right now we have to match the codegen names used for theses
http = { package = "http", version = "0.2.9" }
http = "0.2.9"
http-body = "0.4.5"
http-1x = { package = "http", version = "1" }
http-1x = { package = "http", version = "1", optional = true }
http-body-1x = { package = "http-body", version = "1", optional = true }
hmac = "0.12"
lru = "0.12.5"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use aws_smithy_runtime_api::client::interceptors::context::BeforeTransmitInterce
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 http_1x::header::ACCEPT;
use http_1x::HeaderValue;
use http::header::ACCEPT;
use http::HeaderValue;

/// Interceptor that adds an Accept header to API Gateway requests.
#[derive(Debug, Default)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::fmt;
use std::marker::PhantomData;

use bytes::Bytes;
use http_1x::header::HeaderValue;
use http::header::HeaderValue;
use ring::digest::{Context, Digest, SHA256};

use aws_runtime::auth::SigV4OperationSigningConfig;
Expand Down
14 changes: 6 additions & 8 deletions aws/rust-runtime/aws-inlineable/src/http_request_checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use aws_smithy_runtime_api::client::runtime_components::RuntimeComponents;
use aws_smithy_types::body::SdkBody;
use aws_smithy_types::config_bag::{ConfigBag, Layer, Storable, StoreReplace};
use aws_smithy_types::error::operation::BuildError;
use http_1x::HeaderValue;
use http::HeaderValue;
use http_body::Body;
use std::{fmt, mem};

Expand Down Expand Up @@ -221,8 +221,6 @@ fn wrap_streaming_request_body_in_checksum_calculating_body(
let aws_chunked_body_options =
AwsChunkedBodyOptions::new(original_body_size, vec![trailer_len]);

let body = aws_smithy_http::compat::Http1toHttp04::new(body);

let body = AwsChunkedBody::new(body, aws_chunked_body_options);

SdkBody::from_body_0_4(body)
Expand All @@ -237,20 +235,20 @@ fn wrap_streaming_request_body_in_checksum_calculating_body(
let headers = request.headers_mut();

headers.insert(
http_1x::header::HeaderName::from_static("x-amz-trailer"),
http::header::HeaderName::from_static("x-amz-trailer"),
checksum_algorithm.into_impl().header_name(),
);

headers.insert(
http_1x::header::CONTENT_LENGTH,
http::header::CONTENT_LENGTH,
HeaderValue::from(encoded_content_length),
);
headers.insert(
http_1x::header::HeaderName::from_static("x-amz-decoded-content-length"),
http::header::HeaderName::from_static("x-amz-decoded-content-length"),
HeaderValue::from(original_body_size),
);
headers.insert(
http_1x::header::CONTENT_ENCODING,
http::header::CONTENT_ENCODING,
HeaderValue::from_str(AWS_CHUNKED)
.map_err(BuildError::other)
.expect("\"aws-chunked\" will always be a valid HeaderValue"),
Expand All @@ -277,7 +275,7 @@ mod tests {
async fn test_checksum_body_is_retryable() {
let input_text = "Hello world";
let chunk_len_hex = format!("{:X}", input_text.len());
let mut request: HttpRequest = http_1x::Request::builder()
let mut request: HttpRequest = http::Request::builder()
.body(SdkBody::retryable(move || SdkBody::from(input_text)))
.unwrap()
.try_into()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ pub(crate) fn wrap_body_with_checksum_validator(
use aws_smithy_checksums::body::validate;

body.map(move |body| {
SdkBody::from_body_1_x(validate::ChecksumBody::new(
SdkBody::from_body_0_4(validate::ChecksumBody::new(
body,
checksum_algorithm.into_impl(),
precalculated_checksum.clone(),
Expand Down
7 changes: 3 additions & 4 deletions aws/rust-runtime/aws-inlineable/src/s3_request_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ mod test {
#[test]
fn handle_missing_header() {
let resp =
Response::try_from(http_1x::Response::builder().status(400).body("").unwrap()).unwrap();
Response::try_from(http::Response::builder().status(400).body("").unwrap()).unwrap();
let mut builder = ErrorMetadata::builder().message("123");
builder = apply_extended_request_id(builder, resp.headers());
assert_eq!(builder.build().extended_request_id(), None);
Expand All @@ -88,12 +88,11 @@ mod test {
#[test]
fn test_extended_request_id_sdk_error() {
let without_extended_request_id = || {
Response::try_from(http_1x::Response::builder().body(SdkBody::empty()).unwrap())
.unwrap()
Response::try_from(http::Response::builder().body(SdkBody::empty()).unwrap()).unwrap()
};
let with_extended_request_id = || {
Response::try_from(
http_1x::Response::builder()
http::Response::builder()
.header("x-amz-id-2", "some-request-id")
.body(SdkBody::empty())
.unwrap(),
Expand Down
1 change: 0 additions & 1 deletion aws/rust-runtime/aws-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ aws-smithy-types = { path = "../../../rust-runtime/aws-smithy-types" }
aws-types = { path = "../aws-types" }
bytes = "1.1"
fastrand = "2.0.0"
# TODO(hyper1) - can we make these pre 1.x http crates optional dependencies assuming usage is internal?
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 }
Expand Down
11 changes: 6 additions & 5 deletions aws/rust-runtime/aws-runtime/src/content_encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

use bytes::{Bytes, BytesMut};
use http_02x::{HeaderMap, HeaderValue};
use http_body_04x::{Body, SizeHint};
use pin_project_lite::pin_project;

use std::pin::Pin;
Expand Down Expand Up @@ -196,9 +197,9 @@ fn total_rendered_length_of_trailers(trailer_map: Option<&HeaderMap>) -> u64 {
}
}

impl<Inner> http_body_04x::Body for AwsChunkedBody<Inner>
impl<Inner> Body for AwsChunkedBody<Inner>
where
Inner: http_body_04x::Body<Data = Bytes, Error = aws_smithy_types::body::Error>,
Inner: Body<Data = Bytes, Error = aws_smithy_types::body::Error>,
{
type Data = Bytes;
type Error = aws_smithy_types::body::Error;
Expand Down Expand Up @@ -295,8 +296,8 @@ where
self.state == AwsChunkedBodyState::Closed
}

fn size_hint(&self) -> http_body_04x::SizeHint {
http_body_04x::SizeHint::with_exact(self.encoded_length())
fn size_hint(&self) -> SizeHint {
SizeHint::with_exact(self.encoded_length())
}
}

Expand Down Expand Up @@ -379,7 +380,7 @@ mod tests {
}
}

impl http_body_04x::Body for SputteringBody {
impl Body for SputteringBody {
type Data = Bytes;
type Error = aws_smithy_types::body::Error;

Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pub mod auth;

/// AWS-specific content-encoding tools
#[cfg(any(feature = "http-02x", feature = "http-1x"))]
#[cfg(feature = "http-02x")]
pub mod content_encoding;

/// Supporting code for recursion detection in the AWS SDK.
Expand Down
10 changes: 5 additions & 5 deletions aws/rust-runtime/aws-sigv4/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ repository = "https://github.com/smithy-lang/smithy-rs"

[features]
default = ["sign-http", "http1"]
http0-compat = ["dep:http-02x", "aws-smithy-runtime-api/http-02x"]
http1 = ["dep:http-1x"]
sign-http = ["dep:http-1x", "dep:percent-encoding", "dep:form_urlencoded"]
http0-compat = ["dep:http0"]
http1 = ["dep:http"]
sign-http = ["dep:http0", "dep:percent-encoding", "dep:form_urlencoded"]
sign-eventstream = ["dep:aws-smithy-eventstream"]
sigv4a = ["dep:p256", "dep:crypto-bigint", "dep:subtle", "dep:zeroize", "dep:ring"]

Expand All @@ -26,8 +26,8 @@ bytes = "1"
form_urlencoded = { version = "1.0", optional = true }
hex = "0.4"
hmac = "0.12"
http-02x = { package = "http", version = "0.2", optional = true }
http-1x = { package = "http", version = "1", optional = true }
http0 = { version = "0.2", optional = true, package = "http" }
http = { version = "1", optional = true }
once_cell = "1.8"
p256 = { version = "0.11", features = ["ecdsa"], optional = true }
percent-encoding = { version = "2.1", optional = true }
Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-sigv4/src/http_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
//! **Note**: This requires `http0-compat` to be enabled.
//!
//! ```rust
//! # use http_1x as http;
//! # use aws_credential_types::Credentials;
//! use aws_smithy_runtime_api::client::identity::Identity;
//! # use aws_sigv4::http_request::SignableBody;
//! #[cfg(feature = "http1")]
//! fn test() -> Result<(), aws_sigv4::http_request::SigningError> {
//! use aws_sigv4::http_request::{sign, SigningSettings, SigningParams, SignableRequest};
//! use aws_sigv4::sign::v4;
//! use http0;
//! use std::time::SystemTime;
//!
//! // Set up information and settings for the signing
Expand Down
16 changes: 8 additions & 8 deletions aws/rust-runtime/aws-sigv4/src/http_request/canonical_request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use crate::http_request::{PercentEncodingMode, SigningSettings};
use crate::sign::v4::sha256_hex_string;
use crate::SignatureVersion;
use aws_smithy_http::query_writer::QueryWriter;
use http_1x::header::{AsHeaderName, HeaderName, HOST};
use http_1x::{HeaderMap, HeaderValue, Uri};
use http0::header::{AsHeaderName, HeaderName, HOST};
use http0::{HeaderMap, HeaderValue, Uri};
use std::borrow::Cow;
use std::cmp::Ordering;
use std::fmt;
Expand Down Expand Up @@ -640,7 +640,7 @@ mod tests {
use aws_credential_types::Credentials;
use aws_smithy_http::query_writer::QueryWriter;
use aws_smithy_runtime_api::client::identity::Identity;
use http_1x::{HeaderValue, Uri};
use http0::{HeaderValue, Uri};
use pretty_assertions::assert_eq;
use proptest::{prelude::*, proptest};
use std::borrow::Cow;
Expand Down Expand Up @@ -808,7 +808,7 @@ mod tests {

#[test]
fn test_tilde_in_uri() {
let req = http_1x::Request::builder()
let req = http0::Request::builder()
.uri("https://s3.us-east-1.amazonaws.com/my-bucket?list-type=2&prefix=~objprefix&single&k=&unreserved=-_.~").body("").unwrap().into();
let req = SignableRequest::from(&req);
let identity = Credentials::for_tests().into();
Expand All @@ -829,7 +829,7 @@ mod tests {
query_writer.insert("list-type", "2");
query_writer.insert("prefix", &all_printable_ascii_chars);

let req = http_1x::Request::builder()
let req = http0::Request::builder()
.uri(query_writer.build_uri())
.body("")
.unwrap()
Expand Down Expand Up @@ -877,7 +877,7 @@ mod tests {
// It should exclude authorization, user-agent, x-amzn-trace-id headers from presigning
#[test]
fn non_presigning_header_exclusion() {
let request = http_1x::Request::builder()
let request = http0::Request::builder()
.uri("https://some-endpoint.some-region.amazonaws.com")
.header("authorization", "test-authorization")
.header("content-type", "application/xml")
Expand Down Expand Up @@ -909,7 +909,7 @@ mod tests {
// It should exclude authorization, user-agent, x-amz-user-agent, x-amzn-trace-id headers from presigning
#[test]
fn presigning_header_exclusion() {
let request = http_1x::Request::builder()
let request = http0::Request::builder()
.uri("https://some-endpoint.some-region.amazonaws.com")
.header("authorization", "test-authorization")
.header("content-type", "application/xml")
Expand Down Expand Up @@ -958,7 +958,7 @@ mod tests {
valid_input,
)
) {
let mut request_builder = http_1x::Request::builder()
let mut request_builder = http0::Request::builder()
.uri("https://some-endpoint.some-region.amazonaws.com")
.header("content-type", "application/xml")
.header("content-length", "0");
Expand Down
4 changes: 2 additions & 2 deletions aws/rust-runtime/aws-sigv4/src/http_request/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

use http_1x::header::{InvalidHeaderName, InvalidHeaderValue};
use http_1x::uri::InvalidUri;
use http0::header::{InvalidHeaderName, InvalidHeaderValue};
use http0::uri::InvalidUri;
use std::error::Error;
use std::fmt;

Expand Down
2 changes: 1 addition & 1 deletion aws/rust-runtime/aws-sigv4/src/http_request/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

use http_1x::header::{AUTHORIZATION, USER_AGENT};
use http0::header::{AUTHORIZATION, USER_AGENT};
use std::borrow::Cow;
use std::time::Duration;

Expand Down
Loading

0 comments on commit 7102aad

Please sign in to comment.