You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@jclouds.apache.org by vpanghal <no...@github.com> on 2016/12/15 19:16:21 UTC

[jclouds/jclouds] Make user agent header configurable (#1043)

Jclouds sends default user agent string with each request to cloud
services. But some application would like to override this and
send custom user agent instead.

This commit define a string property to override this default user agent
string. This property will be applied to all outgoing http request to
cloud services

JCLOUDS-819
You can view, comment on, or merge this pull request online at:

  https://github.com/jclouds/jclouds/pull/1043

-- Commit Summary --

  * Make user agent header configurable

-- File Changes --

    M core/src/main/java/org/jclouds/Constants.java (7)
    M core/src/main/java/org/jclouds/apis/internal/BaseApiMetadata.java (6)
    M core/src/main/java/org/jclouds/http/internal/JavaUrlHttpCommandExecutorService.java (13)
    M core/src/test/java/org/jclouds/http/internal/TrackingJavaUrlHttpCommandExecutorService.java (6)
    M providers/dynect/src/main/java/org/jclouds/dynect/v3/config/DynECTHttpApiModule.java (6)
    M providers/profitbricks/src/main/java/org/jclouds/profitbricks/http/ResponseStatusFromPayloadHttpCommandExecutorService.java (7)

-- Patch Links --

https://github.com/jclouds/jclouds/pull/1043.patch
https://github.com/jclouds/jclouds/pull/1043.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
@vpanghal pushed 1 commit.

4682963  Fix formatting


-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/jclouds/jclouds/pull/1043/files/bc01fd5a2f0e4e866d2e0c0a5add2a995f57d2b0..46829639b0acf9df24b58a50fcded28d63d64fca

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Zack Shoylev <no...@github.com>.
zack-shoylev commented on this pull request.



>  
    @Inject
    OkHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
          DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
          DelegatingErrorHandler errorHandler, HttpWire wire, Function<URI, Proxy> proxyForURI, OkHttpClient okHttpClient,
-         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods) {
+         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods,
+	 @Named(PROPERTY_USER_AGENT) String userAgent) {

And here

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#pullrequestreview-13626782

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
Checkstyle did not complain about whitespaces. Can you please point to the code where whitespace is off?

In our use case, we would like to override the complete user agent string. I think overriding gives complete control to the caller. Caller is free to send what jclouds is sending and append their own suffix.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#issuecomment-268058497

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Zack Shoylev <no...@github.com>.
zack-shoylev commented on this pull request.



>  
    @Inject
    public JavaUrlHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
          DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
          DelegatingErrorHandler errorHandler, HttpWire wire, @Named("untrusted") HostnameVerifier verifier,
          @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider, Function<URI, Proxy> proxyForURI,
-         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods) {
+         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods,
+	 @Named(PROPERTY_USER_AGENT) String userAgent) {

Seems like there is a tab here?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#pullrequestreview-13626695

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
vpanghal commented on this pull request.



>  
    @Inject
    public JavaUrlHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
          DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
          DelegatingErrorHandler errorHandler, HttpWire wire, @Named("untrusted") HostnameVerifier verifier,
          @Named("untrusted") Supplier<SSLContext> untrustedSSLContextProvider, Function<URI, Proxy> proxyForURI,
-         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods) {
+         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods,
+	 @Named(PROPERTY_USER_AGENT) String userAgent) {

done

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
vpanghal commented on this pull request.



>  
    @Inject
    ApacheHCHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
          DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
          DelegatingErrorHandler errorHandler, HttpWire wire, HttpClient client,
-         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods) {
+         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods,
+	 @Named(PROPERTY_USER_AGENT) String userAgent) {

done

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Zack Shoylev <no...@github.com>.
zack-shoylev commented on this pull request.



>  
    @Inject
    ApacheHCHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
          DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
          DelegatingErrorHandler errorHandler, HttpWire wire, HttpClient client,
-         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods) {
+         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods,
+	 @Named(PROPERTY_USER_AGENT) String userAgent) {

And here

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#pullrequestreview-13626747

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Ignasi Barrera <no...@github.com>.
Thanks @vpanghal! I think we're not configuring it now, but for consistency the user agent should be set in the Apache HTTP Client and OkHttp drivers too. Could you have a look at this and include it in the PR?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#issuecomment-267448570

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Ignasi Barrera <no...@github.com>.
Closed #1043.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#event-899904349

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
vpanghal commented on this pull request.



>  
    @Inject
    OkHttpCommandExecutorService(HttpUtils utils, ContentMetadataCodec contentMetadataCodec,
          DelegatingRetryHandler retryHandler, IOExceptionRetryHandler ioRetryHandler,
          DelegatingErrorHandler errorHandler, HttpWire wire, Function<URI, Proxy> proxyForURI, OkHttpClient okHttpClient,
-         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods) {
+         @Named(PROPERTY_IDEMPOTENT_METHODS) String idempotentMethods,
+	 @Named(PROPERTY_USER_AGENT) String userAgent) {

done

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Zack Shoylev <no...@github.com>.
Whitespace seems a bit off. I also would have preferred concatenating additional information on the default user agent string instead of replacing it, I think. Thoughts? Is a completely custom user agent required for an application?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#issuecomment-268053507

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
@vpanghal pushed 1 commit.

bc01fd5  Make user agent configurable for other http drivers


-- 
You are receiving this because you are subscribed to this thread.
View it on GitHub:
https://github.com/jclouds/jclouds/pull/1043/files/10e87f08ac980dad76de65fc82bd3b0d8dbbdcf0..bc01fd5a2f0e4e866d2e0c0a5add2a995f57d2b0

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Ignasi Barrera <no...@github.com>.
Thanks @vpanghal! I've squashed the commits and merged to [master](http://git-wip-us.apache.org/repos/asf/jclouds/commit/f3c3f3b3) and [2.0.x](http://git-wip-us.apache.org/repos/asf/jclouds/commit/79ad45d6).

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#issuecomment-268208153

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by vpanghal <no...@github.com>.
@nacx done! 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#issuecomment-267681363

Re: [jclouds/jclouds] Make user agent header configurable (#1043)

Posted by Zack Shoylev <no...@github.com>.
> In our use case, we would like to override the complete user agent string.

Good to know! 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/jclouds/jclouds/pull/1043#issuecomment-268059499