adutra commented on code in PR #18878:
URL: https://github.com/apache/iceberg/pull/18878#discussion_r4600920872


##########
core/src/main/java/org/apache/iceberg/rest/HTTPClient.java:
##########
@@ -169,6 +170,34 @@ public HTTPClient withAuthSession(AuthSession session) {
     return new HTTPClient(this, session);
   }
 
+  @VisibleForTesting
+  static String userAgent(String override, String prefix) {
+    if (override != null) {
+      checkVisibleAscii(REST_USER_AGENT, override);
+      return override;
+    }
+
+    // the format the REST spec recommends, with the library token after any 
caller tokens
+    String userAgent =
+        String.format(
+            "iceberg-java/%s (jvm %s)", IcebergBuild.version(), 
System.getProperty("java.version"));
+    if (prefix == null) {
+      return userAgent;
+    }
+
+    checkVisibleAscii(REST_USER_AGENT_PREFIX, prefix);
+    String tokens = prefix.strip();
+    return tokens.isEmpty() ? userAgent : tokens + " " + userAgent;
+  }
+
+  // the HTTP client silently replaces other characters with '?'
+  private static void checkVisibleAscii(String property, String value) {

Review Comment:
   nit: I would inline this method.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to