GNU libmicrohttpd 0.9.5
|
Methods for managing response objects. More...
Go to the source code of this file.
Functions | |
static int | add_response_entry (struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, const char *content) |
int | MHD_add_response_header (struct MHD_Response *response, const char *header, const char *content) |
int | MHD_add_response_footer (struct MHD_Response *response, const char *footer, const char *content) |
int | MHD_del_response_header (struct MHD_Response *response, const char *header, const char *content) |
int | MHD_get_response_headers (struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls) |
const char * | MHD_get_response_header (struct MHD_Response *response, const char *key) |
struct MHD_Response * | MHD_create_response_from_callback (uint64_t size, size_t block_size, MHD_ContentReaderCallback crc, void *crc_cls, MHD_ContentReaderFreeCallback crfc) |
static ssize_t | file_reader (void *cls, uint64_t pos, char *buf, size_t max) |
static void | free_callback (void *cls) |
struct MHD_Response * | MHD_create_response_from_fd_at_offset (size_t size, int fd, off_t offset) |
struct MHD_Response * | MHD_create_response_from_fd (size_t size, int fd) |
struct MHD_Response * | MHD_create_response_from_data (size_t size, void *data, int must_free, int must_copy) |
struct MHD_Response * | MHD_create_response_from_buffer (size_t size, void *buffer, enum MHD_ResponseMemoryMode mode) |
void | MHD_destroy_response (struct MHD_Response *response) |
void | MHD_increment_response_rc (struct MHD_Response *response) |
Methods for managing response objects.
Definition in file response.c.
static int add_response_entry | ( | struct MHD_Response * | response, |
enum MHD_ValueKind | kind, | ||
const char * | header, | ||
const char * | content | ||
) | [static] |
Add a header or footer line to the response.
response | response to add a header to |
kind | header or footer |
header | the header to add |
content | value to add |
Definition at line 41 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::kind, MHD_NO, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
Referenced by MHD_add_response_footer(), and MHD_add_response_header().
static ssize_t file_reader | ( | void * | cls, |
uint64_t | pos, | ||
char * | buf, | ||
size_t | max | ||
) | [static] |
Given a file descriptor, read data from the file to generate the response.
cls | pointer to the response |
pos | offset in the file to access |
buf | where to write the data |
max | number of bytes to write at most |
Definition at line 270 of file response.c.
References MHD_Response::fd, and MHD_Response::fd_off.
Referenced by MHD_create_response_from_fd_at_offset().
static void free_callback | ( | void * | cls | ) | [static] |
Destroy file reader context. Closes the file descriptor.
cls | pointer to file descriptor |
Definition at line 286 of file response.c.
References MHD_Response::fd.
Referenced by MHD_create_response_from_fd_at_offset().
int MHD_add_response_footer | ( | struct MHD_Response * | response, |
const char * | footer, | ||
const char * | content | ||
) |
Add a footer line to the response.
response | response to remove a header from |
footer | the footer to delete |
content | value to delete |
Definition at line 110 of file response.c.
References add_response_entry(), and MHD_FOOTER_KIND.
int MHD_add_response_header | ( | struct MHD_Response * | response, |
const char * | header, | ||
const char * | content | ||
) |
Add a header line to the response.
response | response to add a header to |
header | the header to add |
content | value to add |
Definition at line 91 of file response.c.
References add_response_entry(), and MHD_HEADER_KIND.
Referenced by add_extra_headers(), MHD_queue_auth_fail_response(), and MHD_queue_basic_auth_fail_response().
struct MHD_Response* MHD_create_response_from_buffer | ( | size_t | size, |
void * | buffer, | ||
enum MHD_ResponseMemoryMode | mode | ||
) | [read] |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
buffer | size bytes containing the response's data portion |
mode | flags for buffer management |
Definition at line 406 of file response.c.
References MHD_create_response_from_data(), MHD_RESPMEM_MUST_COPY, and MHD_RESPMEM_MUST_FREE.
Referenced by parse_connection_headers(), and transmit_error_response().
struct MHD_Response* MHD_create_response_from_callback | ( | uint64_t | size, |
size_t | block_size, | ||
MHD_ContentReaderCallback | crc, | ||
void * | crc_cls, | ||
MHD_ContentReaderFreeCallback | crfc | ||
) | [read] |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response, MHD_SIZE_UNKNOWN for unknown |
block_size | 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 |
crc | callback to use to obtain response data |
crc_cls | extra argument to crc |
crfc | callback to call to free crc_cls resources |
Definition at line 228 of file response.c.
References MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::data, MHD_Response::data_buffer_size, MHD_Response::fd, MHD_Response::mutex, NULL, MHD_Response::reference_count, and MHD_Response::total_size.
Referenced by MHD_create_response_from_fd_at_offset().
struct MHD_Response* MHD_create_response_from_data | ( | size_t | size, |
void * | data, | ||
int | must_free, | ||
int | must_copy | ||
) | [read] |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
data | the data itself |
must_free | libmicrohttpd should free data when done |
must_copy | libmicrohttpd must make a copy of data right away, the data maybe released anytime after this call returns |
Definition at line 354 of file response.c.
References MHD_Response::crc, MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::data, MHD_Response::data_size, MHD_Response::fd, MHD_YES, MHD_Response::mutex, NULL, MHD_Response::reference_count, and MHD_Response::total_size.
Referenced by MHD_create_response_from_buffer().
struct MHD_Response* MHD_create_response_from_fd | ( | size_t | size, |
int | fd | ||
) | [read] |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
fd | file descriptor referring to a file on disk with the data |
Definition at line 333 of file response.c.
References MHD_create_response_from_fd_at_offset().
struct MHD_Response* MHD_create_response_from_fd_at_offset | ( | size_t | size, |
int | fd, | ||
off_t | offset | ||
) | [read] |
Create a response object. The response object can be extended with header information and then be used any number of times.
size | size of the data portion of the response |
fd | file descriptor referring to a file on disk with the data |
off | offset to start reading from in the file |
Definition at line 303 of file response.c.
References MHD_Response::crc_cls, MHD_Response::fd, MHD_Response::fd_off, file_reader(), free_callback(), MHD_create_response_from_callback(), and NULL.
Referenced by MHD_create_response_from_fd().
int MHD_del_response_header | ( | struct MHD_Response * | response, |
const char * | header, | ||
const char * | content | ||
) |
Delete a header line from the response.
response | response to remove a header from |
header | the header to delete |
content | value to delete |
Definition at line 129 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_NO, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
void MHD_destroy_response | ( | struct MHD_Response * | response | ) |
Destroy a response object and associated resources. Note that libmicrohttpd 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 immediatley.
Definition at line 424 of file response.c.
References MHD_Response::crc_cls, MHD_Response::crfc, MHD_Response::first_header, MHD_HTTP_Header::header, MHD_Response::mutex, MHD_HTTP_Header::next, NULL, MHD_Response::reference_count, and MHD_HTTP_Header::value.
Referenced by MHD_cleanup_connections(), MHD_connection_handle_idle(), parse_connection_headers(), and transmit_error_response().
const char* MHD_get_response_header | ( | struct MHD_Response * | response, |
const char * | key | ||
) |
Get a particular header from the response.
key | which header to get |
Definition at line 195 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
Referenced by add_extra_headers(), and build_header_response().
int MHD_get_response_headers | ( | struct MHD_Response * | response, |
MHD_KeyValueIterator | iterator, | ||
void * | iterator_cls | ||
) |
Get all of the headers added to a response.
iterator | callback to call on each header; maybe NULL (then just count headers) |
iterator_cls | extra argument to iterator |
Definition at line 169 of file response.c.
References MHD_Response::first_header, MHD_HTTP_Header::header, MHD_HTTP_Header::kind, MHD_YES, MHD_HTTP_Header::next, NULL, and MHD_HTTP_Header::value.
void MHD_increment_response_rc | ( | struct MHD_Response * | response | ) |
Increment response RC. Should this be part of the public API?
Definition at line 453 of file response.c.
References MHD_Response::mutex, and MHD_Response::reference_count.
Referenced by MHD_queue_response().