aws-sdk-rust
aws-sdk-rust copied to clipboard
[request]: Customize user-agent
Community Note
- Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue, please leave a comment
Tell us about your request I'd like to customize the user-agent for my application.
Tell us about the problem you're trying to solve. What are you trying to do, and why is it hard? I'm migrating from rusoto where I can add stuff to the user-agent:
let mut hyper = HttpClient::new()?;
hyper.local_agent(format!(
"QLDB Driver for Rust v{}/QLDB Shell for Rust v{}",
amazon_qldb_driver::version(),
env!("CARGO_PKG_VERSION")
));
Are you currently working around this issue? I'm not!
Additional context N/A
Attachments N/A
I needed this ability in some S3 client code I'm working on. I was able to hack something together that does the job, replacing the entire user agent with a custom string. It's not pretty and it involved copy-pasting some code from inside the AWS Rust SDK. Hopefully this helps the next person who needs this ability:
https://github.com/elastio/ssstar/blob/97292eaab71769bd52d6b682a88fcf365cda2ef7/ssstar/src/objstore/s3.rs#L1484-L1596
BTW, thanks to @guyilin-amazon and awslabs/amazon-qldb-shell#196 for providing the initial clue as to how to reach into the tangled nest of abstractions in AWS smithy-rs and find the right place to modify the HTTP headers for each request.
@anelson - I want to understand your requirements better. Did you see that there is an AppName config that you can use to append to the SDK's user agent? And is that flexible enough for your use-case?
Hi @jdisanti
I saw app_name but it does not solve the problem. In my case I'm working with the Amazon APN as a partner, and they require that our product use a specific user agent string when storing objects in S3 so that those objects can be associated with our partner account. I have more details than that but I think I received them under NDA with Amazon so I can't share them here. If you like I can put you in touch with our APN partner rep to get more details about this requirement.
In short, setting an app name just adds the app name string towards the end of the SDK-generated user agent. In this case I need to control the start of the user agent string. So if app_name were set as the prefix of the user agent, with all SDK-generated user agent components appended to the app name, this would have solved my problem. As it is it's not flexible enough.