views:

183

answers:

1

If you run this command:

$ curl -XHEAD -i -H "User-Agent: myuseragent" http://www.google.com
HTTP/1.1 302 Found 
... snip ...
Server: gws
Content-Length: 222
X-XSS-Protection: 0

you will notice immediately that the curl command hangs. (I am running this in cygwin/VISTA)

If you run it against twitter or facebook, curl terminates immediately. I suspect it's because twitter & facebook returns Connection: close.

In my Android 1.5 cupcake app, I am running the same command using the HttpClient framework. And I notice that the connection hangs but terminates after the timeout (Thank god for Http 4.0 !! ).

Is there an option to set in HttpClient to terminate once I've received the relevant HEAD http headers ? Thanks.

+2  A: 

Have you tried adding the "Connection: close" header to your request? That should tell the server that you don't want a persistent connection.

Jon Skeet
Will try that. I thought Connection: Close is sent only from server to client.
Jacques René Mesrine
It works! Thanks a lot.
Jacques René Mesrine