moonchen commented on code in PR #12655:
URL: https://github.com/apache/trafficserver/pull/12655#discussion_r2579017846


##########
src/proxy/http/HttpTunnel.cc:
##########
@@ -1028,7 +1028,18 @@ HttpTunnel::producer_run(HttpTunnelProducer *p)
         return;
       }
     } else {
-      body_bytes_copied  += sm->postbuf_copy_partial_data(body_bytes_to_copy);
+      int64_t bytes_to_copy_now = body_bytes_to_copy;
+
+      // For POST redirect buffering with HTTP_CLIENT producer, we need 
special handling.
+      // When POST data is pre-buffered (common for small POSTs), producer_n 
(ntodo) is 0,
+      // so body_bytes_to_copy calculated earlier would be 0. Instead, copy 
what's available,
+      // but limit it to the actual content length to avoid copying pipelined 
requests.
+      if (p->vc_type == HttpTunnelType_t::HTTP_CLIENT && 
sm->enable_redirection && body_bytes_to_copy == 0) {
+        int64_t bytes_available = p->buffer_start->read_avail();
+        bytes_to_copy_now       = (p->total_bytes >= 0) ? 
std::min(bytes_available, p->total_bytes) : bytes_available;

Review Comment:
   What would happen here if the POST request is chunked?  I think 
`p->total_bytes` is `INT64_MAX` so it would copy everything buffered from TLS, 
including possibly the next pipelined POST request?



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