wwj6591812 commented on code in PR #8219:
URL: https://github.com/apache/paimon/pull/8219#discussion_r3409252578


##########
paimon-api/src/main/java/org/apache/paimon/rest/HttpClientUtils.java:
##########
@@ -86,9 +88,61 @@ private static HttpClientConnectionManager 
configureConnectionManager() {
     public static InputStream getAsInputStream(String uri) throws IOException {
         HttpGet httpGet = new HttpGet(uri);
         CloseableHttpResponse response = DEFAULT_HTTP_CLIENT.execute(httpGet);
-        if (response.getCode() != 200) {
-            throw new RuntimeException("HTTP error code: " + 
response.getCode());
+        int statusCode = response.getCode();
+        if (statusCode != HttpStatus.SC_OK) {
+            throw httpError(statusCode);
         }
         return response.getEntity().getContent();
     }
+
+    /**
+     * Checks whether an HTTP resource exists. HEAD is attempted first; when 
the server does not
+     * support HEAD, a lightweight GET with {@code Range: bytes=0-0} is used 
as fallback.
+     */
+    public static boolean exists(String uri) throws IOException {
+        int statusCode = headStatusCode(uri);

Review Comment:
   @JingsongLi 
   
   Good point — making HEAD authoritative is unsafe for signed or GET-only URLs.
   
   I've updated exists() so that only a successful HEAD (200) returns true 
immediately. For any non-200 HEAD status (including 403/404, as well as 
405/501), we now fall back to a lightweight Range: bytes=0-0 GET and only 
return false when that GET also returns 404. Added tests for HEAD 404/403 with 
a readable range GET, and for HEAD 404 + GET 404.
   
   Thanks again for the careful review!



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