Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,10 @@ protected AbstractGoogleClientRequest(AbstractGoogleClient abstractGoogleClient,
// application name
String applicationName = abstractGoogleClient.getApplicationName();
if (applicationName != null) {
requestHeaders.setUserAgent(applicationName + " " + USER_AGENT_SUFFIX);
requestHeaders.setUserAgent(applicationName + " " + USER_AGENT_SUFFIX + "/"
+ GoogleUtils.VERSION);
} else {
requestHeaders.setUserAgent(USER_AGENT_SUFFIX);
requestHeaders.setUserAgent(USER_AGENT_SUFFIX + "/" + GoogleUtils.VERSION);
}
// Set the header for the Api Client version (Java and OS version)
requestHeaders.set(API_VERSION_HEADER, ApiClientVersion.DEFAULT_VERSION);
Expand Down
Original file line number Diff line number Diff line change
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 {
// Specify an Application Name.
String applicationName = "Test Application";
transport.expectedUserAgent = applicationName + " "
Comment thread
chingor13 marked this conversation as resolved.
Resolved
+ AbstractGoogleClientRequest.USER_AGENT_SUFFIX + " "
+ "Google-API-Java-Client/" + GoogleUtils.VERSION + " "
+ HttpRequest.USER_AGENT_SUFFIX;
MockGoogleClient client = new MockGoogleClient.Builder(
transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null).setApplicationName(
Expand All @@ -215,7 +216,8 @@ public void testUserAgentSuffix() throws Exception {

public void testUserAgent() throws IOException {
AssertUserAgentTransport transport = new AssertUserAgentTransport();
transport.expectedUserAgent = AbstractGoogleClientRequest.USER_AGENT_SUFFIX + " " + HttpRequest.USER_AGENT_SUFFIX;
transport.expectedUserAgent = "Google-API-Java-Client/" + GoogleUtils.VERSION + " "
+ HttpRequest.USER_AGENT_SUFFIX;
// Don't specify an Application Name.
MockGoogleClient client = new MockGoogleClient.Builder(
transport, ROOT_URL, SERVICE_PATH, JSON_OBJECT_PARSER, null).build();
Expand Down