Skip to content
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

fix: add version in userAgent requestHeaders #1408

Closed
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -35,7 +35,7 @@ public final class GoogleUtils {
// NOTE: toString() so compiler thinks it isn't a constant, so it won't inline it
// {x-version-update-start:google-api-client:current}
/** Current release version. */
public static final String VERSION = "1.30.3".toString();
public static final String VERSION = "1.30.5".toString();
// {x-version-update-end:google-api-client:current}

// NOTE: Integer instead of int so compiler thinks it isn't a constant, so it won't inline it
Expand Down
Expand Up @@ -126,7 +126,7 @@ protected AbstractGoogleClientRequest(AbstractGoogleClient abstractGoogleClient,
// application name
String applicationName = abstractGoogleClient.getApplicationName();
if (applicationName != null) {
requestHeaders.setUserAgent(applicationName + " " + USER_AGENT_SUFFIX);
requestHeaders.setUserAgent(applicationName + GoogleUtils.VERSION + " " + USER_AGENT_SUFFIX);
Copy link

Choose a reason for hiding this comment

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

minor - do you want to leave a space or delimiter between application name and version number?

Copy link
Contributor

Choose a reason for hiding this comment

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

The space here is correct, as it is a separate entry in the user-agent and the space is required.

jsimonweb marked this conversation as resolved.
Show resolved Hide resolved
} else {
requestHeaders.setUserAgent(USER_AGENT_SUFFIX);
}
Expand Down
Expand Up @@ -12,6 +12,7 @@

package com.google.api.client.googleapis.services;

import com.google.api.client.googleapis.GoogleUtils;
import com.google.api.client.googleapis.services.AbstractGoogleClientRequest.ApiClientVersion;
import com.google.api.client.googleapis.testing.services.MockGoogleClient;
import com.google.api.client.googleapis.testing.services.MockGoogleClientRequest;
Expand Down Expand Up @@ -203,7 +204,7 @@ public void testUserAgentSuffix() throws Exception {
AssertUserAgentTransport transport = new AssertUserAgentTransport();
// Specify an Application Name.
String applicationName = "Test Application";
transport.expectedUserAgent = applicationName + " "
transport.expectedUserAgent = applicationName + GoogleUtils.VERSION + " "
+ AbstractGoogleClientRequest.USER_AGENT_SUFFIX + " "
+ HttpRequest.USER_AGENT_SUFFIX;
MockGoogleClient client = new MockGoogleClient.Builder(
Expand Down