You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@inlong.apache.org by "vernedeng (via GitHub)" <gi...@apache.org> on 2023/11/01 12:27:41 UTC

Re: [PR] [INLONG-8676][Manager] Elasticsearch - Modify the calling method from SDK to HTTP [inlong]

vernedeng commented on code in PR #9057:
URL: https://github.com/apache/inlong/pull/9057#discussion_r1378736172


##########
inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/util/HttpUtils.java:
##########
@@ -95,6 +95,24 @@ public static <T> T request(RestTemplate restTemplate, String url, HttpMethod me
         }
     }
 
+    /**
+     * Send HEAD request to the specified URL.
+     */
+    public static boolean headRequest(RestTemplate restTemplate, String url, Map<String, Object> params,
+            HttpHeaders header) {
+        ResponseEntity<String> exchange;
+        boolean result = false;
+        HttpEntity<String> request = new HttpEntity(params, header);
+        log.debug("send request to {}, param {}", url, params);
+        exchange = restTemplate.exchange(url, HttpMethod.HEAD, request, String.class);
+        HttpStatus statusCode = exchange.getStatusCode();
+        if (statusCode.is2xxSuccessful()) {
+            result = true;

Review Comment:
   ```suggestion
               result = statusCode.is2xxSuccessful()
   ```



-- 
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: commits-unsubscribe@inlong.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org