Copilot commented on code in PR #3644:
URL: https://github.com/apache/brpc/pull/3644#discussion_r4366388843


##########
src/brpc/details/http_parser.cpp:
##########
@@ -1565,6 +1565,14 @@ size_t http_parser_execute (http_parser *parser,
         }
 
         if (ch == ':') {
+          if (parser->header_state == h_transfer_encoding) {
+            /* Multiple `Transfer-Encoding` headers are one list (RFC 7230
+             * 3.2.2), so `chunked` from an earlier line is no longer final.
+             * Clear it here rather than at value start so that an empty
+             * value also resets it.
+             */
+            parser->flags &= ~F_CHUNKED;

Review Comment:
   Clearing `F_CHUNKED` at the colon also clears it for an empty repeated 
field, although RFC 7230 §7 requires recipients to ignore a reasonable number 
of empty list elements. A `Transfer-Encoding: chunked` line followed by 
`Transfer-Encoding:` therefore incorrectly rejects requests and makes 
corresponding keep-alive responses wait for EOF instead of completing at the 
terminating chunk. Move the reset to nonempty-value processing and change the 
empty-field expectation in `test/brpc_http_message_unittest.cpp:532–538` to 
preserve chunked framing.



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