Skip to content

No user-agent set when communicating via proxy #1457

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

Open
abatkin opened this issue Oct 7, 2019 · 4 comments
Open

No user-agent set when communicating via proxy #1457

abatkin opened this issue Oct 7, 2019 · 4 comments
Labels
bug This issue is a bug. hacktoberfest We encourage contributions to this issue for Hacktoberfest. p3 This is a minor priority issue proxy This issue is related to a proxy configuration

Comments

@abatkin
Copy link

abatkin commented Oct 7, 2019

Expected Behavior

When communicating via an explicit (non-transparent) HTTP Proxy, the User-Agent header should be set to something like aws-sdk-java/whatever... (see UserAgentUtils.UA_STRING for the template)

Current Behavior

The User-Agent header is set to an empty string:

http-outgoing-1 >> "CONNECT sts.us-east-1.amazonaws.com:443 HTTP/1.1[\r][\n]"
http-outgoing-1 >> "Host: sts.us-east-1.amazonaws.com[\r][\n]"
http-outgoing-1 >> "User-Agent: [\r][\n]"
http-outgoing-1 >> "[\r][\n]"
http-outgoing-1 << "HTTP/1.1 200 Connection established[\r][\n]"
http-outgoing-1 << "[\r][\n]"

I believe this is due to the .setUserAgent("") in ApacheHttpClient.createClient().

Possible Solution

It would be nice for the User-Agent header to be set to something sensible in the client itself instead of the empty string (as outlined above). Later on in the (normal) request processing, the AWS SDK will set the User-Agent header itself, but that's only for the portion of the request that it actually handles (i.e. the SDK explicitly sets the header when making a request, whereas the setUserAgent() sets a property on the client itself, and that property is needed by HttpClient when talking to a proxy).

Steps to Reproduce (for bugs)

  1. Set up a proxy server
  2. Tell the SDK to use the proxy (either using the JDK standard System Properties or by setting proxyConfiguration() on the ApacheHttpClient's builder)
  3. Make a request to an AWS service (I used STS)
  4. Notice that an empty string is sent for the User-Agent header (either by looking at the HttpClient's debug logs, or asking the proxy server to dump the traffic)

Context

Proxy servers may handle requests different depending on a number of factors, including the User Agent. Without an accurate User Agent header, proxy servers lose an important piece of information.

Your Environment

  • AWS Java SDK version used: 2.9.14
  • JDK version used: 1.8.x
  • Operating System and version: Windows
@dagnir
Copy link
Contributor

dagnir commented Oct 7, 2019

Thanks @abatkin. This applies to the Netty client and probably the URL connection client as well.

@dagnir dagnir added the feature-request A feature should be added or improved. label Oct 23, 2019
@zoewangg zoewangg added the hacktoberfest We encourage contributions to this issue for Hacktoberfest. label Oct 2, 2020
@h-hub
Copy link

h-hub commented Oct 18, 2020

@zoewangg Since this is tagged with hacktoberfest, can I give this a try?

@zoewangg
Copy link
Contributor

@h-hub Absolutely! 😃 PRs are always welcome!

@h-hub
Copy link

h-hub commented Oct 20, 2020

Thanks @zoewangg 😃

aws-sdk-java-automation added a commit that referenced this issue Jun 9, 2021
…60ba79278

Pull request: release <- staging/df80b5d4-c11a-4564-8681-70a60ba79278
@millems millems added bug This issue is a bug. and removed feature-request A feature should be added or improved. labels Jul 21, 2021
@yasminetalby yasminetalby added the p3 This is a minor priority issue label Nov 12, 2022
@debora-ito debora-ito added the proxy This issue is related to a proxy configuration label Nov 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue is a bug. hacktoberfest We encourage contributions to this issue for Hacktoberfest. p3 This is a minor priority issue proxy This issue is related to a proxy configuration
Projects
None yet
Development

No branches or pull requests

7 participants