@@ -56,6 +56,14 @@ public StreamHTTPClient(@NotNull String apiKey, @NotNull String apiSecret) {
5656 setCredetials (apiKey , apiSecret );
5757 }
5858
59+ public StreamHTTPClient (
60+ @ NotNull String apiKey , @ NotNull String apiSecret , @ NotNull OkHttpClient httpClient ) {
61+ this .apiKey = apiKey ;
62+ this .apiSecret = apiSecret ;
63+ var jwtToken = buildJWT (apiSecret );
64+ this .client = buildHTTPClient (jwtToken , httpClient .newBuilder ());
65+ }
66+
5967 // default constructor using ENV or System properties
6068 // env vars have priority over system properties
6169 public StreamHTTPClient () {
@@ -120,7 +128,13 @@ private void setCredetials(@NotNull String apiKey, @NotNull String apiSecret) {
120128 this .apiKey = apiKey ;
121129 this .apiSecret = apiSecret ;
122130 var jwtToken = buildJWT (apiSecret );
123- this .client = buildHTTPClient (jwtToken );
131+ this .client = buildHTTPClient (jwtToken , defaultHttpClientBuilder ());
132+ }
133+
134+ private OkHttpClient .Builder defaultHttpClientBuilder () {
135+ return new OkHttpClient .Builder ()
136+ .connectionPool (new ConnectionPool (5 , 59 , TimeUnit .SECONDS ))
137+ .callTimeout (timeout , TimeUnit .MILLISECONDS );
124138 }
125139
126140 private void readPropertiesAndEnv (Properties properties ) {
@@ -159,11 +173,7 @@ private void readPropertiesAndEnv(Properties properties) {
159173 return HttpLoggingInterceptor .Level .valueOf (logLevel );
160174 }
161175
162- private OkHttpClient buildHTTPClient (String jwtToken ) {
163- OkHttpClient .Builder httpClient =
164- new OkHttpClient .Builder ()
165- .connectionPool (new ConnectionPool (5 , 59 , TimeUnit .SECONDS ))
166- .callTimeout (timeout , TimeUnit .MILLISECONDS );
176+ private OkHttpClient buildHTTPClient (String jwtToken , OkHttpClient .Builder httpClient ) {
167177 httpClient .interceptors ().clear ();
168178
169179 HttpLoggingInterceptor loggingInterceptor =
0 commit comments