poorbarcode commented on code in PR #19514:
URL: https://github.com/apache/pulsar/pull/19514#discussion_r1133045975


##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/WebServer.java:
##########
@@ -214,6 +218,13 @@ public void addServlet(String basePath, ServletHolder 
servletHolder,
         handlers.add(context);
     }
 
+    private static void popularServletParams(ServletHolder servletHolder, 
ProxyConfiguration config){
+        if (config.getHttpClientRequestBufferSize() > 0 || 
config.getHttpMaxRequestHeaderSize() > 0){
+            int v = Math.max(config.getHttpClientRequestBufferSize(), 
config.getHttpMaxRequestHeaderSize());
+            servletHolder.setInitParameter(INIT_PARAM_REQUEST_BUFFER_SIZE, 
String.valueOf(v));
+        }
+    }

Review Comment:
   Proxy handles HTTP requests like this: `pulsar-admin.sh` -> `proxy web 
server` -> `(highlight) internal client in proxy` -> `pulsar web server`.  
   
   When the internal client forwards a request, it forwards the request header 
and the request body, and all the data passes through a buffer( we call it Buf 
), like this:
   - Receive a request
   - Put the request line and request headers input to the Buf.
   - <strong>(highlight)</strong>Flush the Buf ( If the data in the request 
line and request header exceeds the length of the buf, an error is reported )
   - Put the request body input to the Buf.
   - Flush the Buf if it is full.
   
   So we need a config to set the `buff size` of the Buf: 
`pulsar-proxy.conf.httpClientRequestBufferSize` -> `buf size of the internal 
client`.
   And if `pulsar-proxy.conf.httpMaxRequestHeaderSize` is large than 
`pulsar-proxy.conf.httpClientRequestBufferSize`, the error in Step 3 above 
occurs, so we should set the size of Buf to 
`max(pulsar-proxy.conf.httpClientRequestBufferSize, 
pulsar-proxy.conf.httpMaxRequestHeaderSize)`



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