Hendrik, thank you - that solved the problem. Now, I have a new one however:
The client -> proxy connection is kept alive correctly. The proxy ->
server connection, however, is not. Squid closes the connection to the
server after the client issues a second request. After that, Squid opens
a new connection to the server and sends the second request over a new
connection.
You can reproduce this using two netcats - a client and a server netcat.
This is the client netcat output ('>' at the beginning of the line means
sent data, '<' means received data)
$ nc localhost 3128
>POST http://127.0.0.1:300/ HTTP/1.1
>Host: 127.0.0.1
>Content-Type: application/x-www-form-urlencoded
>Proxy-Connection: Keep-Alive
>Content-Length: 40
>
>d=%3e3900%0a10%3aeNrz8QwO4eUCAAWnAVQA%0a
<HTTP/1.0 200 OK
<Content-Type: text/html
<Content-Length: 8
<X-Cache: MISS from badda
<X-Cache-Lookup: MISS from badda:3128
<Via: 1.0 badda:3128 (squid/2.6.STABLE12)
<Proxy-Connection: keep-alive
<
<3900 OK
>POST http://127.0.0.1:300/ HTTP/1.1
>Host: 127.0.0.1
>Content-Type: application/x-www-form-urlencoded
>Proxy-Connection: Keep-Alive
>Content-Length: 40
>
>d=%3e3900%0a10%3aeNrz8QwO4eUCAAWnAVQA%0a
<HTTP/1.0 503 Service Unavailable
<......
Now squid sends an error page and ends the connection
This is the server netcat output
$ nc -l -p 300
<POST / HTTP/1.0
<Host: 127.0.0.1:300
<Content-Type: application/x-www-form-urlencoded
<Content-Length: 40
<Via: 1.1 badda:3128 (squid/2.6.STABLE12)
<X-Forwarded-For: 127.0.0.1
<Cache-Control: max-age=259200
<Connection: keep-alive
<
<d=%3e3900%0a10%3aeNrz8QwO4eUCAAWnAVQA%0a
>HTTP/1.1 200 OK
>Connection: Keep-Alive
>Content-Type: text/html
>Content-Length: 8
>
>3900 OK
>
here, the connection breaks and netcat returns to the command prompt.
Squid breaks the proxy->server connection exactly at the moment when the
second request is issued.
Is this a bug or am I doing something wrong?
Regards, Sebastian
Henrik Nordstrom wrote:
The response to the POST request must be HTTP/1.0 keep-alive compatible,
i.e. have a Content-Length.
Your response do not have a Content-Length, and therefore HTTP/1.0
keep-alive can not be used as the only method available for terminating
the response is to close the connection.
Regards
Henrik