This is normal behavior for the request configuration you have.
It has to do with HTTP persistent connections.
Jetty 6's servlet tester defaulted to HTTP/1.0 behavior.
HTTP/1.0 has no official specification for persistent connections, but clients have evolved over the years to adopt a non-persistent behavior, which can be overridden with a negotiated Connection
header.
With HTTP/1.0, its 1 request, then 1 response, then connection is closed. Unless the client sends a Connection: Keep-Alive
header (and the server responds with the same header)
Jetty 9's HttpTester also defaults to HTTP/1.0.
You specified request.setVersion("HTTP/1.1");
in your example, where all connections are considered persistent unless declared otherwise. So adding Connection: close
will force the server to close the connection after the response has been sent, not waiting for another request.
So you have 2 options here:
- Stick with HTTP/1.1 and also add
request.setHeader("Connection", "close");
- or downgrade your HTTP version to 1.0. using either:
request.setVersion("HTTP/1.0");
- or comment out the call to
request.setVersion();
and rely on default behavior.