Next: microhttpd-response create, Up: microhttpd-responses [Contents][Index]
Queue a response to be transmitted to the client as soon as possible but only after MHD_AccessHandlerCallback returns. This function checks that it is legal to queue a response at this time for the given connection. It also increments the internal reference counter for the response object (the counter will be decremented automatically once the response has been transmitted).
the connection identifying the client;
HTTP status code (i.e. 200
for OK);
response to transmit.
Return MHD_YES
on success or if message has been queued. Return
MHD_NO
: if arguments are invalid (example: NULL
pointer); on
error (i.e. reply already sent).
Destroy a response object and associated resources (decrement the reference counter). Note that MHD may keep some of the resources around if the response is still in the queue for some clients, so the memory may not necessarily be freed immediately.
An explanation of reference counting1:
MHD_Response
object is allocated:
struct MHD_Response * response = MHD_create_response_from_buffer(...); /* here: reference counter = 1 */
MHD_Response
object is enqueued in a MHD_Connection
:
MHD_queue_response(connection, , response); /* here: reference counter = 2 */
MHD_destroy_response(response); /* here: reference counter = 1 */
MHD_destroy_response()
: the counter’s value drops to zero and
the MHD_Response
object is released.
Note to readers acquainted
to the Tcl API: reference counting on MHD_Connection
structures is handled in the same way as Tcl handles Tcl_Obj
structures through Tcl_IncrRefCount()
and
Tcl_DecrRefCount()
.
Next: microhttpd-response create, Up: microhttpd-responses [Contents][Index]