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


##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConfiguration.java:
##########
@@ -661,6 +661,29 @@ public class ProxyConfiguration implements 
PulsarConfiguration {
     )
     private int httpOutputBufferSize = 32 * 1024;
 
+    @FieldContext(
+        minValue = 1,
+        category = CATEGORY_HTTP,
+        doc = """
+                The maximum size in bytes of the request header.
+                Larger headers will allow for more and/or larger cookies plus 
larger form content encoded in a URL.
+                However, larger headers consume more memory and can make a 
server more vulnerable to denial of service
+                attacks.
+              """
+    )
+    private int httpMaxRequestHeaderSize = 8 * 1024;
+
+    @FieldContext(
+        minValue = 1,
+        category = CATEGORY_HTTP,
+        doc = """
+                 the size of the buffer used to write requests to Broker.
+                 if "httpMaxRequestHeaderSize" is large than 
"httpClientRequestBufferSize", will set
+                 "httpClientRequestBufferSize" to the value of 
"httpMaxRequestHeaderSize"
+              """
+    )
+    private int httpClientRequestBufferSize = 4096;

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)`
   
   same as the comment: 
https://github.com/apache/pulsar/pull/19514#discussion_r1133045975



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