531651225 commented on code in PR #4752:
URL: 
https://github.com/apache/incubator-seatunnel/pull/4752#discussion_r1195999047


##########
seatunnel-connectors-v2/connector-starrocks/src/main/java/org/apache/seatunnel/connectors/seatunnel/starrocks/client/HttpHelper.java:
##########
@@ -77,100 +77,58 @@ public String doHttpPost(String postUrl, Map<String, 
String> header, String post
         }
     }
 
-    public String doHttpGet(String getUrl) throws IOException {
-        log.info("Executing GET from {}.", getUrl);
-        try (CloseableHttpClient httpclient = buildHttpClient()) {
-            HttpGet httpGet = new HttpGet(getUrl);
-            try (CloseableHttpResponse resp = httpclient.execute(httpGet)) {
-                HttpEntity respEntity = resp.getEntity();
-                if (null == respEntity) {
-                    log.warn("Request failed with empty response.");
-                    return null;
-                }
-                return EntityUtils.toString(respEntity);
+    public String doHttpExecute(HttpClientBuilder clientBuilder, 
HttpRequestBase httpRequestBase)
+            throws IOException {
+        if (Objects.isNull(clientBuilder)) clientBuilder = 
getDefaultClientBuilder();
+        try (CloseableHttpClient client = clientBuilder.build()) {
+            try (CloseableHttpResponse response = 
client.execute(httpRequestBase)) {
+                return parseHttpResponse(response, 
httpRequestBase.getMethod());
             }
         }
     }
 
-    public Map<String, Object> doHttpGet(String getUrl, Map<String, String> 
header)
-            throws IOException {
-        log.info("Executing GET from {}.", getUrl);
-        try (CloseableHttpClient httpclient = HttpClients.createDefault()) {
-            HttpGet httpGet = new HttpGet(getUrl);
-            if (null != header) {
-                for (Map.Entry<String, String> entry : header.entrySet()) {
-                    httpGet.setHeader(entry.getKey(), 
String.valueOf(entry.getValue()));
-                }
-            }
-            try (CloseableHttpResponse resp = httpclient.execute(httpGet)) {
-                HttpEntity respEntity = getHttpEntity(resp);
-                if (null == respEntity) {
-                    log.warn("Request failed with empty response.");
-                    return null;
-                }
-                return JsonUtils.parseObject(EntityUtils.toString(respEntity), 
Map.class);
-            }
+    public String parseHttpResponse(CloseableHttpResponse response, String 
requestType)
+            throws StarRocksConnectorException {
+        int code = response.getStatusLine().getStatusCode();
+        if (307 == code) {

Review Comment:
   > Can you change the response code number to same meaning enum?
   Thanks, fixed it
   



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