[Bug 69208] New: Submit report bug

2024-07-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69208

Bug ID: 69208
   Summary: Submit report bug
   Product: Tomcat Native
   Version: 2.0.6
  Hardware: PC
Status: NEW
  Severity: normal
  Priority: P2
 Component: Library
  Assignee: dev@tomcat.apache.org
  Reporter: gardeniaestatesprest...@gmail.com
  Target Milestone: ---

submit bug

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 69208] Submit report bug

2024-07-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69208

gardeniaestates  changed:

   What|Removed |Added

URL||https://www.prestigegardeni
   ||aestates.live/
 OS||All

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 69208] SPAM SPAM SPAM SPAM

2024-07-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=69208

Chuck Caldarale  changed:

   What|Removed |Added

 Resolution|--- |INVALID
URL|https://www.prestigegardeni |
   |aestates.live/  |
 Status|NEW |RESOLVED
Summary|Submit report bug   |SPAM SPAM SPAM SPAM

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) branch 9.0.x updated: Sync default server.xml with 10.1

2024-07-19 Thread remm
This is an automated email from the ASF dual-hosted git repository.

remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
 new b260f051df Sync default server.xml with 10.1
b260f051df is described below

commit b260f051df4e85716b54e203b4d9eaf47aaee6d9
Author: remm 
AuthorDate: Fri Jul 19 14:45:22 2024 +0200

Sync default server.xml with 10.1
---
 conf/server.xml | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/conf/server.xml b/conf/server.xml
index ee964fea2a..1be01d5859 100644
--- a/conf/server.xml
+++ b/conf/server.xml
@@ -24,8 +24,10 @@
   
-  
-  
+  
+  
+  
+  
   
   
   


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



[Bug 56596] OpenSSL 1.0.1g is vulnerable to a man-in-the-middle attack

2024-07-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56596

--- Comment #18 from pooop  ---
https://www.dailymotion.com/video/x92hf1k

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 56596] OpenSSL 1.0.1g is vulnerable to a man-in-the-middle attack

2024-07-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=56596

--- Comment #19 from pooop  ---
https://dai.ly/k6Z7J0dS0q4eLSB6Tqw

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



[Bug 63362] GlobalRequestProcessor statistics in MBean does not count Websocket communication

2024-07-19 Thread bugzilla
https://bz.apache.org/bugzilla/show_bug.cgi?id=63362

--- Comment #9 from pooop  ---
https://dai.ly/k6Z7J0dS0q4eLSB6Tqw

-- 
You are receiving this mail because:
You are the assignee for the bug.
-
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org



(tomcat) 01/09: Rename method that performs commit to commit()

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3a1659ebe6a9afc7aa771ee594680a4b57620812
Author: Mark Thomas 
AuthorDate: Thu Jul 4 13:50:37 2024 +0100

Rename method that performs commit to commit()

This refactoring is in preparation for RFC 8293 (Early Hints) support.
That will introduce a method that writes headers without a commit. This
rename will reduce potential confusion between writeHeaders() and
sendHeaders().
---
 java/org/apache/catalina/connector/OutputBuffer.java |  2 +-
 java/org/apache/coyote/Response.java | 11 +++
 java/org/apache/coyote/http2/Http2OutputBuffer.java  |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java 
b/java/org/apache/catalina/connector/OutputBuffer.java
index 03b6737af6..b185561ef3 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -270,7 +270,7 @@ public class OutputBuffer extends Writer {
 try {
 doFlush = true;
 if (initial) {
-coyoteResponse.sendHeaders();
+coyoteResponse.commit();
 initial = false;
 }
 if (cb.remaining() > 0) {
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index 118aa92917..ca89a1afca 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -447,8 +447,19 @@ public final class Response {
 
 /**
  * Signal that we're done with the headers, and body will follow.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11 onwards. Use {@link 
#commit()}.
  */
+@Deprecated
 public void sendHeaders() {
+commit();
+}
+
+
+/**
+ * Signal that we're done with the headers, and body will follow.
+ */
+public void commit() {
 action(ActionCode.COMMIT, this);
 setCommitted(true);
 }
diff --git a/java/org/apache/coyote/http2/Http2OutputBuffer.java 
b/java/org/apache/coyote/http2/Http2OutputBuffer.java
index 1de4569900..3d4d6b96c5 100644
--- a/java/org/apache/coyote/http2/Http2OutputBuffer.java
+++ b/java/org/apache/coyote/http2/Http2OutputBuffer.java
@@ -52,7 +52,7 @@ public class Http2OutputBuffer implements HttpOutputBuffer {
 @Override
 public int doWrite(ByteBuffer chunk) throws IOException {
 if (!coyoteResponse.isCommitted()) {
-coyoteResponse.sendHeaders();
+coyoteResponse.commit();
 }
 return next.doWrite(chunk);
 }


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



(tomcat) branch main updated (ebd5cae558 -> 809548fd8a)

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from ebd5cae558 Fix warning
 new 3a1659ebe6 Rename method that performs commit to commit()
 new 9dba4efc0f Remove deprecated code
 new ff7a869fd2 Refactor writing of the status code
 new 2d939ecf4c Refactoring writing of HTTP headers to separate method
 new 3f37960753 Implement early hints for HTTP/1.1
 new 26a9aef3e4 Remove deprecated code
 new d4db19dabf AJP doesn't support 1xx responses.
 new 73df9bd7d9 Add HTTP/2 support for early hints
 new 809548fd8a Add a changelog entry

The 9 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/catalina/connector/OutputBuffer.java|  2 +-
 java/org/apache/catalina/connector/Response.java   | 14 +
 .../apache/catalina/connector/ResponseFacade.java  |  4 ++
 java/org/apache/coyote/AbstractProcessor.java  | 11 
 java/org/apache/coyote/ActionCode.java |  7 ++-
 java/org/apache/coyote/Response.java   |  2 +-
 java/org/apache/coyote/ajp/AjpProcessor.java   |  6 ++
 .../apache/coyote/http11/Http11OutputBuffer.java   |  8 ++-
 java/org/apache/coyote/http11/Http11Processor.java | 23 ++--
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  2 +-
 java/org/apache/coyote/http2/Stream.java   | 16 ++
 java/org/apache/coyote/http2/StreamProcessor.java  |  6 ++
 .../apache/coyote/http11/TestHttp11Processor.java  | 49 
 .../apache/coyote/http2/TestStreamProcessor.java   | 67 ++
 webapps/docs/changelog.xml | 12 
 15 files changed, 218 insertions(+), 11 deletions(-)


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



(tomcat) 07/09: AJP doesn't support 1xx responses.

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit d4db19dabf59b2696f10149a4df106c14607db7b
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:09:33 2024 +0100

AJP doesn't support 1xx responses.
---
 java/org/apache/coyote/ajp/AjpProcessor.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index 9563c2b592..8df1960e10 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1059,8 +1059,7 @@ public class AjpProcessor extends AbstractProcessor {
 
 @Override
 protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+// NO-OP for AJP
 }
 
 


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



(tomcat) 04/09: Refactoring writing of HTTP headers to separate method

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 2d939ecf4ce214281d6f3db41a6c98fb8134cc47
Author: Mark Thomas 
AuthorDate: Thu Jul 4 14:18:16 2024 +0100

Refactoring writing of HTTP headers to separate method

This in preparation for RFC 8297 (Early Hints) support that will need to
write the current headers without committing the response.
---
 java/org/apache/coyote/http11/Http11Processor.java | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index f6f34e8f45..dac9e8e419 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1035,9 +1035,15 @@ public class Http11Processor extends AbstractProcessor {
 headers.removeHeader("transfer-encoding");
 }
 
-// Build the response header
+writeHeaders(response.getStatus(), headers);
+
+outputBuffer.commit();
+}
+
+
+private void writeHeaders(int status, MimeHeaders headers) {
 try {
-outputBuffer.sendStatus(response.getStatus());
+outputBuffer.sendStatus(status);
 
 int size = headers.size();
 for (int i = 0; i < size; i++) {
@@ -1054,7 +1060,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(response.getStatus());
+outputBuffer.sendStatus(status);
 }
 }
 outputBuffer.endHeaders();
@@ -1065,10 +1071,9 @@ public class Http11Processor extends AbstractProcessor {
 outputBuffer.resetHeaderBuffer();
 throw t;
 }
-
-outputBuffer.commit();
 }
 
+
 private static boolean isConnectionToken(MimeHeaders headers, String 
token) throws IOException {
 MessageBytes connection = headers.getValue(Constants.CONNECTION);
 if (connection == null) {


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



(tomcat) 03/09: Refactor writing of the status code

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit ff7a869fd203b3b60ffd699c47da1d07e77f0c3a
Author: Mark Thomas 
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 be7955c1b0..76fdb0d126 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 681db0e96b..f6f34e8f45 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1037,7 +1037,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++) {
@@ -1054,7 +1054,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



(tomcat) 05/09: Implement early hints for HTTP/1.1

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 3f37960753a54e9cd500268c05f117ca1701e5d6
Author: Mark Thomas 
AuthorDate: Thu Jul 4 15:48:18 2024 +0100

Implement early hints for HTTP/1.1
---
 java/org/apache/catalina/connector/Response.java   | 14 +++
 .../apache/catalina/connector/ResponseFacade.java  |  4 ++
 java/org/apache/coyote/AbstractProcessor.java  | 11 +
 java/org/apache/coyote/ActionCode.java |  7 +++-
 java/org/apache/coyote/ajp/AjpProcessor.java   |  7 
 .../apache/coyote/http11/Http11OutputBuffer.java   |  3 ++
 java/org/apache/coyote/http11/Http11Processor.java |  8 
 java/org/apache/coyote/http2/StreamProcessor.java  |  7 
 .../apache/coyote/http11/TestHttp11Processor.java  | 49 ++
 9 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index 21fc8f1138..66dd7cab47 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1037,6 +1037,20 @@ public class Response implements HttpServletResponse {
 }
 
 
+public void sendEarlyHints() {
+if (isCommitted()) {
+return;
+}
+
+// Ignore any call from an included servlet
+if (included) {
+return;
+}
+
+getCoyoteResponse().action(ActionCode.EARLY_HINTS, null);
+}
+
+
 @Override
 public void sendError(int status) throws IOException {
 sendError(status, null);
diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index b09b4731a8..dcc4ee059d 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -245,6 +245,10 @@ public class ResponseFacade implements HttpServletResponse 
{
 }
 
 
+public void sendEarlyHints() {
+response.sendEarlyHints();
+}
+
 @Override
 public void sendError(int sc, String msg) throws IOException {
 checkCommitted("coyoteResponse.sendError.ise");
diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 21a7ef2304..30e4e12bd5 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -393,6 +393,14 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 ack((ContinueResponseTiming) param);
 break;
 }
+case EARLY_HINTS: {
+try {
+earlyHints();
+} catch (IOException e) {
+handleIOException(e);
+}
+break;
+}
 case CLIENT_FLUSH: {
 action(ActionCode.COMMIT, null);
 try {
@@ -734,6 +742,9 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 protected abstract void ack(ContinueResponseTiming continueResponseTiming);
 
 
+protected abstract void earlyHints() throws IOException;
+
+
 /**
  * Callback to write data from the buffer.
  * @throws IOException IO exception during the write
diff --git a/java/org/apache/coyote/ActionCode.java 
b/java/org/apache/coyote/ActionCode.java
index 15531f7c39..2b233fb82c 100644
--- a/java/org/apache/coyote/ActionCode.java
+++ b/java/org/apache/coyote/ActionCode.java
@@ -265,5 +265,10 @@ public enum ActionCode {
 /**
  * Obtain the servlet connection instance for the network connection 
supporting the current request.
  */
-SERVLET_CONNECTION
+SERVLET_CONNECTION,
+
+/**
+ * Send an RFC 8297 Early Hints informational response.
+ */
+EARLY_HINTS
 }
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index 1c568b05aa..9563c2b592 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1057,6 +1057,13 @@ public class AjpProcessor extends AbstractProcessor {
 }
 
 
+@Override
+protected void earlyHints() throws IOException {
+// TODO Auto-generated method stub
+// NO-OP for now
+}
+
+
 @Override
 protected final int available(boolean doRead) {
 if (endOfStream) {
diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java 
b/java/org/apache/coyote/http11/Http11OutputBuffer.java
index 76fdb0d126..07381f1b50 100644
--- a/java/org/apache/coyote/http11/Http11OutputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java
@@ -300,7 +300,10 @@ public class Http11OutputBuffer implements 
HttpOutputBuffer {
  */
 protected void commit() throws IOException {
 

(tomcat) 02/09: Remove deprecated code

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 9dba4efc0f0f878076d3bfe113366c047c600b0d
Author: Mark Thomas 
AuthorDate: Thu Jul 4 13:50:56 2024 +0100

Remove deprecated code
---
 java/org/apache/coyote/Response.java | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index ca89a1afca..cdc15a854e 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -445,17 +445,6 @@ public final class Response {
 }
 
 
-/**
- * Signal that we're done with the headers, and body will follow.
- *
- * @deprecated Unused. Will be removed in Tomcat 11 onwards. Use {@link 
#commit()}.
- */
-@Deprecated
-public void sendHeaders() {
-commit();
-}
-
-
 /**
  * Signal that we're done with the headers, and body will follow.
  */


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



(tomcat) 06/09: Remove deprecated code

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 26a9aef3e4f7f91d449e07202c365473279ac332
Author: Mark Thomas 
AuthorDate: Thu Jul 4 15:49:19 2024 +0100

Remove deprecated code
---
 java/org/apache/coyote/http11/Http11OutputBuffer.java | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java 
b/java/org/apache/coyote/http11/Http11OutputBuffer.java
index 07381f1b50..bd1a66730f 100644
--- a/java/org/apache/coyote/http11/Http11OutputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java
@@ -321,17 +321,6 @@ 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.
  *


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



(tomcat) 09/09: Add a changelog entry

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 809548fd8a3157735ef867675ccd726320f52349
Author: Mark Thomas 
AuthorDate: Fri Jul 19 12:44:17 2024 +0100

Add a changelog entry
---
 webapps/docs/changelog.xml | 12 
 1 file changed, 12 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 944d0bfaf3..0fa7268704 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,18 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Add support for RFC 8297 (Early Hints). Applications can use this
+feature by casting the HttpServletResponse to
+org.apache.catalina.connector.Reponse and then calling the
+method void sendEarlyHints(). This method will be added to
+the Servlet API (removing the need for the cast) in Servlet 6.2 
onwards.
+(markt)
+  
+
+  
   
 
   


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



(tomcat) 08/09: Add HTTP/2 support for early hints

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 73df9bd7d98ef3a562ccdb67403f6d29a2ff185c
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:53:21 2024 +0100

Add HTTP/2 support for early hints
---
 java/org/apache/coyote/http2/Stream.java   | 16 ++
 java/org/apache/coyote/http2/StreamProcessor.java  |  3 +-
 .../apache/coyote/http2/TestStreamProcessor.java   | 67 ++
 3 files changed, 84 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index f8e80be5b8..923f7c9c9c 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -590,6 +590,22 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+final void writeEarlyHints() throws IOException {
+MimeHeaders headers = coyoteResponse.getMimeHeaders();
+String originalStatus = headers.getHeader(":status");
+headers.setValue(":status").setString("103");
+try {
+handler.writeHeaders(this, headers, false, 
Constants.DEFAULT_HEADERS_FRAME_SIZE);
+} finally {
+if (originalStatus == null) {
+headers.removeHeader(":status");
+} else {
+headers.setValue(":status").setString(originalStatus);
+}
+}
+}
+
+
 @Override
 final String getConnectionId() {
 return handler.getConnectionId();
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index c99a1691b7..89a6116854 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -270,8 +270,7 @@ class StreamProcessor extends AbstractProcessor {
 
 @Override
 protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+stream.writeEarlyHints();
 }
 
 
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index ac362c6e30..4208ff5954 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -21,6 +21,7 @@ import java.io.IOException;
 import java.io.OutputStream;
 import java.io.PrintWriter;
 import java.nio.ByteBuffer;
+import java.nio.charset.StandardCharsets;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -36,6 +37,7 @@ import org.junit.Test;
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.ResponseFacade;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.tomcat.util.compat.JrePlatform;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -586,4 +588,69 @@ public class TestStreamProcessor extends Http2TestBase {
 String trace = output.getTrace();
 Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[501]"));
 }
+
+
+@Test
+public void testEarlyHints() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+Context ctxt = getProgrammaticRootContext();
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "ehs", new EarlyHintsServlet());
+ctxt.addServletMappingDecoded("/ehs", "ehs");
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+// Disable overhead protection for window update as it breaks some 
tests
+http2Protocol.setOverheadWindowUpdateThreshold(0);
+
+byte[] headersFrameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+buildGetRequest(headersFrameHeader, headersPayload, null, 3, "/ehs");
+
+// Write the headers
+writeFrame(headersFrameHeader, headersPayload);
+
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[103]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n" + 
"3-HeadersEnd\n", output.getTrace());
+output.clearTrace();
+
+parser.readFrame();
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n" +
+"3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
+"3-Header-[content-length]-[2]\n" +
+"3-Header-[date]-[" + DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" 
+ "3-Body-2\n" + "3-EndOfStream\n",
+output.getTrace());
+}
+
+
+private s

(tomcat) branch 10.1.x updated: Refactor SimpleHTTPClient to read body as-is rather than via readLine()

2024-07-19 Thread markt
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


The following commit(s) were added to refs/heads/10.1.x by this push:
 new f631975606 Refactor SimpleHTTPClient to read body as-is rather than 
via readLine()
f631975606 is described below

commit f631975606dc2d8e8a77cc61bfa96930d928b009
Author: Mark Thomas 
AuthorDate: Thu Jun 22 17:08:02 2023 +0100

Refactor SimpleHTTPClient to read body as-is rather than via readLine()

Update impacted tests so they still pass
---
 test/org/apache/catalina/core/TestStandardContext.java   |  2 +-
 test/org/apache/catalina/startup/SimpleHttpClient.java   | 16 
 test/org/apache/coyote/http11/TestHttp11InputBuffer.java |  2 +-
 test/org/apache/coyote/http11/TestHttp11Processor.java   |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/test/org/apache/catalina/core/TestStandardContext.java 
b/test/org/apache/catalina/core/TestStandardContext.java
index aa92e22a58..9070963476 100644
--- a/test/org/apache/catalina/core/TestStandardContext.java
+++ b/test/org/apache/catalina/core/TestStandardContext.java
@@ -704,7 +704,7 @@ public class TestStandardContext extends TomcatBaseTest {
 
 PrintWriter out = resp.getWriter();
 
-out.println("parts=" + (null == req.getParts()
+out.print("parts=" + (null == req.getParts()
 ? "null"
 : Integer.valueOf(req.getParts().size(;
 }
diff --git a/test/org/apache/catalina/startup/SimpleHttpClient.java 
b/test/org/apache/catalina/startup/SimpleHttpClient.java
index bc47ada2b0..00943970d5 100644
--- a/test/org/apache/catalina/startup/SimpleHttpClient.java
+++ b/test/org/apache/catalina/startup/SimpleHttpClient.java
@@ -150,6 +150,13 @@ public abstract class SimpleHttpClient {
 return responseLine;
 }
 
+public int getStatusCode() {
+if (responseLine.length() < 13) {
+throw new IllegalStateException();
+}
+return Integer.parseInt(responseLine.substring(9, 12));
+}
+
 public List getResponseHeaders() {
 return responseHeaders;
 }
@@ -326,11 +333,12 @@ public abstract class SimpleHttpClient {
 builder.append(body, 0 , read);
 Assert.assertEquals(contentLength, 
builder.toString().getBytes(responseBodyEncoding).length);
 } else {
-// not using content length, so just read it line by line
-String line = null;
+// Not using content length, so just read until EOF
+char[] buf = new char[1024];
+int read;
 try {
-while ((line = readLine()) != null) {
-builder.append(line);
+while ((read = reader.read(buf)) != -1) {
+builder.append(buf, 0, read);
 }
 } catch (SocketException e) {
 // Ignore
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java 
b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
index 9796330d43..2a01bdd2cc 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
@@ -379,7 +379,7 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
 private void processHeaders(String header, HttpServletRequest req, 
PrintWriter out) {
 Enumeration values = req.getHeaders(header);
 while (values.hasMoreElements()) {
-out.println(values.nextElement());
+out.print(values.nextElement());
 }
 }
 }
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index 65b2015c71..857d51185d 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -105,7 +105,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 // There should not be an end chunk
 Assert.assertFalse(client.getResponseBody().endsWith("0"));
 // The last portion of text should be there
-Assert.assertTrue(client.getResponseBody().endsWith("line03"));
+Assert.assertTrue(client.getResponseBody().endsWith("line03" + 
SimpleHttpClient.CRLF));
 }
 
 private static class ResponseWithErrorServlet extends HttpServlet {


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



Re: Short and long term plans for Tomcat Native

2024-07-19 Thread Koteswararao Gundapaneni
Hi Mark


Do we need the app is maintained or to be noticed

On Wed, 17 Jul 2024, 21:04 Mark Thomas,  wrote:

> All,
>
> I've spent some time today trying to build Tomcat Native with Visual
> Studio 2022 rather then the current, more involved process without success.
>
> Therefore, my short-term plan for Tomcat Native is to get the next 2.0.x
> and 1.3.x releases completed using the existing build process. I'll be
> starting that shortly.
>
> Longer term, thinking about Tomcat Native and FFM I have the following
> rough plan in mind:
>
> - stop providing x86 binaries for Windows
> - require Windows 10 onwards
> - provide:
>- libssl.dll
>- libcrypto.dll
>- tomcat-native-2.dll
>- openssl.exe
>
> along with appropriate debug symbols.
>
> I'm not sure if we'd need an apr.dll in there as well.
>
> The idea is that users can then use either the AprLifecycleListener or
> OpenSSLLifecycleListener.
>
> This would probably require moving Tomcat Native to 2.1.x and 1.4.x
>
> This really needs someone more familiar with building C libraries
> generally and these libraries in particular - i.e. Mladen - to say
> whether the above is possible and to provide some pointers on how to do it.
>
> Mark
>
> -
> To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
> For additional commands, e-mail: dev-h...@tomcat.apache.org
>
>


(tomcat) branch 10.1.x updated (f631975606 -> 6df40af33c)

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 10.1.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from f631975606 Refactor SimpleHTTPClient to read body as-is rather than 
via readLine()
 new 95ea8ac12f Rename method that performs commit to commit()
 new 158410dce4 Refactor writing of the status code
 new 573560e980 Refactoring writing of HTTP headers to separate method
 new 2922f53f7d Implement early hints for HTTP/1.1
 new 67cbac5094 AJP doesn't support 1xx responses.
 new ae22fadba4 Add HTTP/2 support for early hints
 new 6df40af33c Add a changelog entry

The 7 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/catalina/connector/OutputBuffer.java|  2 +-
 java/org/apache/catalina/connector/Response.java   | 14 +
 .../apache/catalina/connector/ResponseFacade.java  |  4 ++
 java/org/apache/coyote/AbstractProcessor.java  | 11 
 java/org/apache/coyote/ActionCode.java |  7 ++-
 java/org/apache/coyote/Response.java   | 11 
 java/org/apache/coyote/ajp/AjpProcessor.java   |  6 ++
 .../apache/coyote/http11/Http11OutputBuffer.java   | 17 +-
 java/org/apache/coyote/http11/Http11Processor.java | 23 ++--
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  2 +-
 java/org/apache/coyote/http2/Stream.java   | 16 ++
 java/org/apache/coyote/http2/StreamProcessor.java  |  6 ++
 .../apache/coyote/http11/TestHttp11Processor.java  | 49 
 .../apache/coyote/http2/TestStreamProcessor.java   | 66 ++
 webapps/docs/changelog.xml | 12 
 15 files changed, 237 insertions(+), 9 deletions(-)


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



(tomcat) 01/07: Rename method that performs commit to commit()

2024-07-19 Thread markt
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 95ea8ac12f5df68ae7df273372766e344548d515
Author: Mark Thomas 
AuthorDate: Thu Jul 4 13:50:37 2024 +0100

Rename method that performs commit to commit()

This refactoring is in preparation for RFC 8293 (Early Hints) support.
That will introduce a method that writes headers without a commit. This
rename will reduce potential confusion between writeHeaders() and
sendHeaders().
---
 java/org/apache/catalina/connector/OutputBuffer.java |  2 +-
 java/org/apache/coyote/Response.java | 11 +++
 java/org/apache/coyote/http2/Http2OutputBuffer.java  |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java 
b/java/org/apache/catalina/connector/OutputBuffer.java
index de6dbd35fd..ede9343c65 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -282,7 +282,7 @@ public class OutputBuffer extends Writer {
 try {
 doFlush = true;
 if (initial) {
-coyoteResponse.sendHeaders();
+coyoteResponse.commit();
 initial = false;
 }
 if (cb.remaining() > 0) {
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index a7eddfd7ff..01815ce936 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -448,8 +448,19 @@ public final class Response {
 
 /**
  * Signal that we're done with the headers, and body will follow.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11 onwards. Use {@link 
#commit()}.
  */
+@Deprecated
 public void sendHeaders() {
+commit();
+}
+
+
+/**
+ * Signal that we're done with the headers, and body will follow.
+ */
+public void commit() {
 action(ActionCode.COMMIT, this);
 setCommitted(true);
 }
diff --git a/java/org/apache/coyote/http2/Http2OutputBuffer.java 
b/java/org/apache/coyote/http2/Http2OutputBuffer.java
index 1de4569900..3d4d6b96c5 100644
--- a/java/org/apache/coyote/http2/Http2OutputBuffer.java
+++ b/java/org/apache/coyote/http2/Http2OutputBuffer.java
@@ -52,7 +52,7 @@ public class Http2OutputBuffer implements HttpOutputBuffer {
 @Override
 public int doWrite(ByteBuffer chunk) throws IOException {
 if (!coyoteResponse.isCommitted()) {
-coyoteResponse.sendHeaders();
+coyoteResponse.commit();
 }
 return next.doWrite(chunk);
 }


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



(tomcat) 04/07: Implement early hints for HTTP/1.1

2024-07-19 Thread markt
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 2922f53f7d2257b30c009fbda7d1817c549ef59c
Author: Mark Thomas 
AuthorDate: Thu Jul 4 15:48:18 2024 +0100

Implement early hints for HTTP/1.1
---
 java/org/apache/catalina/connector/Response.java   | 14 +++
 .../apache/catalina/connector/ResponseFacade.java  |  4 ++
 java/org/apache/coyote/AbstractProcessor.java  | 11 +
 java/org/apache/coyote/ActionCode.java |  7 +++-
 java/org/apache/coyote/ajp/AjpProcessor.java   |  7 
 .../apache/coyote/http11/Http11OutputBuffer.java   |  3 ++
 java/org/apache/coyote/http11/Http11Processor.java |  8 
 java/org/apache/coyote/http2/StreamProcessor.java  |  7 
 .../apache/coyote/http11/TestHttp11Processor.java  | 49 ++
 9 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index b5906ed7f8..44a94ace51 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1061,6 +1061,20 @@ public class Response implements HttpServletResponse {
 }
 
 
+public void sendEarlyHints() {
+if (isCommitted()) {
+return;
+}
+
+// Ignore any call from an included servlet
+if (included) {
+return;
+}
+
+getCoyoteResponse().action(ActionCode.EARLY_HINTS, null);
+}
+
+
 @Override
 public void sendError(int status) throws IOException {
 sendError(status, null);
diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 5ad4c0778b..8bed33742c 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -324,6 +324,10 @@ public class ResponseFacade implements HttpServletResponse 
{
 }
 
 
+public void sendEarlyHints() {
+response.sendEarlyHints();
+}
+
 @Override
 public void sendError(int sc, String msg) throws IOException {
 checkCommitted("coyoteResponse.sendError.ise");
diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 49a7882712..8a731014bd 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -394,6 +394,14 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 ack((ContinueResponseTiming) param);
 break;
 }
+case EARLY_HINTS: {
+try {
+earlyHints();
+} catch (IOException e) {
+handleIOException(e);
+}
+break;
+}
 case CLIENT_FLUSH: {
 action(ActionCode.COMMIT, null);
 try {
@@ -742,6 +750,9 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 protected abstract void ack(ContinueResponseTiming continueResponseTiming);
 
 
+protected abstract void earlyHints() throws IOException;
+
+
 /**
  * Callback to write data from the buffer.
  * @throws IOException IO exception during the write
diff --git a/java/org/apache/coyote/ActionCode.java 
b/java/org/apache/coyote/ActionCode.java
index 6a24345ed2..62d236633a 100644
--- a/java/org/apache/coyote/ActionCode.java
+++ b/java/org/apache/coyote/ActionCode.java
@@ -275,5 +275,10 @@ public enum ActionCode {
 /**
  * Obtain the servlet connection instance for the network connection 
supporting the current request.
  */
-SERVLET_CONNECTION
+SERVLET_CONNECTION,
+
+/**
+ * Send an RFC 8297 Early Hints informational response.
+ */
+EARLY_HINTS
 }
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index caf2d5700e..f879a3f84d 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1054,6 +1054,13 @@ public class AjpProcessor extends AbstractProcessor {
 }
 
 
+@Override
+protected void earlyHints() throws IOException {
+// TODO Auto-generated method stub
+// NO-OP for now
+}
+
+
 @Override
 protected final int available(boolean doRead) {
 if (endOfStream) {
diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java 
b/java/org/apache/coyote/http11/Http11OutputBuffer.java
index 2c51cdfb45..6967c30996 100644
--- a/java/org/apache/coyote/http11/Http11OutputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java
@@ -300,7 +300,10 @@ public class Http11OutputBuffer implements 
HttpOutputBuffer {
  */
 protected void commit() throws IOException {
   

(tomcat) 03/07: Refactoring writing of HTTP headers to separate method

2024-07-19 Thread markt
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 573560e980a9e74a6c219a56dec5a4bc47d35ea5
Author: Mark Thomas 
AuthorDate: Thu Jul 4 14:18:16 2024 +0100

Refactoring writing of HTTP headers to separate method

This in preparation for RFC 8297 (Early Hints) support that will need to
write the current headers without committing the response.
---
 java/org/apache/coyote/http11/Http11Processor.java | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index cf872a09be..3542625fb7 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1037,9 +1037,15 @@ public class Http11Processor extends AbstractProcessor {
 headers.setValue("Server").setString(server);
 }
 
-// Build the response header
+writeHeaders(response.getStatus(), headers);
+
+outputBuffer.commit();
+}
+
+
+private void writeHeaders(int status, MimeHeaders headers) {
 try {
-outputBuffer.sendStatus(response.getStatus());
+outputBuffer.sendStatus(status);
 
 int size = headers.size();
 for (int i = 0; i < size; i++) {
@@ -1056,7 +1062,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(response.getStatus());
+outputBuffer.sendStatus(status);
 }
 }
 outputBuffer.endHeaders();
@@ -1067,10 +1073,9 @@ public class Http11Processor extends AbstractProcessor {
 outputBuffer.resetHeaderBuffer();
 throw t;
 }
-
-outputBuffer.commit();
 }
 
+
 private static boolean isConnectionToken(MimeHeaders headers, String 
token) throws IOException {
 MessageBytes connection = headers.getValue(Constants.CONNECTION);
 if (connection == null) {


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



(tomcat) 07/07: Add a changelog entry

2024-07-19 Thread markt
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 6df40af33c51fa29b7d9e2a56d98c39b551428c6
Author: Mark Thomas 
AuthorDate: Fri Jul 19 12:44:17 2024 +0100

Add a changelog entry
---
 webapps/docs/changelog.xml | 12 
 1 file changed, 12 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index a4366c857e..9511034e32 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,18 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Add support for RFC 8297 (Early Hints). Applications can use this
+feature by casting the HttpServletResponse to
+org.apache.catalina.connector.Reponse and then calling the
+method void sendEarlyHints(). This method will be added to
+the Servlet API (removing the need for the cast) in Servlet 6.2 
onwards.
+(markt)
+  
+
+  
   
 
   


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



(tomcat) 05/07: AJP doesn't support 1xx responses.

2024-07-19 Thread markt
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 67cbac50947cea05294d59bfa924fb10a6ce7b3b
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:09:33 2024 +0100

AJP doesn't support 1xx responses.
---
 java/org/apache/coyote/ajp/AjpProcessor.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index f879a3f84d..fd1bdc1e24 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1056,8 +1056,7 @@ public class AjpProcessor extends AbstractProcessor {
 
 @Override
 protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+// NO-OP for AJP
 }
 
 


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



(tomcat) 06/07: Add HTTP/2 support for early hints

2024-07-19 Thread markt
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 ae22fadba4b94152fa5cc1d015ed2058f21e3164
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:53:21 2024 +0100

Add HTTP/2 support for early hints
---
 java/org/apache/coyote/http2/Stream.java   | 16 ++
 java/org/apache/coyote/http2/StreamProcessor.java  |  3 +-
 .../apache/coyote/http2/TestStreamProcessor.java   | 66 ++
 3 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index a72bba3a7b..3e621e82a8 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -597,6 +597,22 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+final void writeEarlyHints() throws IOException {
+MimeHeaders headers = coyoteResponse.getMimeHeaders();
+String originalStatus = headers.getHeader(":status");
+headers.setValue(":status").setString("103");
+try {
+handler.writeHeaders(this, 0, headers, false, 
Constants.DEFAULT_HEADERS_FRAME_SIZE);
+} finally {
+if (originalStatus == null) {
+headers.removeHeader(":status");
+} else {
+headers.setValue(":status").setString(originalStatus);
+}
+}
+}
+
+
 @Override
 final String getConnectionId() {
 return handler.getConnectionId();
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index 3f3cde6f50..b7d6e9e6ce 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -263,8 +263,7 @@ class StreamProcessor extends AbstractProcessor {
 
 @Override
 protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+stream.writeEarlyHints();
 }
 
 
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index ac362c6e30..5082349a6e 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -36,6 +36,7 @@ import org.junit.Test;
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.ResponseFacade;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.tomcat.util.compat.JrePlatform;
 import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -586,4 +587,69 @@ public class TestStreamProcessor extends Http2TestBase {
 String trace = output.getTrace();
 Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[501]"));
 }
+
+
+@Test
+public void testEarlyHints() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+Context ctxt = getProgrammaticRootContext();
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "ehs", new EarlyHintsServlet());
+ctxt.addServletMappingDecoded("/ehs", "ehs");
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+// Disable overhead protection for window update as it breaks some 
tests
+http2Protocol.setOverheadWindowUpdateThreshold(0);
+
+byte[] headersFrameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+buildGetRequest(headersFrameHeader, headersPayload, null, 3, "/ehs");
+
+// Write the headers
+writeFrame(headersFrameHeader, headersPayload);
+
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[103]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n" + 
"3-HeadersEnd\n", output.getTrace());
+output.clearTrace();
+
+parser.readFrame();
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n" +
+"3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
+"3-Header-[content-length]-[2]\n" +
+"3-Header-[date]-[" + DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" 
+ "3-Body-2\n" + "3-EndOfStream\n",
+output.getTrace());
+}
+
+
+private static class EarlyHintsServlet extends HttpServlet {
+
+private static final long serialVersionUID = 1L;
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
throws Servle

(tomcat) branch 9.0.x updated: Fix unlock logic after review from kkolinko

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/9.0.x by this push:
 new 6170e45b41 Fix unlock logic after review from kkolinko
6170e45b41 is described below

commit 6170e45b41853fc6d73adc4c94545bd11f2cb81b
Author: Mark Thomas 
AuthorDate: Thu Jul 18 13:49:50 2024 +0100

Fix unlock logic after review from kkolinko

Only call unlock() if lock() was successful
---
 java/org/apache/tomcat/jni/Library.java | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/java/org/apache/tomcat/jni/Library.java 
b/java/org/apache/tomcat/jni/Library.java
index c8e62f4a27..c83b95e316 100644
--- a/java/org/apache/tomcat/jni/Library.java
+++ b/java/org/apache/tomcat/jni/Library.java
@@ -316,10 +316,12 @@ public final class Library {
 public static boolean tryCleanUpLock(long cleanupGeneration) {
 try {
 boolean result = cleanUpLock.readLock().tryLock(0, 
TimeUnit.SECONDS);
-if (result &&  generation.get() == cleanupGeneration) {
-return true;
+if (result) {
+if (generation.get() == cleanupGeneration) {
+return true;
+}
+cleanUpLock.readLock().unlock();
 }
-cleanUpLock.readLock().unlock();
 } catch (InterruptedException e) {
 // Treated the same way as not getting the lock
 }


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



(tomcat) 02/07: Refactor writing of the status code

2024-07-19 Thread markt
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 
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



Re: Security mechanisms to counter spam

2024-07-19 Thread Koteswararao Gundapaneni
Hi Dimitris,

We could potentially block but it is as per the agreement

On Fri, 7 Jun 2024, 15:53 Dimitris Soumis,  wrote:

> Hi All,
>
> Due to the surge in spam BZs today, I propose implementing a security
> mechanism to counter this issue and prevent further disruption to the
> mailing list.
>
> A potential solution could include a honeypot to identify and block bots,
> as well as a reCaptcha to verify users. Additionally, should monitor for
> multiple requests from the same IP address and block the IP if necessary.
>
> Can also leverage tools like this Mozilla Bugbot Spam Detection Script
>  to
> identify and filter out spam.
>
> Best regards,
>
> Dimitris
>


Re: (tomcat) 06/07: Add HTTP/2 support for early hints

2024-07-19 Thread Koteswararao Gundapaneni
Hi Mark,


OpenclientConnection should be ftp rather than tcpip

Re
Koti




On Fri, 19 Jul 2024, 21:56 ,  wrote:

> 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 ae22fadba4b94152fa5cc1d015ed2058f21e3164
> Author: Mark Thomas 
> AuthorDate: Thu Jul 4 16:53:21 2024 +0100
>
> Add HTTP/2 support for early hints
> ---
>  java/org/apache/coyote/http2/Stream.java   | 16 ++
>  java/org/apache/coyote/http2/StreamProcessor.java  |  3 +-
>  .../apache/coyote/http2/TestStreamProcessor.java   | 66
> ++
>  3 files changed, 83 insertions(+), 2 deletions(-)
>
> diff --git a/java/org/apache/coyote/http2/Stream.java
> b/java/org/apache/coyote/http2/Stream.java
> index a72bba3a7b..3e621e82a8 100644
> --- a/java/org/apache/coyote/http2/Stream.java
> +++ b/java/org/apache/coyote/http2/Stream.java
> @@ -597,6 +597,22 @@ class Stream extends AbstractNonZeroStream implements
> HeaderEmitter {
>  }
>
>
> +final void writeEarlyHints() throws IOException {
> +MimeHeaders headers = coyoteResponse.getMimeHeaders();
> +String originalStatus = headers.getHeader(":status");
> +headers.setValue(":status").setString("103");
> +try {
> +handler.writeHeaders(this, 0, headers, false,
> Constants.DEFAULT_HEADERS_FRAME_SIZE);
> +} finally {
> +if (originalStatus == null) {
> +headers.removeHeader(":status");
> +} else {
> +headers.setValue(":status").setString(originalStatus);
> +}
> +}
> +}
> +
> +
>  @Override
>  final String getConnectionId() {
>  return handler.getConnectionId();
> diff --git a/java/org/apache/coyote/http2/StreamProcessor.java
> b/java/org/apache/coyote/http2/StreamProcessor.java
> index 3f3cde6f50..b7d6e9e6ce 100644
> --- a/java/org/apache/coyote/http2/StreamProcessor.java
> +++ b/java/org/apache/coyote/http2/StreamProcessor.java
> @@ -263,8 +263,7 @@ class StreamProcessor extends AbstractProcessor {
>
>  @Override
>  protected void earlyHints() throws IOException {
> -// TODO Auto-generated method stub
> -// NO-OP for now
> +stream.writeEarlyHints();
>  }
>
>
> diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java
> b/test/org/apache/coyote/http2/TestStreamProcessor.java
> index ac362c6e30..5082349a6e 100644
> --- a/test/org/apache/coyote/http2/TestStreamProcessor.java
> +++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
> @@ -36,6 +36,7 @@ import org.junit.Test;
>  import org.apache.catalina.Context;
>  import org.apache.catalina.Wrapper;
>  import org.apache.catalina.connector.Connector;
> +import org.apache.catalina.connector.ResponseFacade;
>  import org.apache.catalina.startup.Tomcat;
>  import org.apache.tomcat.util.compat.JrePlatform;
>  import org.apache.tomcat.util.http.FastHttpDateFormat;
> @@ -586,4 +587,69 @@ public class TestStreamProcessor extends
> Http2TestBase {
>  String trace = output.getTrace();
>  Assert.assertTrue(trace,
> trace.contains("3-Header-[:status]-[501]"));
>  }
> +
> +
> +@Test
> +public void testEarlyHints() throws Exception {
> +enableHttp2();
> +
> +Tomcat tomcat = getTomcatInstance();
> +
> +Context ctxt = getProgrammaticRootContext();
> +Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
> +ctxt.addServletMappingDecoded("/simple", "simple");
> +Tomcat.addServlet(ctxt, "ehs", new EarlyHintsServlet());
> +ctxt.addServletMappingDecoded("/ehs", "ehs");
> +tomcat.start();
> +
> +openClientConnection();
> +doHttpUpgrade();
> +sendClientPreface();
> +validateHttp2InitialResponse();
> +
> +// Disable overhead protection for window update as it breaks
> some tests
> +http2Protocol.setOverheadWindowUpdateThreshold(0);
> +
> +byte[] headersFrameHeader = new byte[9];
> +ByteBuffer headersPayload = ByteBuffer.allocate(128);
> +
> +buildGetRequest(headersFrameHeader, headersPayload, null, 3,
> "/ehs");
> +
> +// Write the headers
> +writeFrame(headersFrameHeader, headersPayload);
> +
> +parser.readFrame();
> +
> +Assert.assertEquals("3-HeadersStart\n" +
> "3-Header-[:status]-[103]\n" +
> +"3-Header-[link]-[; rel=preload; as=style]\n"
> + "3-HeadersEnd\n", output.getTrace());
> +output.clearTrace();
> +
> +parser.readFrame();
> +parser.readFrame();
> +
> +Assert.assertEquals("3-HeadersStart\n" +
> "3-Header-[:status]-[200]\n" +
> +"3-Header-[link]-[; rel=preload; as=style]\n"
> +
> +"3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
> +"3-Header-[content-length]-[2]\n" +
> +"3-Header-[date]-[" + DEFAULT_

Re: Short and long term plans for Tomcat Native

2024-07-19 Thread Mark Thomas

On 19/07/2024 16:03, Koteswararao Gundapaneni wrote:

Hi Mark


Do we need the app is maintained or to be noticed


This comment makes no sense.

If you continue to make nonsensical comments to the dev@ list, GitHub, 
Bugzilla or similar then you will be blocked from making any comments.


If English is not your first language, I would strongly encourage you to 
use Google Translate or a similar service.


Mark




On Wed, 17 Jul 2024, 21:04 Mark Thomas,  wrote:


All,

I've spent some time today trying to build Tomcat Native with Visual
Studio 2022 rather then the current, more involved process without success.

Therefore, my short-term plan for Tomcat Native is to get the next 2.0.x
and 1.3.x releases completed using the existing build process. I'll be
starting that shortly.

Longer term, thinking about Tomcat Native and FFM I have the following
rough plan in mind:

- stop providing x86 binaries for Windows
- require Windows 10 onwards
- provide:
- libssl.dll
- libcrypto.dll
- tomcat-native-2.dll
- openssl.exe

along with appropriate debug symbols.

I'm not sure if we'd need an apr.dll in there as well.

The idea is that users can then use either the AprLifecycleListener or
OpenSSLLifecycleListener.

This would probably require moving Tomcat Native to 2.1.x and 1.4.x

This really needs someone more familiar with building C libraries
generally and these libraries in particular - i.e. Mladen - to say
whether the above is possible and to provide some pointers on how to do it.

Mark

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






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



Re: Security mechanisms to counter spam

2024-07-19 Thread Mark Thomas

On 19/07/2024 16:08, Koteswararao Gundapaneni wrote:

Hi Dimitris,

We could potentially block but it is as per the agreement


This comment makes no sense.

If you continue to make nonsensical comments to the dev@ list, GitHub, 
Bugzilla or similar then you will be blocked from making any comments.


If English is not your first language, I would strongly encourage you to 
use Google Translate or a similar service.


Mark





On Fri, 7 Jun 2024, 15:53 Dimitris Soumis,  wrote:


Hi All,

Due to the surge in spam BZs today, I propose implementing a security
mechanism to counter this issue and prevent further disruption to the
mailing list.

A potential solution could include a honeypot to identify and block bots,
as well as a reCaptcha to verify users. Additionally, should monitor for
multiple requests from the same IP address and block the IP if necessary.

Can also leverage tools like this Mozilla Bugbot Spam Detection Script
 to
identify and filter out spam.

Best regards,

Dimitris





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



Re: (tomcat) 03/09: Refactor writing of the status code

2024-07-19 Thread Koteswararao Gundapaneni
Hi Mark,

response.getStatus() should be identical I mean it is json eval


On Fri, 19 Jul 2024, 20:39 ,  wrote:

> This is an automated email from the ASF dual-hosted git repository.
>
> markt pushed a commit to branch main
> in repository https://gitbox.apache.org/repos/asf/tomcat.git
>
> commit ff7a869fd203b3b60ffd699c47da1d07e77f0c3a
> Author: Mark Thomas 
> 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 be7955c1b0..76fdb0d126 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 681db0e96b..f6f34e8f45 100644
> --- a/java/org/apache/coyote/http11/Http11Processor.java
> +++ b/java/org/apache/coyote/http11/Http11Processor.java
> @@ -1037,7 +1037,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++) {
> @@ -1054,7 +1054,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
>
>


Re: (tomcat) 06/07: Add HTTP/2 support for early hints

2024-07-19 Thread Mark Thomas

On 19/07/2024 16:19, Koteswararao Gundapaneni wrote:

Hi Mark,


OpenclientConnection should be ftp rather than tcpip

Re
Koti


And the above complete and utter nonsense is the point where my patience 
is exhausted. Any more posts like this and a ban will be applied without 
further comment or warning.


Mark







On Fri, 19 Jul 2024, 21:56 ,  wrote:


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 ae22fadba4b94152fa5cc1d015ed2058f21e3164
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:53:21 2024 +0100

 Add HTTP/2 support for early hints
---
  java/org/apache/coyote/http2/Stream.java   | 16 ++
  java/org/apache/coyote/http2/StreamProcessor.java  |  3 +-
  .../apache/coyote/http2/TestStreamProcessor.java   | 66
++
  3 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java
b/java/org/apache/coyote/http2/Stream.java
index a72bba3a7b..3e621e82a8 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -597,6 +597,22 @@ class Stream extends AbstractNonZeroStream implements
HeaderEmitter {
  }


+final void writeEarlyHints() throws IOException {
+MimeHeaders headers = coyoteResponse.getMimeHeaders();
+String originalStatus = headers.getHeader(":status");
+headers.setValue(":status").setString("103");
+try {
+handler.writeHeaders(this, 0, headers, false,
Constants.DEFAULT_HEADERS_FRAME_SIZE);
+} finally {
+if (originalStatus == null) {
+headers.removeHeader(":status");
+} else {
+headers.setValue(":status").setString(originalStatus);
+}
+}
+}
+
+
  @Override
  final String getConnectionId() {
  return handler.getConnectionId();
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java
b/java/org/apache/coyote/http2/StreamProcessor.java
index 3f3cde6f50..b7d6e9e6ce 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -263,8 +263,7 @@ class StreamProcessor extends AbstractProcessor {

  @Override
  protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+stream.writeEarlyHints();
  }


diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index ac362c6e30..5082349a6e 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -36,6 +36,7 @@ import org.junit.Test;
  import org.apache.catalina.Context;
  import org.apache.catalina.Wrapper;
  import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.ResponseFacade;
  import org.apache.catalina.startup.Tomcat;
  import org.apache.tomcat.util.compat.JrePlatform;
  import org.apache.tomcat.util.http.FastHttpDateFormat;
@@ -586,4 +587,69 @@ public class TestStreamProcessor extends
Http2TestBase {
  String trace = output.getTrace();
  Assert.assertTrue(trace,
trace.contains("3-Header-[:status]-[501]"));
  }
+
+
+@Test
+public void testEarlyHints() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+Context ctxt = getProgrammaticRootContext();
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "ehs", new EarlyHintsServlet());
+ctxt.addServletMappingDecoded("/ehs", "ehs");
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+// Disable overhead protection for window update as it breaks
some tests
+http2Protocol.setOverheadWindowUpdateThreshold(0);
+
+byte[] headersFrameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+buildGetRequest(headersFrameHeader, headersPayload, null, 3,
"/ehs");
+
+// Write the headers
+writeFrame(headersFrameHeader, headersPayload);
+
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" +
"3-Header-[:status]-[103]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n"
+ "3-HeadersEnd\n", output.getTrace());
+output.clearTrace();
+
+parser.readFrame();
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" +
"3-Header-[:status]-[200]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n"
+
+"3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
+"3-Header-[content-length]-[2]\n" +
+"3-Header-[date]-[" 

(tomcat) branch 9.0.x updated (6170e45b41 -> b54fa0e67f)

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a change to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


from 6170e45b41 Fix unlock logic after review from kkolinko
 new 40f82e1a72 Refactor SimpleHTTPClient to read body as-is rather than 
via readLine()
 new 0dfcbf7973 Rename method that performs commit to commit()
 new fb1e220e71 Refactor writing of the status code
 new 5bb7db277a Refactoring writing of HTTP headers to separate method
 new 5c2cce Implement early hints for HTTP/1.1
 new 5322419f4b AJP doesn't support 1xx responses.
 new 0d2b76ba3c Add HTTP/2 support for early hints
 new b54fa0e67f Add a changelog entry

The 8 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../apache/catalina/connector/OutputBuffer.java|  2 +-
 java/org/apache/catalina/connector/Response.java   | 14 +
 .../apache/catalina/connector/ResponseFacade.java  |  4 ++
 java/org/apache/coyote/AbstractProcessor.java  | 11 
 java/org/apache/coyote/ActionCode.java |  7 ++-
 java/org/apache/coyote/Response.java   | 11 
 java/org/apache/coyote/ajp/AjpProcessor.java   |  6 ++
 .../apache/coyote/http11/Http11OutputBuffer.java   | 17 +-
 java/org/apache/coyote/http11/Http11Processor.java | 23 ++--
 .../org/apache/coyote/http2/Http2OutputBuffer.java |  2 +-
 java/org/apache/coyote/http2/Stream.java   | 16 ++
 java/org/apache/coyote/http2/StreamProcessor.java  |  6 ++
 .../apache/catalina/core/TestStandardContext.java  |  2 +-
 .../apache/catalina/startup/SimpleHttpClient.java  | 16 --
 .../coyote/http11/TestHttp11InputBuffer.java   |  2 +-
 .../apache/coyote/http11/TestHttp11Processor.java  | 51 -
 .../apache/coyote/http2/TestStreamProcessor.java   | 66 ++
 webapps/docs/changelog.xml | 12 
 18 files changed, 252 insertions(+), 16 deletions(-)


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



(tomcat) 04/08: Refactoring writing of HTTP headers to separate method

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 5bb7db277a66d5f60ea8dac47249d53e83f54f79
Author: Mark Thomas 
AuthorDate: Thu Jul 4 14:18:16 2024 +0100

Refactoring writing of HTTP headers to separate method

This in preparation for RFC 8297 (Early Hints) support that will need to
write the current headers without committing the response.
---
 java/org/apache/coyote/http11/Http11Processor.java | 15 ++-
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/java/org/apache/coyote/http11/Http11Processor.java 
b/java/org/apache/coyote/http11/Http11Processor.java
index 7a7b17faf8..045c2ed8b1 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1036,9 +1036,15 @@ public class Http11Processor extends AbstractProcessor {
 headers.setValue("Server").setString(server);
 }
 
-// Build the response header
+writeHeaders(response.getStatus(), headers);
+
+outputBuffer.commit();
+}
+
+
+private void writeHeaders(int status, MimeHeaders headers) {
 try {
-outputBuffer.sendStatus(response.getStatus());
+outputBuffer.sendStatus(status);
 
 int size = headers.size();
 for (int i = 0; i < size; i++) {
@@ -1055,7 +1061,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(response.getStatus());
+outputBuffer.sendStatus(status);
 }
 }
 outputBuffer.endHeaders();
@@ -1066,10 +1072,9 @@ public class Http11Processor extends AbstractProcessor {
 outputBuffer.resetHeaderBuffer();
 throw t;
 }
-
-outputBuffer.commit();
 }
 
+
 private static boolean isConnectionToken(MimeHeaders headers, String 
token) throws IOException {
 MessageBytes connection = headers.getValue(Constants.CONNECTION);
 if (connection == null) {


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



(tomcat) 03/08: Refactor writing of the status code

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit fb1e220e711798a427eb12d2f8a30d9bb594f312
Author: Mark Thomas 
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 6e88c9c438..7a7b17faf8 100644
--- a/java/org/apache/coyote/http11/Http11Processor.java
+++ b/java/org/apache/coyote/http11/Http11Processor.java
@@ -1038,7 +1038,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++) {
@@ -1055,7 +1055,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



(tomcat) 01/08: Refactor SimpleHTTPClient to read body as-is rather than via readLine()

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 40f82e1a72c29d641fe99e14663a88f3ca5da5b4
Author: Mark Thomas 
AuthorDate: Thu Jun 22 17:08:02 2023 +0100

Refactor SimpleHTTPClient to read body as-is rather than via readLine()

Update impacted tests so they still pass
---
 test/org/apache/catalina/core/TestStandardContext.java   |  2 +-
 test/org/apache/catalina/startup/SimpleHttpClient.java   | 16 
 test/org/apache/coyote/http11/TestHttp11InputBuffer.java |  2 +-
 test/org/apache/coyote/http11/TestHttp11Processor.java   |  2 +-
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/test/org/apache/catalina/core/TestStandardContext.java 
b/test/org/apache/catalina/core/TestStandardContext.java
index ca83d2ccc0..fdf37b6733 100644
--- a/test/org/apache/catalina/core/TestStandardContext.java
+++ b/test/org/apache/catalina/core/TestStandardContext.java
@@ -704,7 +704,7 @@ public class TestStandardContext extends TomcatBaseTest {
 
 PrintWriter out = resp.getWriter();
 
-out.println("parts=" + (null == req.getParts()
+out.print("parts=" + (null == req.getParts()
 ? "null"
 : Integer.valueOf(req.getParts().size(;
 }
diff --git a/test/org/apache/catalina/startup/SimpleHttpClient.java 
b/test/org/apache/catalina/startup/SimpleHttpClient.java
index 1491ab6d87..d20136d680 100644
--- a/test/org/apache/catalina/startup/SimpleHttpClient.java
+++ b/test/org/apache/catalina/startup/SimpleHttpClient.java
@@ -146,6 +146,13 @@ public abstract class SimpleHttpClient {
 return responseLine;
 }
 
+public int getStatusCode() {
+if (responseLine.length() < 13) {
+throw new IllegalStateException();
+}
+return Integer.parseInt(responseLine.substring(9, 12));
+}
+
 public List getResponseHeaders() {
 return responseHeaders;
 }
@@ -319,11 +326,12 @@ public abstract class SimpleHttpClient {
 Assert.assertEquals(contentLength, read);
 builder.append(body);
 } else {
-// not using content length, so just read it line by line
-String line = null;
+// Not using content length, so just read until EOF
+char[] buf = new char[1024];
+int read;
 try {
-while ((line = readLine()) != null) {
-builder.append(line);
+while ((read = reader.read(buf)) != -1) {
+builder.append(buf, 0, read);
 }
 } catch (SocketException e) {
 // Ignore
diff --git a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java 
b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
index 99e25601f7..f67ba1f0b8 100644
--- a/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
+++ b/test/org/apache/coyote/http11/TestHttp11InputBuffer.java
@@ -379,7 +379,7 @@ public class TestHttp11InputBuffer extends TomcatBaseTest {
 private void processHeaders(String header, HttpServletRequest req, 
PrintWriter out) {
 Enumeration values = req.getHeaders(header);
 while (values.hasMoreElements()) {
-out.println(values.nextElement());
+out.print(values.nextElement());
 }
 }
 }
diff --git a/test/org/apache/coyote/http11/TestHttp11Processor.java 
b/test/org/apache/coyote/http11/TestHttp11Processor.java
index a26a7f96a5..94a3323b3d 100644
--- a/test/org/apache/coyote/http11/TestHttp11Processor.java
+++ b/test/org/apache/coyote/http11/TestHttp11Processor.java
@@ -105,7 +105,7 @@ public class TestHttp11Processor extends TomcatBaseTest {
 // There should not be an end chunk
 Assert.assertFalse(client.getResponseBody().endsWith("0"));
 // The last portion of text should be there
-Assert.assertTrue(client.getResponseBody().endsWith("line03"));
+Assert.assertTrue(client.getResponseBody().endsWith("line03" + 
SimpleHttpClient.CRLF));
 }
 
 private static class ResponseWithErrorServlet extends HttpServlet {


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



(tomcat) 02/08: Rename method that performs commit to commit()

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 0dfcbf7973dc7e9fb73dd00aadf710eb7acc7332
Author: Mark Thomas 
AuthorDate: Thu Jul 4 13:50:37 2024 +0100

Rename method that performs commit to commit()

This refactoring is in preparation for RFC 8293 (Early Hints) support.
That will introduce a method that writes headers without a commit. This
rename will reduce potential confusion between writeHeaders() and
sendHeaders().
---
 java/org/apache/catalina/connector/OutputBuffer.java |  2 +-
 java/org/apache/coyote/Response.java | 11 +++
 java/org/apache/coyote/http2/Http2OutputBuffer.java  |  2 +-
 3 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/catalina/connector/OutputBuffer.java 
b/java/org/apache/catalina/connector/OutputBuffer.java
index f522a09ad5..6776fbe82a 100644
--- a/java/org/apache/catalina/connector/OutputBuffer.java
+++ b/java/org/apache/catalina/connector/OutputBuffer.java
@@ -286,7 +286,7 @@ public class OutputBuffer extends Writer {
 try {
 doFlush = true;
 if (initial) {
-coyoteResponse.sendHeaders();
+coyoteResponse.commit();
 initial = false;
 }
 if (cb.remaining() > 0) {
diff --git a/java/org/apache/coyote/Response.java 
b/java/org/apache/coyote/Response.java
index a81185b699..ee5dbeeebc 100644
--- a/java/org/apache/coyote/Response.java
+++ b/java/org/apache/coyote/Response.java
@@ -438,8 +438,19 @@ public final class Response {
 
 /**
  * Signal that we're done with the headers, and body will follow.
+ *
+ * @deprecated Unused. Will be removed in Tomcat 11 onwards. Use {@link 
#commit()}.
  */
+@Deprecated
 public void sendHeaders() {
+commit();
+}
+
+
+/**
+ * Signal that we're done with the headers, and body will follow.
+ */
+public void commit() {
 action(ActionCode.COMMIT, this);
 setCommitted(true);
 }
diff --git a/java/org/apache/coyote/http2/Http2OutputBuffer.java 
b/java/org/apache/coyote/http2/Http2OutputBuffer.java
index 1de4569900..3d4d6b96c5 100644
--- a/java/org/apache/coyote/http2/Http2OutputBuffer.java
+++ b/java/org/apache/coyote/http2/Http2OutputBuffer.java
@@ -52,7 +52,7 @@ public class Http2OutputBuffer implements HttpOutputBuffer {
 @Override
 public int doWrite(ByteBuffer chunk) throws IOException {
 if (!coyoteResponse.isCommitted()) {
-coyoteResponse.sendHeaders();
+coyoteResponse.commit();
 }
 return next.doWrite(chunk);
 }


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



(tomcat) 05/08: Implement early hints for HTTP/1.1

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 5c2cceaf9aeb7db55f92f28530eb9e9fb417
Author: Mark Thomas 
AuthorDate: Thu Jul 4 15:48:18 2024 +0100

Implement early hints for HTTP/1.1
---
 java/org/apache/catalina/connector/Response.java   | 14 +++
 .../apache/catalina/connector/ResponseFacade.java  |  4 ++
 java/org/apache/coyote/AbstractProcessor.java  | 11 +
 java/org/apache/coyote/ActionCode.java |  7 +++-
 java/org/apache/coyote/ajp/AjpProcessor.java   |  7 
 .../apache/coyote/http11/Http11OutputBuffer.java   |  3 ++
 java/org/apache/coyote/http11/Http11Processor.java |  8 
 java/org/apache/coyote/http2/StreamProcessor.java  |  7 
 .../apache/coyote/http11/TestHttp11Processor.java  | 49 ++
 9 files changed, 109 insertions(+), 1 deletion(-)

diff --git a/java/org/apache/catalina/connector/Response.java 
b/java/org/apache/catalina/connector/Response.java
index d751dc231f..0e8fe8d2c5 100644
--- a/java/org/apache/catalina/connector/Response.java
+++ b/java/org/apache/catalina/connector/Response.java
@@ -1123,6 +1123,20 @@ public class Response implements HttpServletResponse {
 }
 
 
+public void sendEarlyHints() {
+if (isCommitted()) {
+return;
+}
+
+// Ignore any call from an included servlet
+if (included) {
+return;
+}
+
+getCoyoteResponse().action(ActionCode.EARLY_HINTS, null);
+}
+
+
 @Override
 public void sendError(int status) throws IOException {
 sendError(status, null);
diff --git a/java/org/apache/catalina/connector/ResponseFacade.java 
b/java/org/apache/catalina/connector/ResponseFacade.java
index 89aeecf0f9..068c68982b 100644
--- a/java/org/apache/catalina/connector/ResponseFacade.java
+++ b/java/org/apache/catalina/connector/ResponseFacade.java
@@ -325,6 +325,10 @@ public class ResponseFacade implements HttpServletResponse 
{
 }
 
 
+public void sendEarlyHints() {
+response.sendEarlyHints();
+}
+
 @Override
 public String encodeUrl(String url) {
 checkFacade();
diff --git a/java/org/apache/coyote/AbstractProcessor.java 
b/java/org/apache/coyote/AbstractProcessor.java
index 108aa82538..2e1c1fda3c 100644
--- a/java/org/apache/coyote/AbstractProcessor.java
+++ b/java/org/apache/coyote/AbstractProcessor.java
@@ -393,6 +393,14 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 ack((ContinueResponseTiming) param);
 break;
 }
+case EARLY_HINTS: {
+try {
+earlyHints();
+} catch (IOException e) {
+handleIOException(e);
+}
+break;
+}
 case CLIENT_FLUSH: {
 action(ActionCode.COMMIT, null);
 try {
@@ -750,6 +758,9 @@ public abstract class AbstractProcessor extends 
AbstractProcessorLight implement
 protected abstract void ack(ContinueResponseTiming continueResponseTiming);
 
 
+protected abstract void earlyHints() throws IOException;
+
+
 /**
  * Callback to write data from the buffer.
  * @throws IOException IO exception during the write
diff --git a/java/org/apache/coyote/ActionCode.java 
b/java/org/apache/coyote/ActionCode.java
index 349c43fe2a..84d0eda0ea 100644
--- a/java/org/apache/coyote/ActionCode.java
+++ b/java/org/apache/coyote/ActionCode.java
@@ -274,5 +274,10 @@ public enum ActionCode {
 /**
  * Obtain the stream identifier for the request. Used with multiplexing 
protocols such as HTTP/2.
  */
-STREAM_ID
+STREAM_ID,
+
+/**
+ * Send an RFC 8297 Early Hints informational response.
+ */
+EARLY_HINTS
 }
diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index 08c29a97a8..fba8fd624d 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1045,6 +1045,13 @@ public class AjpProcessor extends AbstractProcessor {
 }
 
 
+@Override
+protected void earlyHints() throws IOException {
+// TODO Auto-generated method stub
+// NO-OP for now
+}
+
+
 @Override
 protected final int available(boolean doRead) {
 if (endOfStream) {
diff --git a/java/org/apache/coyote/http11/Http11OutputBuffer.java 
b/java/org/apache/coyote/http11/Http11OutputBuffer.java
index 2c51cdfb45..6967c30996 100644
--- a/java/org/apache/coyote/http11/Http11OutputBuffer.java
+++ b/java/org/apache/coyote/http11/Http11OutputBuffer.java
@@ -300,7 +300,10 @@ public class Http11OutputBuffer implements 
HttpOutputBuffer {
  */
 protected void commit() throws IOException {
 response.setCommitted(true);
+writeHeaders();
+}
 
+protec

(tomcat) 08/08: Add a changelog entry

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit b54fa0e67fb1368b75c86a777907be8763dcff1b
Author: Mark Thomas 
AuthorDate: Fri Jul 19 12:44:17 2024 +0100

Add a changelog entry
---
 webapps/docs/changelog.xml | 12 
 1 file changed, 12 insertions(+)

diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index cfae001c34..9d098de379 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -105,6 +105,18 @@
   issues do not "pop up" wrt. others).
 -->
 
+  
+
+  
+Add support for RFC 8297 (Early Hints). Applications can use this
+feature by casting the HttpServletResponse to
+org.apache.catalina.connector.Reponse and then calling the
+method void sendEarlyHints(). This method will be added to
+the Servlet API (removing the need for the cast) in Servlet 6.2 
onwards.
+(markt)
+  
+
+  
   
 
   


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



(tomcat) 07/08: Add HTTP/2 support for early hints

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 0d2b76ba3c13957debfc8857359c308b47bb9d8b
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:53:21 2024 +0100

Add HTTP/2 support for early hints
---
 java/org/apache/coyote/http2/Stream.java   | 16 ++
 java/org/apache/coyote/http2/StreamProcessor.java  |  3 +-
 .../apache/coyote/http2/TestStreamProcessor.java   | 66 ++
 3 files changed, 83 insertions(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/http2/Stream.java 
b/java/org/apache/coyote/http2/Stream.java
index 95b596a004..08c22bbcda 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -595,6 +595,22 @@ class Stream extends AbstractNonZeroStream implements 
HeaderEmitter {
 }
 
 
+final void writeEarlyHints() throws IOException {
+MimeHeaders headers = coyoteResponse.getMimeHeaders();
+String originalStatus = headers.getHeader(":status");
+headers.setValue(":status").setString("103");
+try {
+handler.writeHeaders(this, 0, headers, false, 
Constants.DEFAULT_HEADERS_FRAME_SIZE);
+} finally {
+if (originalStatus == null) {
+headers.removeHeader(":status");
+} else {
+headers.setValue(":status").setString(originalStatus);
+}
+}
+}
+
+
 @Override
 final String getConnectionId() {
 return handler.getConnectionId();
diff --git a/java/org/apache/coyote/http2/StreamProcessor.java 
b/java/org/apache/coyote/http2/StreamProcessor.java
index afd199c97c..78b76ed86b 100644
--- a/java/org/apache/coyote/http2/StreamProcessor.java
+++ b/java/org/apache/coyote/http2/StreamProcessor.java
@@ -263,8 +263,7 @@ class StreamProcessor extends AbstractProcessor {
 
 @Override
 protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+stream.writeEarlyHints();
 }
 
 
diff --git a/test/org/apache/coyote/http2/TestStreamProcessor.java 
b/test/org/apache/coyote/http2/TestStreamProcessor.java
index 60448f3401..5c3daac77c 100644
--- a/test/org/apache/coyote/http2/TestStreamProcessor.java
+++ b/test/org/apache/coyote/http2/TestStreamProcessor.java
@@ -36,6 +36,7 @@ import org.junit.Test;
 import org.apache.catalina.Context;
 import org.apache.catalina.Wrapper;
 import org.apache.catalina.connector.Connector;
+import org.apache.catalina.connector.ResponseFacade;
 import org.apache.catalina.startup.Tomcat;
 import org.apache.coyote.UpgradeProtocol;
 import org.apache.tomcat.util.compat.JrePlatform;
@@ -591,4 +592,69 @@ public class TestStreamProcessor extends Http2TestBase {
 String trace = output.getTrace();
 Assert.assertTrue(trace, trace.contains("3-Header-[:status]-[501]"));
 }
+
+
+@Test
+public void testEarlyHints() throws Exception {
+enableHttp2();
+
+Tomcat tomcat = getTomcatInstance();
+
+Context ctxt = getProgrammaticRootContext();
+Tomcat.addServlet(ctxt, "simple", new SimpleServlet());
+ctxt.addServletMappingDecoded("/simple", "simple");
+Tomcat.addServlet(ctxt, "ehs", new EarlyHintsServlet());
+ctxt.addServletMappingDecoded("/ehs", "ehs");
+tomcat.start();
+
+openClientConnection();
+doHttpUpgrade();
+sendClientPreface();
+validateHttp2InitialResponse();
+
+// Disable overhead protection for window update as it breaks some 
tests
+http2Protocol.setOverheadWindowUpdateThreshold(0);
+
+byte[] headersFrameHeader = new byte[9];
+ByteBuffer headersPayload = ByteBuffer.allocate(128);
+
+buildGetRequest(headersFrameHeader, headersPayload, null, 3, "/ehs");
+
+// Write the headers
+writeFrame(headersFrameHeader, headersPayload);
+
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[103]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n" + 
"3-HeadersEnd\n", output.getTrace());
+output.clearTrace();
+
+parser.readFrame();
+parser.readFrame();
+
+Assert.assertEquals("3-HeadersStart\n" + "3-Header-[:status]-[200]\n" +
+"3-Header-[link]-[; rel=preload; as=style]\n" +
+"3-Header-[content-type]-[text/plain;charset=UTF-8]\n" +
+"3-Header-[content-length]-[2]\n" +
+"3-Header-[date]-[" + DEFAULT_DATE + "]\n" + "3-HeadersEnd\n" 
+ "3-Body-2\n" + "3-EndOfStream\n",
+output.getTrace());
+}
+
+
+private static class EarlyHintsServlet extends HttpServlet {
+
+private static final long serialVersionUID = 1L;
+
+@Override
+protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
throws ServletException, IO

(tomcat) 06/08: AJP doesn't support 1xx responses.

2024-07-19 Thread markt
This is an automated email from the ASF dual-hosted git repository.

markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git

commit 5322419f4b7dfc93db630aa49145889240487821
Author: Mark Thomas 
AuthorDate: Thu Jul 4 16:09:33 2024 +0100

AJP doesn't support 1xx responses.
---
 java/org/apache/coyote/ajp/AjpProcessor.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/java/org/apache/coyote/ajp/AjpProcessor.java 
b/java/org/apache/coyote/ajp/AjpProcessor.java
index fba8fd624d..e80b34ad52 100644
--- a/java/org/apache/coyote/ajp/AjpProcessor.java
+++ b/java/org/apache/coyote/ajp/AjpProcessor.java
@@ -1047,8 +1047,7 @@ public class AjpProcessor extends AbstractProcessor {
 
 @Override
 protected void earlyHints() throws IOException {
-// TODO Auto-generated method stub
-// NO-OP for now
+// NO-OP for AJP
 }
 
 


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