This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 10.1.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
commit 158410dce411399bd2d19697579878de7480f7f1 Author: Mark Thomas <ma...@apache.org> AuthorDate: Thu Jul 4 14:15:50 2024 +0100 Refactor writing of the status code This refactoring is part of the preparation for RFC 8297 (Early Hints) support. --- java/org/apache/coyote/http11/Http11OutputBuffer.java | 14 +++++++++++++- java/org/apache/coyote/http11/Http11Processor.java | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java b/java/org/apache/coyote/http11/Http11OutputBuffer.java index 128f327cdb..2c51cdfb45 100644 --- a/java/org/apache/coyote/http11/Http11OutputBuffer.java +++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java @@ -320,14 +320,26 @@ public class Http11OutputBuffer implements HttpOutputBuffer { /** * Send the response status line. + * + * @deprecated Unused. Will be removed in Tomcat 11. Use {@link #sendStatus(int)}. */ + @Deprecated public void sendStatus() { + sendStatus(response.getStatus()); + } + + + /** + * Send the response status line. + * + * @param status The HTTP status code to include in the status line + */ + public void sendStatus(int status) { // Write protocol name write(Constants.HTTP_11_BYTES); headerBuffer.put(Constants.SP); // Write status code - int status = response.getStatus(); switch (status) { case 200: write(Constants._200_BYTES); diff --git a/java/org/apache/coyote/http11/Http11Processor.java b/java/org/apache/coyote/http11/Http11Processor.java index f1f3fb9501..cf872a09be 100644 --- a/java/org/apache/coyote/http11/Http11Processor.java +++ b/java/org/apache/coyote/http11/Http11Processor.java @@ -1039,7 +1039,7 @@ public class Http11Processor extends AbstractProcessor { // Build the response header try { - outputBuffer.sendStatus(); + outputBuffer.sendStatus(response.getStatus()); int size = headers.size(); for (int i = 0; i < size; i++) { @@ -1056,7 +1056,7 @@ public class Http11Processor extends AbstractProcessor { outputBuffer.resetHeaderBuffer(); // -1 as it will be incremented at the start of the loop and header indexes start at 0. i = -1; - outputBuffer.sendStatus(); + outputBuffer.sendStatus(response.getStatus()); } } outputBuffer.endHeaders(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org