@@ -122,6 +122,7 @@ public class BoxAPIConnection {
122122 private int maxRetryAttempts ;
123123 private int connectTimeout ;
124124 private int readTimeout ;
125+ private Boolean useZstdCompression ;
125126 private final List <BoxAPIConnectionListener > listeners ;
126127 private RequestInterceptor interceptor ;
127128 private final Map <String , String > customHeaders ;
@@ -160,6 +161,7 @@ public BoxAPIConnection(String clientID, String clientSecret, String accessToken
160161 this .maxRetryAttempts = BoxGlobalSettings .getMaxRetryAttempts ();
161162 this .connectTimeout = BoxGlobalSettings .getConnectTimeout ();
162163 this .readTimeout = BoxGlobalSettings .getReadTimeout ();
164+ this .useZstdCompression = BoxGlobalSettings .getUseZstdCompression ();
163165 this .refreshLock = new ReentrantReadWriteLock ();
164166 this .userAgent = "Box Java SDK v" + SDK_VERSION + " (Java " + JAVA_VERSION + ")" ;
165167 this .listeners = new ArrayList <>();
@@ -237,7 +239,9 @@ private void buildHttpClients() {
237239 }
238240 }
239241 builder = modifyHttpClientBuilder (builder );
240- builder .addInterceptor (new ZstdInterceptor ());
242+ if (this .useZstdCompression ) {
243+ builder .addNetworkInterceptor (new ZstdInterceptor ());
244+ }
241245
242246 this .httpClient = builder .build ();
243247 this .noRedirectsHttpClient = new OkHttpClient .Builder (httpClient )
@@ -658,6 +662,23 @@ public void setConnectTimeout(int connectTimeout) {
658662 buildHttpClients ();
659663 }
660664
665+ /*
666+ * Gets if request use zstd encoding when possible
667+ * @return true if request use zstd encoding when possible
668+ */
669+ public Boolean getUseZstdCompression () {
670+ return this .useZstdCompression ;
671+ }
672+
673+ /*
674+ * Sets if request use zstd encoding when possible
675+ * @param useZstdCompression true if request use zstd encoding when possible
676+ */
677+ public void setUseZstdCompression (Boolean useZstdCompression ) {
678+ this .useZstdCompression = useZstdCompression ;
679+ buildHttpClients ();
680+ }
681+
661682 /**
662683 * Gets the read timeout for this connection in milliseconds.
663684 *
0 commit comments