-1

I am fairly new to HTTP and pardon me if the question looks stupid. I cant get my head around the HTTP keepalive logic. I am studying HTTP definitive guide.

We send multiple requests , response over a single tcp connection is clear , but how this works with proxy is not getting through my head. Proxy is not supposed to forward keepalive header(this is hop by hop) , then how server will know then connection has to be open ? If the server doesnt know , it will send a close in response packet ? So how does the client side connection still forward more requests on the same tcp connection.

Example

client(10.0.0.1)---------Proxy(1.1.1.1)----------(1.1.1.5)Server

client sends request with connection: keepalive to 1.1.1.5 . Proxy receives and : 1) forwards it blindly if HTTP/1.0 2) Proxy sends connection 1.1.1.1 -> 1.1.1.5 to server , is the connection: keepalive sent or not ?

It says proxy do not cache or forward connection and keepalive headers , then how does server know it shoud keep it open or close it.

Please help.... I am kinda lost here

1 Answer 1

1

Hop-by-hop only means that the proxy is free to change the header as it sees fit and interpret it immediately; the header should not be forwarded without interpretation.

The default for HTTP/1.1 is persistent connections unless one of the parties on a connection (either client-to-proxy or proxy-to-server) specifies the Connection: close header. This header is connection-specific and has no bearing on the other connection in a client-proxy-server loop.

Thus the proxy may establish a persistent connection with the origin server or specify Connection: close regardless of what the client specified in Connection. Similarly, if the origin server sends Connection: close, the proxy is not required to forward that header back to the client, who can then make further requests on the still-alive client-to-proxy connection.

The only thing that is forbidden is sending Keep-Alive to an http/1.0 proxy as they were not required to interpret the Keep-Alive and Connection headers, because this can lock up a dumb proxy.

RFC 2616 section 13.5.1 specifies all the headers that must be handled hop-by-hop (not cached, not forwarded).

1
  • thank you for the response . so if i understand correctly . Extensions to HTTP 1. 0 included keepalive option , so this could LOCK UP dumb proxies on 1.0 . Reading up definitive guide , it looks like it is not defined correctly , to quote directly it says "To avoid this kind of proxy miscommunication, modern proxies must never proxy the Connection header or any headers whose names appear inside the Connection values. So if a proxy receives a Connection: Keep-Alive header, it shouldn’t proxy either the Connection header or any headers named Keep-Alive" . Proxy however can forward as you said
    – Priyanka
    Nov 20, 2014 at 8:08

Not the answer you're looking for? Browse other questions tagged .