artiya4u / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

Allow customizing user agent without USER_AGENT_SUFFIX #53

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
version: Google-HTTP-Java-Client/1.6.0-beta 

could the library allow us to completely customize the user agent without the 
hardcoded suffix? 

http://code.google.com/p/google-http-java-client/source/browse/google-http-clien
t/src/main/java/com/google/api/client/http/HttpRequest.java
{code}
public static final String USER_AGENT_SUFFIX =
      "Google-HTTP-Java-Client/" + Strings.VERSION + " (gzip)";
...
   // add to user agent
      if (headers.getUserAgent() == null) {
        headers.setUserAgent(USER_AGENT_SUFFIX);
      } else {
        headers.setUserAgent(headers.getUserAgent() + " " + USER_AGENT_SUFFIX);
      }
{code}

I propose just to remove the else case above. IMHO, it is a good practice to 
use User-Agent http header like that, but as a library, there should be an 
option for us not to follow the good practice. what do you think?

Original issue reported on code.google.com by mingfai...@gmail.com on 22 Nov 2011 at 7:01

GoogleCodeExporter commented 9 years ago
Perhaps we should add a setSuppressUserAgentSuffix(boolean) method to 
HttpRequest which is false by default?

Feedback from Alexey Zakharov on 7/19/2012:
https://groups.google.com/forum/?fromgroups#!topic/google-http-java-client/A-JFu
FWAw_k

"
Current implementation make it impossible to remove google http client suffix 
from UserAgent.
Could you please make it optional, because it breaks our company guidelines.
"

Original comment by yan...@google.com on 26 Jul 2012 at 1:52

GoogleCodeExporter commented 9 years ago
http://codereview.appspot.com/6448055/

Original comment by rmis...@google.com on 26 Jul 2012 at 3:30

GoogleCodeExporter commented 9 years ago

Original comment by rmis...@google.com on 7 Aug 2012 at 2:05