ex172000 commented on code in PR #2630:
URL: https://github.com/apache/iggy/pull/2630#discussion_r2742672715


##########
foreign/java/java-sdk/src/main/java/org/apache/iggy/client/blocking/http/InternalHttpClient.java:
##########
@@ -19,34 +19,98 @@
 
 package org.apache.iggy.client.blocking.http;
 
+import org.apache.commons.lang3.StringUtils;
+import org.apache.hc.client5.http.config.ConnectionConfig;
+import org.apache.hc.client5.http.config.RequestConfig;
+import org.apache.hc.client5.http.impl.classic.CloseableHttpClient;
 import org.apache.hc.client5.http.impl.classic.HttpClients;
+import 
org.apache.hc.client5.http.impl.io.PoolingHttpClientConnectionManagerBuilder;
+import org.apache.hc.client5.http.ssl.DefaultClientTlsStrategy;
 import org.apache.hc.core5.http.ClassicHttpRequest;
 import org.apache.hc.core5.http.ClassicHttpResponse;
 import org.apache.hc.core5.http.NameValuePair;
 import org.apache.hc.core5.http.io.HttpClientResponseHandler;
 import org.apache.hc.core5.http.io.support.ClassicRequestBuilder;
-import org.apache.iggy.client.blocking.http.error.IggyHttpError;
-import org.apache.iggy.client.blocking.http.error.IggyHttpException;
+import org.apache.hc.core5.ssl.SSLContextBuilder;
+import org.apache.hc.core5.util.Timeout;
+import org.apache.iggy.exception.IggyConnectionException;
+import org.apache.iggy.exception.IggyInvalidArgumentException;
+import org.apache.iggy.exception.IggyServerException;
+import org.apache.iggy.exception.IggyTlsException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import tools.jackson.core.type.TypeReference;
 import tools.jackson.databind.JavaType;
 import tools.jackson.databind.ObjectMapper;
+import tools.jackson.databind.node.ObjectNode;
 
+import java.io.Closeable;
+import java.io.File;
 import java.io.IOException;
+import java.security.GeneralSecurityException;
+import java.time.Duration;
 import java.util.Optional;
 
-final class InternalHttpClient {
+final class InternalHttpClient implements Closeable {
 
     private static final Logger log = 
LoggerFactory.getLogger(InternalHttpClient.class);
 
     private static final String AUTHORIZATION = "Authorization";
     private final String url;
     private final ObjectMapper objectMapper = 
ObjectMapperFactory.getInstance();
+    private final CloseableHttpClient httpClient;
     private Optional<String> token = Optional.empty();
 
-    InternalHttpClient(String url) {
+    InternalHttpClient(
+            String url,
+            Optional<Duration> connectionTimeout,
+            Optional<Duration> requestTimeout,
+            Optional<File> tlsCertificate) {
+        validateUrl(url);
         this.url = url;
+        this.httpClient = createHttpClient(connectionTimeout, requestTimeout, 
tlsCertificate);
+    }
+
+    private static void validateUrl(String url) {
+        if (StringUtils.isBlank(url)) {
+            throw new IggyInvalidArgumentException("URL cannot be null or 
empty");
+        }
+        if (!url.startsWith("http://";) && !url.startsWith("https://";)) {
+            throw new IggyInvalidArgumentException("URL must start with 
http:// or https://";);
+        }
+    }
+
+    private static CloseableHttpClient createHttpClient(
+            Optional<Duration> connectionTimeout, Optional<Duration> 
requestTimeout, Optional<File> tlsCertificate) {
+        var connectionConfigBuilder = ConnectionConfig.custom();

Review Comment:
   Curious to know the reason? 



-- 
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]

Reply via email to