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

Reply via email to