Skip to content

Commit

Permalink
dbeaver/dbeaver#23361 Proper user agent
Browse files Browse the repository at this point in the history
  • Loading branch information
serge-rider committed Nov 4, 2024
1 parent 9da3438 commit 801817d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ public LibSqlConnection(
}

public LibSqlClient getClient() {
String applicationName = getClientApplicationName();
if (!CommonUtils.isEmpty(applicationName)) {
client.setUserAgent(applicationName);
}
return client;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public LibSqlExecutionResult[] executeBatch(
final HttpRequest.Builder builder = HttpRequest.newBuilder()
.uri(url.toURI())
.version(HttpClient.Version.HTTP_1_1)
//.header("Content-Type", "application/json")
.header("Content-Type", "application/json")
.header("User-Agent", userAgent)
.POST(HttpRequest.BodyPublishers.ofString(requestBuffer.toString()));
if (authToken != null) {
Expand Down Expand Up @@ -149,7 +149,9 @@ public HttpURLConnection openSimpleConnection(String endpoint) throws IOExceptio
baseURL += "/";
}
baseURL += endpoint;
return (HttpURLConnection) new URL(baseURL).openConnection();
HttpURLConnection connection = (HttpURLConnection) new URL(baseURL).openConnection();
connection.setRequestProperty("User-Agent", userAgent);
return connection;
}

private void executeQuery(
Expand Down

0 comments on commit 801817d

Please sign in to comment.