Next: , Previous: , Up: microhttpd-responses   [Contents][Index]


8.3 Adding headers to a response

Function: enum MHD_Result MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content)

Add a header line to the response. The strings referenced by header and content must be zero-terminated and they are duplicated into memory blocks embedded in response.

Notice that the strings must not hold newlines, carriage returns or tab chars.

MHD_add_response_header() prevents applications from setting a “Transfer-Encoding” header to values other than “identity” or “chunked” as other transfer encodings are not supported by MHD. Note that usually MHD will pick the transfer encoding correctly automatically, but applications can use the header to force a particular behavior.

MHD_add_response_header() also prevents applications from setting a “Content-Length” header. MHD will automatically set a correct “Content-Length” header if it is possible and allowed.

Return MHD_NO on error (i.e. invalid header or content format or memory allocation error).

Function: enum MHD_Result MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content)

Add a footer line to the response. The strings referenced by footer and content must be zero-terminated and they are duplicated into memory blocks embedded in response.

Notice that the strings must not hold newlines, carriage returns or tab chars. You can add response footers at any time before signalling the end of the response to MHD (not just before calling ’MHD_queue_response’). Footers are useful for adding cryptographic checksums to the reply or to signal errors encountered during data generation. This call was introduced in MHD 0.9.3.

Return MHD_NO on error (i.e. invalid header or content format or memory allocation error).

Function: enum MHD_Result MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content)

Delete a header (or footer) line from the response. Return MHD_NO on error (arguments are invalid or no such header known).


Next: , Previous: , Up: microhttpd-responses   [Contents][Index]