markt-asf commented on code in PR #785:
URL: https://github.com/apache/tomcat/pull/785#discussion_r1853737908
##########
java/org/apache/coyote/http11/Http11Processor.java:
##########
@@ -1250,8 +1255,19 @@ protected final void ack(ContinueResponseTiming
continueResponseTiming) {
@Override
protected void earlyHints() throws IOException {
- writeHeaders(103, response.getMimeHeaders());
+ MimeHeaders earlyHintsHeaders = new MimeHeaders();
+ earlyHintsHeaders.duplicate(response.getMimeHeaders());
+ earlyHintsHeaders.filter(HTTP_EARLY_HINTS_HEADERS);
+ writeHeaders(HttpServletResponse.SC_EARLY_HINTS, earlyHintsHeaders);
+ // Once early hints emitted, clean up early hints relative headers.
+ // The final response is responsible for resetting Link/CSP/etc
related headers
+ for (String header : HTTP_EARLY_HINTS_HEADERS) {
+ response.getMimeHeaders().removeHeader(header);
+ }
Review Comment:
No need to duplicate MimeHeaders. No need to remove headers after sending
103.
##########
java/org/apache/coyote/http11/Http11Processor.java:
##########
@@ -1250,8 +1255,19 @@ protected final void ack(ContinueResponseTiming
continueResponseTiming) {
@Override
protected void earlyHints() throws IOException {
- writeHeaders(103, response.getMimeHeaders());
+ MimeHeaders earlyHintsHeaders = new MimeHeaders();
+ earlyHintsHeaders.duplicate(response.getMimeHeaders());
+ earlyHintsHeaders.filter(HTTP_EARLY_HINTS_HEADERS);
+ writeHeaders(HttpServletResponse.SC_EARLY_HINTS, earlyHintsHeaders);
+ // Once early hints emitted, clean up early hints relative headers.
+ // The final response is responsible for resetting Link/CSP/etc
related headers
+ for (String header : HTTP_EARLY_HINTS_HEADERS) {
+ response.getMimeHeaders().removeHeader(header);
+ }
outputBuffer.writeHeaders();
+ // to take advantage of the Early Hints feature, the server-think-time
is needed between the Early Hints
+ // headers and the final response. Therefore, we need emit early hints
status and headers via flush.
+ outputBuffer.flush();
Review Comment:
No need to flush.
##########
java/org/apache/coyote/http11/Http11Processor.java:
##########
@@ -1250,8 +1255,19 @@ protected final void ack(ContinueResponseTiming
continueResponseTiming) {
@Override
protected void earlyHints() throws IOException {
- writeHeaders(103, response.getMimeHeaders());
+ MimeHeaders earlyHintsHeaders = new MimeHeaders();
+ earlyHintsHeaders.duplicate(response.getMimeHeaders());
+ earlyHintsHeaders.filter(HTTP_EARLY_HINTS_HEADERS);
+ writeHeaders(HttpServletResponse.SC_EARLY_HINTS, earlyHintsHeaders);
Review Comment:
I do support the use of a constant here.
--
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]