Folks,

while working on BZ-63835 I have noticed an odd thing and I'd like someone to review whether my code/understanding is wrong or the one already present in Tomcat.

Note: The same code path in HTTPd behaves corectly.

Consider this output received by curl:

HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=300, max=100
Connection: keep-alive

HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=300, max=99
Connection: keep-alive

HTTP/1.1 302

...
>
HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=300, max=2
Connection: keep-alive

HTTP/1.1 302

Transfer-Encoding: chunked
Connection: close

we have a total of 100 requests (HTTP/1.1 302). I'd assume the connection to sustain 100 requests and on the n+1 requests to be closed.

This is caused by
} else if (maxKeepAliveRequests > 0 &&
        socketWrapper.decrementKeepAlive() <= 0) {
    keepAlive = false;
}

while decrementKeepAlive() being a predecrement, chopping off the current request.
Making this postdecrement the outcome is as expected:

HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=20, max=100
Connection: keep-alive

HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=20, max=99
Connection: keep-alive

...

HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=20, max=2
Connection: keep-alive

HTTP/1.1 302

Transfer-Encoding: chunked
Keep-Alive: timeout=20, max=1
Connection: keep-alive

HTTP/1.1 302

Transfer-Encoding: chunked
Connection: close

having 101 requests in total, matching HTTPd behavior.

The expired header proposal says:
   The value of the "max" parameter counts the number of requests since
   the connection was created.

My code is here:
https://github.com/apache/tomcat/commit/a5e3e1d7a498a3156350ae8bbed36706b2600e64

Am I wrong?

Michael

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

Reply via email to