Copilot commented on code in PR #13420:
URL: https://github.com/apache/trafficserver/pull/13420#discussion_r3647772045


##########
src/proxy/http2/Http2Stream.cc:
##########
@@ -830,15 +896,36 @@ Http2Stream::update_write_request(bool call_update)
 
   // Process the new data
   if (!this->parsing_header_done) {
-    // Still parsing the request or response header
     int         bytes_used = 0;
     ParseResult state;
-    if (this->is_outbound_connection()) {
+    // The SM's direct-passed header (request for an H2 origin, else 
response); not
+    // serialized, so there is nothing to parse.
+    HTTPHdr *send_hdr = this->_sm == nullptr           ? nullptr :
+                        this->is_outbound_connection() ? 
this->_sm->get_server_request_header() :
+                                                         
this->_sm->get_client_response_header();
+
+    if (send_hdr != nullptr) {
+      // Field-by-field, not copy(): copy() would wipe the create(HTTP_2_0) 
pseudos that the
+      // 1.1->2 conversion fills. The ready flag re-arms per header (1xx 
interim, retries).
+      if (this->is_outbound_connection()) {
+        this->_send_header.method_set(send_hdr->method_get());
+        this->_send_header.url_set(send_hdr->url_get());
+      } else {
+        this->_send_header.status_set(send_hdr->status_get());
+      }
+      for (auto &field : *send_hdr) {
+        MIMEField *f = this->_send_header.field_create(field.name_get());
+
+        f->value_set(this->_send_header.m_heap, this->_send_header.m_mime, 
field.value_get());
+        this->_send_header.field_attach(f);
+      }
+      this->_sm->clear_pending_send_header();
+      state = ParseResult::DONE;
+    } else if (this->is_outbound_connection()) {
       state = this->_send_header.parse_req(&http_parser, this->_send_reader, 
&bytes_used, false);
     } else {
-      state = this->_send_header.parse_resp(&http_parser, this->_send_reader, 
&bytes_used, false);
+      state = ParseResult::CONT;
     }

Review Comment:
   When there is no direct-passed SM header (send_hdr == nullptr) on an inbound 
stream, update_write_request() now sets state=ParseResult::CONT and never 
attempts to parse a serialized HTTP/1.1 response header from _send_reader. This 
breaks existing paths that still serialize response headers into the tunnel 
buffer (e.g., 100 Continue via HttpSM::setup_100_continue_transfer() writes 
into a buffer and expects Http2Stream to parse+convert it). Restore the 
parse_resp() fallback so interim/legacy serialized responses can still be 
emitted as HTTP/2 HEADERS frames.



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