[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[libmicrohttpd] Re: Bothersome guy, me.

From: Christian Grothoff
Subject: [libmicrohttpd] Re: Bothersome guy, me.
Date: Sun, 24 Oct 2010 13:31:26 +0200
User-agent: KMail/1.13.2 (Linux/2.6.32-25-generic; KDE/4.4.2; i686; ; )

A: You are allowed to re-use response objects (if the response is exactly the 
same and your callbacks support it, etc.; that's why there is 
MHD_destroy_response after MHD_queue_response: you might still use the 
response object again), but obviously you don't have to.  In some apps, you 
might get performance benefits from re-using response objects, in others it 
might not matter.  Modifying a response (adding headers, etc.) after queuing 
it could result in undefined behavior (especially for threaded modes).

Note that if you do not set a DATE header in the response, MHD will create an 
appropriate (fresh) date header each time the response is used, so this semi-
mandatory variable component of an HTTP response does not prevent response 

Happy hacking!


On Sunday, October 24, 2010 12:13:43 pm Jakob Eriksson wrote:
> Q:
> Are you supposed to create a new response with
> MHD_create_response_from_callback each time an HTTP request comes in?
> This is what I do in my code. Or should I create the response once,
> and then just use over and over again?
>     response = MHD_create_response_from_callback(args...);
>     MHD_add_response_header(response, "Content-Type", "text/xml");
>     ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
>     MHD_destroy_response(response);
>     return ret;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]