Chenjp commented on code in PR #784:
URL: https://github.com/apache/tomcat/pull/784#discussion_r1853796379


##########
java/org/apache/coyote/http2/Stream.java:
##########
@@ -604,10 +611,23 @@ final void writeAck() throws IOException {
     final void writeEarlyHints() throws IOException {
         MimeHeaders headers = coyoteResponse.getMimeHeaders();
         String originalStatus = headers.getHeader(":status");
-        headers.setValue(":status").setString("103");
+        
headers.setValue(":status").setString(String.valueOf(HttpServletResponse.SC_EARLY_HINTS));
+
         try {
-            handler.writeHeaders(this, headers, false, 
Constants.DEFAULT_HEADERS_FRAME_SIZE);
+            MimeHeaders earlyHintsHeaders = new MimeHeaders();
+            earlyHintsHeaders.duplicate(headers);
+            earlyHintsHeaders.filter(HTTP_EARLY_HINTS_HEADERS);

Review Comment:
   see [Nginx early hints 
behavior](https://github.com/nginx-modules/ngx_http_early_hints) , those 
headers were lost in the final response.
   
   Rfc 8297 original text as follows:
   Typically, a server will include the header fields sent in a 103
      (Early Hints) response in the final response as well.  However, there
      might be cases when this is not desirable, such as when the server
      learns that the header fields in the 103 (Early Hints) response are
      not correct before the final response is sent.
   
      A client can speculatively evaluate the header fields included in a
      103 (Early Hints) response while waiting for the final response.  For
      example, a client might recognize a Link header field value
      containing the relation type "preload" and start fetching the target
      resource.  However, these header fields only provide hints to the
      client; they do not replace the header fields on the final response.
   
      Aside from performance optimizations, such evaluation of the 103
      (Early Hints) response's header fields MUST NOT affect how the final
      response is processed.  A client MUST NOT interpret the 103 (Early
      Hints) response header fields as if they applied to the informational
      response itself (e.g., as metadata about the 103 (Early Hints)
      response).
   



-- 
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: dev-unsubscr...@tomcat.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to