Skip to content

Commit 17ca26d

Browse files
committed
set default values for compression flags
1 parent 5c52edb commit 17ca26d

File tree

1 file changed

+15
-3
lines changed
  • client-v2/src/main/java/com/clickhouse/client/api

1 file changed

+15
-3
lines changed

client-v2/src/main/java/com/clickhouse/client/api/Client.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ public Builder setSocketLinger(int secondsToWait) {
554554

555555
/**
556556
* Server response compression. If set to true server will compress the response.
557-
* Has most effect for read operations.
557+
* Has most effect for read operations. Default is true.
558558
*
559559
* @param enabled - indicates if server response compression is enabled
560560
*/
@@ -565,7 +565,7 @@ public Builder compressServerResponse(boolean enabled) {
565565

566566
/**
567567
* Client request compression. If set to true client will compress the request.
568-
* Has most effect for write operations.
568+
* Has most effect for write operations. Default is false.
569569
*
570570
* @param enabled - indicates if client request compression is enabled
571571
*/
@@ -577,7 +577,7 @@ public Builder compressClientRequest(boolean enabled) {
577577
/**
578578
* Configures the client to use HTTP compression. In this case compression is controlled by
579579
* http headers. Client compression will set {@code Content-Encoding: lz4} header and server
580-
* compression will set {@code Accept-Encoding: lz4} header.
580+
* compression will set {@code Accept-Encoding: lz4} header. Default is false.
581581
*
582582
* @param enabled - indicates if http compression is enabled
583583
* @return
@@ -1079,6 +1079,18 @@ private void setDefaults() {
10791079
useHTTPBasicAuth(true);
10801080
}
10811081

1082+
if (!configuration.containsKey(ClientConfigProperties.COMPRESS_CLIENT_REQUEST.getKey())) {
1083+
compressClientRequest(false);
1084+
}
1085+
1086+
if (!configuration.containsKey(ClientConfigProperties.COMPRESS_SERVER_RESPONSE.getKey())) {
1087+
compressServerResponse(true);
1088+
}
1089+
1090+
if (!configuration.containsKey(ClientConfigProperties.USE_HTTP_COMPRESSION.getKey())) {
1091+
useHttpCompression(false);
1092+
}
1093+
10821094
String userAgent = configuration.getOrDefault(ClientConfigProperties.HTTP_HEADER_PREFIX + HttpHeaders.USER_AGENT.toUpperCase(Locale.US), "");
10831095
String clientName = configuration.getOrDefault(ClientConfigProperties.CLIENT_NAME.getKey(), "");
10841096
httpHeader(HttpHeaders.USER_AGENT, buildUserAgent(userAgent.isEmpty() ? clientName : userAgent));

0 commit comments

Comments
 (0)