On 24.06.2020 17:13, Mark Thomas wrote:
On 24/06/2020 15:59, Julian Reschke wrote:


I just tried to figure out whether Tomcat 9 will let be send trailer
fields in a chunked HTTP/1.1 response, using


I couldn't get it to work yet, so below some questions:

1) Is this actually supported for HTTP/1.1?


2) Will it automatically switch to chunked encoding (leaving out
content-length), or does the application code need to take care of that?

Tomcat will handle all of that but you need to make sure you set the
trailer fields before the response is committed so Tomcat can set the
appropriate headers.

3) I understand that I need to send "Trailer" upfront, but what about
"TE" and "Connection"?

Just the Trailer header. Tomcat will look after the rest.



I'm trying this with Apache Jackrabbit trunk and the minimal patch below:
Index: jackrabbit-parent/pom.xml
--- jackrabbit-parent/pom.xml   (Revision 1879148)
+++ jackrabbit-parent/pom.xml   (Arbeitskopie)
@@ -554,7 +554,7 @@
-        <version>3.1.0</version>
+        <version>4.0.1</version>
      (Revision 1879148)
@@ -95,8 +95,10 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Locale;
+import java.util.Map;

  * <code>AbstractWebdavServlet</code>
@@ -602,6 +604,11 @@

+        response.setHeader("Trailer", "foo");
+        Map<String, String> trailers = new HashMap<>();
+        trailers.put("foo", "bar");
+        response.setTrailerFields(() -> trailers);
         // spool resource properties and eventually resource content.
         OutputStream out = (sendContent) ? response.getOutputStream() : null;
         resource.spool(getOutputContext(response, out));

When I deploy jackrabbit-webapp in Tomcat 9.0.36, and curl a resource, I

< HTTP/1.1 200
< Trailer: foo
< ETag: "2692247-1592985065092"
< Last-Modified: Wed, 24 Jun 2020 07:51:05 GMT
< Content-Type: image/jpeg
< Content-Length: 2692247
< Date: Wed, 24 Jun 2020 15:33:11 GMT
{ [7996 bytes data]

So it does set "Trailer" (so the response was not committed yet), but it
doesn't switch to chunked encoding.

There must be something that I'm doing wrong...

Best regards, Julian

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

Reply via email to