Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Http updates #3059

Merged
merged 16 commits into from
Oct 14, 2023
Merged

Http updates #3059

merged 16 commits into from
Oct 14, 2023

Conversation

rcoh
Copy link
Collaborator

@rcoh rcoh commented Oct 11, 2023

Motivation and Context

  • Upgrade guidance
  • changelog

To allow seamless adoption of the incoming http crate, we're updating our client crates to use an intermediate type.

Description

Update client code to use HttpRequest. Some internal code still uses http::Request but those usages are limited.

Testing

CI

Checklist

  • I have updated CHANGELOG.next.toml if I made changes to the smithy-rs codegen or runtime crates
  • I have updated CHANGELOG.next.toml if I made changes to the AWS SDK, generated SDK code, or SDK runtime crates

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

Copy link
Collaborator

@jdisanti jdisanti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work on this! I only have minor comments so far.

self.0.uri()
}

/// Returns any HTTP headers that need to go along with the request, except for `Host`,
/// which should be sent based on the endpoint in the URI by the HTTP client rather than
/// added directly.
pub fn headers(&self) -> &http::HeaderMap<http::HeaderValue> {
self.0.headers()
pub fn headers(&self) -> impl Iterator<Item = (&str, &str)> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the sensitive flag on headers for presigning?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my take is this header is probably not that sensitive to make it worthwhile to return a custom type here. Open to thoughts though.

@@ -3,6 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

#![cfg(feature = "test-util")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that integration tests are predicated on features, we should update the check-aws-sdk-standalone-integration-tests script here:

pushd "${tmp_dir}/aws/sdk/integration-tests"
cargo check --tests
popd

It should check with --all-features.

@@ -18,10 +18,10 @@ fun String.doubleQuote(): String =
*/
fun String.dq(): String = this.doubleQuote()

val completeWords: List<String> = listOf("ipv4", "ipv6", "sigv4", "mib", "gib", "kib", "ttl")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
val completeWords: List<String> = listOf("ipv4", "ipv6", "sigv4", "mib", "gib", "kib", "ttl")
private val completeWords: List<String> = listOf("ipv4", "ipv6", "sigv4", "mib", "gib", "kib", "ttl")

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why GitHub thinks this file is binary 🤔

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please see #3778. The original author put non-printable characters into this file.

@@ -168,62 +170,46 @@ impl PresigningConfigBuilder {
///
/// **This struct has conversion convenience functions:**
///
/// - [`PresignedRequest::to_http_request<B>`][Self::to_http_request] returns an [`http::Request<B>`](https://docs.rs/http/0.2.6/http/request/struct.Request.html)
/// - [`PresignedRequest::to_http_02x_request<B>`][Self::to_http_03x_request] returns an [`http::Request<B>`](https://docs.rs/http/0.2.6/http/request/struct.Request.html)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// - [`PresignedRequest::to_http_02x_request<B>`][Self::to_http_03x_request] returns an [`http::Request<B>`](https://docs.rs/http/0.2.6/http/request/struct.Request.html)
/// - [`PresignedRequest::to_http_02x_request<B>`][Self::to_http_02x_request] returns an [`http::Request<B>`](https://docs.rs/http/0.2.6/http/request/struct.Request.html)

aws/rust-runtime/aws-inlineable/src/presigning.rs Outdated Show resolved Hide resolved
@@ -29,8 +29,11 @@ pub struct ReplayEvent {

impl ReplayEvent {
/// Creates a new `ReplayEvent`.
pub fn new(request: HttpRequest, response: HttpResponse) -> Self {
Self { request, response }
pub fn new(request: impl TryInto<HttpRequest>, response: impl TryInto<HttpResponse>) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@rcoh rcoh marked this pull request as ready for review October 13, 2023 16:37
@rcoh rcoh requested review from a team as code owners October 13, 2023 16:37
@rcoh rcoh requested a review from jdisanti October 13, 2023 16:39
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh added the breaking-change This will require a breaking change label Oct 13, 2023
@rcoh rcoh added this pull request to the merge queue Oct 13, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to a conflict with the base branch Oct 13, 2023
Copy link
Contributor

@ysaito1001 ysaito1001 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of places to update. Thanks for the work 🙇

@@ -55,5 +56,5 @@ async fn test_presigning() {
][..],
&query_params
);
assert!(presigned.headers().is_empty());
assert_eq!(presigned.headers().count(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_eq!(presigned.headers().count(), 0);
assert_eq!(0, presigned.headers().count());

@@ -97,7 +100,7 @@ async fn test_presigning() {
][..],
&query_params
);
assert!(presigned.headers().is_empty());
assert_eq!(presigned.headers().count(), 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_eq!(presigned.headers().count(), 0);
assert_eq!(0, presigned.headers().count());

Comment on lines +146 to +149
assert_eq!(
headers.get(CONTENT_TYPE.as_str()),
Some(&"application/x-test")
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_eq!(
headers.get(CONTENT_TYPE.as_str()),
Some(&"application/x-test")
);
assert_eq!(
Some(&"application/x-test"),
headers.get(CONTENT_TYPE.as_str())
);

headers.get(CONTENT_TYPE.as_str()),
Some(&"application/x-test")
);
assert_eq!(headers.get(CONTENT_LENGTH.as_str()), Some(&"12345"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_eq!(headers.get(CONTENT_LENGTH.as_str()), Some(&"12345"));
assert_eq!(Some(&"12345"), headers.get(CONTENT_LENGTH.as_str()));

Some(&"application/x-test")
);
assert_eq!(headers.get(CONTENT_LENGTH.as_str()), Some(&"12345"));
assert_eq!(headers.len(), 2);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
assert_eq!(headers.len(), 2);
assert_eq!(2, headers.len());

@@ -15,6 +16,11 @@ pub struct QueryWriter {
}

impl QueryWriter {
/// Creates a new `QueryWriter` from a string
pub fn new_from_string(uri: &str) -> Result<Self, InvalidUri> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, why not impl FromStr for QueryWriter ?

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@rcoh rcoh added this pull request to the merge queue Oct 14, 2023
Merged via the queue into main with commit 684605a Oct 14, 2023
40 of 41 checks passed
@rcoh rcoh deleted the http-updates branch October 14, 2023 01:23
@rcoh rcoh mentioned this pull request Oct 25, 2023
9 tasks
jdisanti added a commit that referenced this pull request Nov 11, 2023
For the same reason that the request wrapper types were created in
#3059, this PR establishes the response wrapper types and refactors
existing code to use them.

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
github-merge-queue bot pushed a commit that referenced this pull request Nov 16, 2023
## Motivation and Context
In #3059 there was an accidental deletion of a test
## Description
Re-introduce checking the URL in protocol tests

## Checklist
<!--- If a checkbox below is not applicable, then please DELETE it
rather than leaving it unchecked -->
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the
smithy-rs codegen or runtime crates
- [ ] I have updated `CHANGELOG.next.toml` if I made changes to the AWS
SDK, generated SDK code, or SDK runtime crates

----

_By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice._
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change This will require a breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants