Skip to content

Different content-length response behaviour on Java 11 vs Java 17 #519

Open
@dzhus

Description

Using dde9716, I'm observing the following response difference around transfer-encoding + content-length headers between Java 11 and Java 17, just using the wiki example as a minimal case + lein repl.

Java 11

Clojure 1.9.0
OpenJDK 64-Bit Server VM 11.0.21+9

user=> (defn handler [_request] {:status 200 :headers {"Content-Type" "text/html"} :body "Hello World"})
user=> (ring.adapter.jetty/run-jetty handler {:port 3000 :join? false})
% curl -v localhost:3000
* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3000...
* Connected to localhost (::1) port 3000
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Date: Fri, 10 Jan 2025 10:42:39 GMT
< Content-Type: text/html
< Content-Length: 11
< Server: Jetty(11.0.24)
< 
* Connection #0 to host localhost left intact
Hello World%  

Java 17

Clojure 1.9.0
OpenJDK 64-Bit Server VM 17.0.13+11

user=> (defn handler [_request] {:status 200 :headers {"Content-Type" "text/html"} :body "Hello World"})
user=> (ring.adapter.jetty/run-jetty handler {:port 3000 :join? false})
% curl -v localhost:3000
* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3000...
* Connected to localhost (::1) port 3000
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.7.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Date: Fri, 10 Jan 2025 10:39:31 GMT
< Content-Type: text/html
< Transfer-Encoding: chunked
< Server: Jetty(11.0.24)
< 
* Connection #0 to host localhost left intact
Hello World%   

So Content-Length: 11 in the response switched over to Transfer-Encoding: chunked. Any thoughts on this? Both variants look correct, but does anyone know if this is expected, and if the change is even thanks to ring or something else in the stack (jetty / Java libraries)?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions