/** * Returns the application's name as a string in the format {@code gcloud-java/[version]}, * optionally prepended with externally supplied User-Agent header value (via setting custom * header provider). */ public String getApplicationName() { String libraryVersion = getLibraryVersion(); // We have to do the following since underlying layers often do not appreciate User-Agent // provided as a normal header and override it or treat setting "application name" as the only // way to append something to User-Agent header. StringBuilder sb = new StringBuilder(); String customUserAgentValue = getUserAgent(); if (customUserAgentValue != null) { sb.append(customUserAgentValue).append(' '); } if (libraryVersion == null) { sb.append(getLibraryName()); } else { sb.append(getLibraryName()).append('/').append(libraryVersion); } return sb.toString(); }
@Test public void testLibraryName() { assertEquals(LIBRARY_NAME, ServiceOptions.getLibraryName()); }
/** * Returns the application's name as a string in the format {@code gcloud-java/[version]}, * optionally prepended with externally supplied User-Agent header value (via setting custom * header provider). */ public String getApplicationName() { String libraryVersion = getLibraryVersion(); // We have to do the following since underlying layers often do not appreciate User-Agent // provided as a normal header and override it or treat setting "application name" as the only // way to append something to User-Agent header. StringBuilder sb = new StringBuilder(); String customUserAgentValue = getUserAgent(); if (customUserAgentValue != null) { sb.append(customUserAgentValue).append(' '); } if (libraryVersion == null) { sb.append(getLibraryName()); } else { sb.append(getLibraryName()).append('/').append(libraryVersion); } return sb.toString(); }