To create a comet connection (hanging get) i am not specifying the content-length in HTTP Header. This works on my system but will requested from another machine of institute LAN, it gives 502 Bad Gateway for the request.
If i mention content-length, i get the response but the connection gets closed, which i dont want. What can be the alternatives to this?
Follow the HTTP/1.1 specification for connection persistence. Return
HTTP/1.1in the reply. If the query was HTTP/1.1, default to keeping the connection open. If the query wasn’t, default to closing it. If you get aConnection: closeheader, close the connection after sending the response. If you get aConnection: keep-aliveheader, keep the connection open even if that wasn’t the protocol default.If you don’t want to follow
HTTP/1.1, you can probably get connection persistence anyway. Just always include aConnection: Keep-Aliveheader if you successfully establish persistence through the rules above. Send aConnection: Closeheader if you cannot support a persistent connection even though the client requested one.Basically, follow the HTTP specification. If you know the content length, you should always send a
Content-Lengthheader. Use the persistence negotiation rules to establish a persistent connection if the client can support one.