Copilot commented on code in PR #13420:
URL: https://github.com/apache/trafficserver/pull/13420#discussion_r3648274202
##########
src/proxy/http/HttpSM.cc:
##########
@@ -627,10 +627,23 @@ HttpSM::state_read_client_request_header(int event, void
*data)
// tokenize header //
/////////////////////
- ParseResult state = t_state.hdr_info.client_request.parse_req(&http_parser,
_ua.get_txn()->get_remote_reader(), &bytes_used,
-
_ua.get_entry()->eos, t_state.http_config_param->strict_uri_parsing,
-
t_state.http_config_param->http_request_line_max_size,
-
t_state.http_config_param->http_hdr_field_max_size);
+ ParseResult state;
+ ProxyTransaction *ua_txn = _ua.get_txn();
+
+ if (ua_txn->supports_direct_header_passing() &&
ua_txn->is_parsed_receive_header_ready()) {
+ // UA_FIRST_READ never fires on this path (the read buffer stays empty),
so stamp it here.
+ if (milestones[TS_MILESTONE_UA_FIRST_READ] == 0) {
+ ATS_PROBE1(milestone_ua_first_read, sm_id);
+ milestones[TS_MILESTONE_UA_FIRST_READ] = ink_get_hrtime();
+ }
+ t_state.hdr_info.client_request.copy(ua_txn->parsed_receive_header());
+ bytes_used = t_state.hdr_info.client_request.length_get();
+ state = ParseResult::DONE;
+ } else {
+ state = t_state.hdr_info.client_request.parse_req(
+ &http_parser, ua_txn->get_remote_reader(), &bytes_used,
_ua.get_entry()->eos, t_state.http_config_param->strict_uri_parsing,
+ t_state.http_config_param->http_request_line_max_size,
t_state.http_config_param->http_hdr_field_max_size);
+ }
client_request_hdr_bytes += bytes_used;
Review Comment:
On the direct-header-passing path, `bytes_used` is set to
`client_request.length_get()`. That value is later interpreted as a
parse-consumption/request-line length surrogate (e.g., to decide whether to use
`REQUEST_URI_TOO_LONG` in the ParseResult::ERROR path). If the request is
rejected due to `request_hdr_max_size`, this can incorrectly map an oversized
header set to a request-line-too-long error. Consider tracking header bytes
separately and leaving `bytes_used` as the parser-produced value (or 0 on the
fast path).
--
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]