Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dzhus opened this issue Jan 10, 2025 · 0 comments
Open

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

dzhus opened this issue Jan 10, 2025 · 0 comments

Comments

@dzhus
Copy link

dzhus commented Jan 10, 2025

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)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant