Skip to content

Update core User-Agent logic #12

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

Merged
merged 10 commits into from
Mar 7, 2019
Merged

Update core User-Agent logic #12

merged 10 commits into from
Mar 7, 2019

Conversation

lpatino10
Copy link
Contributor

@lpatino10 lpatino10 commented Mar 6, 2019

This PR updates the logic regarding the User-Agent header. getUserAgent() now returns the core-specific information, which is the core package version and the various OS and Java versions. This can be called from SDKs that pull in the core as a dependency.

This PR also ensures that, if the User-Agent isn't set on a request, the core info is sent as the User-Agent, so that something is always passed with the request.

In the Java SDK, the method to set the User-Agent will look like this:

private static String getUserAgent() {
    return "watson-apis-java-sdk/" + loadSdkVersion() + "; " + RequestUtils.getUserAgent();
  }

This will result in something like the following:

watson-apis-java-sdk/6.10.1; ibm-java-sdk-core/1.2.1 (os.name=Linux, os.arch=x64, os.version=7.5)

@lpatino10 lpatino10 requested a review from padamstx March 6, 2019 21:32
@lpatino10 lpatino10 changed the title Add method to get core version Update core User-Agent logic Mar 7, 2019
@lpatino10
Copy link
Contributor Author

@padamstx this should be ready for a re-review

padamstx
padamstx previously approved these changes Mar 7, 2019
@@ -153,6 +153,9 @@
*/
String WWW_AUTHENTICATE = "WWW-Authenticate";

/** Header containing analytics info. */
String X_IBMCLOUD_SDK_ANALYTICS = "X-IBMCloud-SDK-Analytics";

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't seem right that a watson-specific header name is defined inside the core. At least I think this sdk analytics stuff is watson-specific. Anyway, it's not a showstopper or anything, but just seems a little odd is all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good call actually. I'll move that out into the Watson SDK and make a point to get rid of other Watson-specific things in a later PR.

@lpatino10 lpatino10 merged commit 3ae6ae5 into master Mar 7, 2019
@lpatino10 lpatino10 deleted the get-core-version branch March 7, 2019 22:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants