FrankChen021 commented on code in PR #20152:
URL: https://github.com/apache/druid/pull/20152#discussion_r3880821225


##########
server/src/main/java/org/apache/druid/client/DirectDruidClient.java:
##########
@@ -243,6 +244,70 @@ public ClientResponse<InputStream> 
handleResponse(HttpResponse response, Traffic
         {
           trafficCopRef.set(trafficCop);
           checkQueryTimeout();
+          // Handle 429/503 HTML before JSON parse to avoid JsonParseException 
0x3c ('<')
+          final int statusCode = response.getStatus().getCode();
+          final String contentType = 
response.headers().get(HttpHeaders.Names.CONTENT_TYPE);
+          final ChannelBuffer contentBuffer = response.getContent();
+          boolean isHtmlContentType = contentType != null && 
StringUtils.toLowerCase(contentType).contains("text/html");
+          boolean isHtmlBody = false;
+          if (contentBuffer.readableBytes() > 0) {

Review Comment:
   [P2] Chunked HTML can bypass prefix sniffing
   
   handleResponse inspects only the initial response buffer, but later chunked 
bytes reach handleChunk without persistent classification. A chunked 503 HTML 
response whose first buffer is empty or lacks the identifying prefix can 
therefore reach JsonParserIterator and fail as a JSON parse error instead of 
producing the intended capacity error. Carry the sniff state across chunks or 
buffer and classify the prefix before handing the stream to the parser.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to