-
Notifications
You must be signed in to change notification settings - Fork 246
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
Reading Extensions
value from Response
wrapper
#990
Comments
What problem are you trying to solve with the extensions? Maybe there's an alternative we can propose. |
We actually capture We write
|
Mostly I need the
Thanks for the example! Apply that to my own case, would I also need to write a new aws-sdk-rust/sdk/aws-smithy-runtime/src/client/http/connection_poisoning.rs Lines 57 to 61 in 51f987b
Or can I assume (with some tests) that a built-in smithy If yes, then I would only need the aws-sdk-rust/sdk/aws-smithy-runtime/src/client/http/hyper_014.rs Lines 325 to 332 in 51f987b
local_addr from the HttpInfo .
|
I do think that you might still want to implement It wouldn't be useful for my case, but it might make the interface more flexible for someone else. |
## Motivation and Context I want to use this field to uniquely identify TCP connection based on their `local_addr` + `remote_addr`. See awslabs/aws-sdk-rust#990 for additional motivation for this change. ## Description - Add a new optional `local_addr` field in the `ConnectionMetadata` struct. - Transfer the `local_addr` `SocketAddress` from the `hyper::HttpInfo` to the `ConnectionMetadata` field. - Add to the `trace-serialize` example program so that it will print out the capture connection values. ## Testing `cargo test` in `rust-runtime/aws-smithy-runtime-api` and `aws-smithy-runtime`. Also ran: ``` thedeck@c889f3b04fb0 examples % cargo run --example trace-serialize Finished dev [unoptimized + debuginfo] target(s) in 0.13s Running `/Users/thedeck/repos/github/declanvk/smithy-rs/target/debug/examples/trace-serialize` 2023-12-06T00:13:15.605555Z INFO lazy_load_identity: aws_smithy_runtime::client::identity::cache::lazy: identity cache miss occurred; added new identity (took Ok(296µs)) 2023-12-06T00:13:15.608344Z INFO trace_serialize: Response received: response=Response { status: StatusCode(200), headers: Headers { headers: {"content-type": HeaderValue { _private: "application/json" }, "content-length": HeaderValue { _private: "17" }, "date": HeaderValue { _private: "Wed, 06 Dec 2023 00:13:15 GMT" }} }, body: SdkBody { inner: BoxBody, retryable: false }, extensions: Extensions } 2023-12-06T00:13:15.608388Z INFO trace_serialize: Captured connection info remote_addr=Some(127.0.0.1:13734) local_addr=Some(127.0.0.1:50199) 2023-12-06T00:13:15.608511Z INFO trace_serialize: Response received POKEMON_SERVICE_URL=http://localhost:13734 response=GetServerStatisticsOutput { calls_count: 0 } ``` You can see the log line with "Captured connection info" contains the `remote_addr` and the `local_addr` fields. ## Checklist - [x] 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._ Co-authored-by: Declan Kelly <[email protected]>
@declanvk contributed a change to smithy-rs that will solve their problem in smithy-lang/smithy-rs#3286 Accessing http extensions is not something we would like to support unless there is a very compelling reason for it, so I'm going to close this for now. |
|
Describe the feature
I would like to be able to access the
extension
field of theResponse
wrapper.The issue is that in an interceptor hook, I cannot use the
try_into_http02x
method because it requires an owned value and the context will only return a shared reference to theResponse
. Additionally,Response
does not implement clone, so I wouldn't be able toresponse.clone().try_into_http02x()
.Use Case
I need this access so that I can read information like the
HttpInfo
as part of anIntercept
implementation that uses theread_after_attempt
hook.Proposed Solution
I realize that directly exposing the
http::Extension
doesn't make sense for a wrapper type where you are attempting to hide thehttp
dependency.Other options might be:
Clone
for theResponse
wrapper in a way that preserves theextensions
valueExtensions
type that is compatible withhttp
's and then expose that type in a public interfaceOther Information
No response
Acknowledgements
A note for the community
Community Note
The text was updated successfully, but these errors were encountered: