[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [libmicrohttpd] Socket shutdown() and close() syscalls
From: |
Christian Grothoff |
Subject: |
Re: [libmicrohttpd] Socket shutdown() and close() syscalls |
Date: |
Fri, 21 Sep 2012 17:14:18 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:10.0.4) Gecko/20120510 Icedove/10.0.4 |
On 09/21/2012 04:46 PM, Enrico Migliore - FATTI srl wrote:
Hi,
I'm playing with MHD and I got 2 questions.
Question 1
----------
I noticed that MHD calls shutdown() and then close() after creating
each HTTP response. Is that correct?
Yes.
If yes, I got another question:
Since HTTP 1.1 allow the browser to issue many requests on the very
same socket, I expect MHD to keep the socket alive.
What am I missing?
The browser needs to not send "Connection: close". Also, as an
application-developer, the MHD API hides keep alive from you, so you
don't have to worry about it. Nevertheless, if the type of request
allows it, MHD will do keep alive.
Question 2
----------
I can't find in the code and in the documentation the word "Keepalive".
How MHD honors the Keepalive header which is usually present in ht
HTTP request issued by the browser?
*In HTTP 1.1*, all connections are considered persistent unless declared
otherwise. So MHD sets "Connection: close" IFF the type of request and
reply make it impossible to use keep-alive and otherwise simply assumes
that keep-alive will be used. You are free to manually (explicitly) set
this connection header for your response if you want / believe the
browser needs it. You can also set "Connection: close" to force MHD not
to use keep-alive.
You can find the respective code by looking for "Connection: close" or
just the string "close" (in double quotes) in the MHD source code.
Happy hacking!
Christian