Next: microhttpd-response headers, Previous: microhttpd-response enqueue, Up: microhttpd-responses [Contents][Index]
Create a response object. The response object can be extended with header information and then it can be used any number of times.
size of the data portion of the response, -1
for unknown;
preferred block size for querying crc (advisory only, MHD may still call crc using smaller chunks); this is essentially the buffer size used for IO, clients should pick a value that is appropriate for IO and memory performance requirements;
callback to use to obtain response data;
extra argument to crc;
callback to call to free crc_cls resources.
Return NULL
on error (i.e. invalid arguments, out of memory).
Create a response object. The response object can be extended with header information and then it can be used any number of times.
size of the data portion of the response (should be smaller or equal to the size of the file)
file descriptor referring to a file on disk with the data; will be closed when response is destroyed; note that ’fd’ must be an actual file descriptor (not a pipe or socket) since MHD might use ’sendfile’ or ’seek’ on it. The descriptor should be in blocking-IO mode.
Return NULL
on error (i.e. invalid arguments, out of memory).
Create a response object. The response object can be extended with header information and then it can be used ONLY ONCE.
file descriptor of the read-end of the pipe; will be closed when response is destroyed. The descriptor should be in blocking-IO mode.
Return NULL
on error (i.e. out of memory).
Create a response object. The response object can be extended with
header information and then it can be used any number of times.
Note that you need to be a bit careful about off_t
when
writing this code. Depending on your platform, MHD is likely
to have been compiled with support for 64-bit files. When you
compile your own application, you must make sure that off_t
is also a 64-bit value. If not, your compiler may pass a 32-bit
value as off_t
, which will result in 32-bits of garbage.
If you use the autotools, use the AC_SYS_LARGEFILE
autoconf
macro and make sure to include the generated config.h file
before microhttpd.h to avoid problems. If you do not have a
build system and only want to run on a GNU/Linux system, you could
also use
#define _FILE_OFFSET_BITS 64 #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <microhttpd.h>
to ensure 64-bit off_t
. Note that if your operating system
does not support 64-bit files, MHD will be compiled with a 32-bit
off_t
(in which case the above would be wrong).
size of the data portion of the response (number of bytes to transmit from the file starting at offset).
file descriptor referring to a file on disk with the data; will be closed when response is destroyed; note that ’fd’ must be an actual file descriptor (not a pipe or socket) since MHD might use ’sendfile’ or ’seek’ on it. The descriptor should be in blocking-IO mode.
offset to start reading from in the file
Return NULL
on error (i.e. invalid arguments, out of memory).
Create a response object. The response object can be extended with header information and then it can be used any number of times.
size of the data portion of the response;
the data itself;
memory management options for buffer; use MHD_RESPMEM_PERSISTENT if the buffer is static/global memory, use MHD_RESPMEM_MUST_FREE if the buffer is heap-allocated and should be freed by MHD and MHD_RESPMEM_MUST_COPY if the buffer is in transient memory (i.e. on the stack) and must be copied by MHD;
Return NULL
on error (i.e. invalid arguments, out of memory).
Create a response object. The buffer at the end must be free’d by calling the crfc function.
size of the data portion of the response;
the data itself;
function to call at the end to free memory allocated at buffer.
Return NULL
on error (i.e. invalid arguments, out of memory).
Create a response object. The response object can be extended with
header information and then it can be used any number of times.
This function is deprecated, use MHD_create_response_from_buffer
instead.
size of the data portion of the response;
the data itself;
if true: MHD should free data when done;
if true: MHD allocates a block of memory and use it to make a copy of
data embedded in the returned MHD_Response
structure;
handling of the embedded memory is responsibility of MHD; data
can be released anytime after this call returns.
Return NULL
on error (i.e. invalid arguments, out of memory).
Example: create a response from a statically allocated string:
const char * data = "<html><body><p>Error!</p></body></html>"; struct MHD_Connection * connection = ...; struct MHD_Response * response; response = MHD_create_response_from_buffer (strlen(data), data, MHD_RESPMEM_PERSISTENT); MHD_queue_response(connection, 404, response); MHD_destroy_response(response);
Next: microhttpd-response headers, Previous: microhttpd-response enqueue, Up: microhttpd-responses [Contents][Index]