48 if ( (
NULL == response) ||
51 (0 == strlen (header)) ||
52 (0 == strlen (content)) ||
53 (
NULL != strchr (header,
'\t')) ||
54 (
NULL != strchr (header,
'\r')) ||
55 (
NULL != strchr (header,
'\n')) ||
56 (
NULL != strchr (content,
'\t')) ||
57 (
NULL != strchr (content,
'\r')) ||
58 (
NULL != strchr (content,
'\n')) )
67 if (
NULL == (hdr->
value = strdup (content)))
91 const char *
header,
const char *content)
111 const char *footer,
const char *content)
137 if ( (
NULL == header) || (
NULL == content) )
143 if ((0 == strcmp (header, pos->
header)) &&
144 (0 == strcmp (content, pos->
value)))
182 if ((
NULL != iterator) &&
183 (
MHD_YES != iterator (iterator_cls,
208 if (0 == strcmp (key, pos->
header))
239 if ((
NULL == crc) || (0 == block_size))
241 if (
NULL == (response = malloc (
sizeof (
struct MHD_Response) + block_size)))
245 response->
data = (
void *) &response[1];
247 if (0 != pthread_mutex_init (&response->
mutex,
NULL))
277 (void) lseek (response->
fd, pos + response->
fd_off, SEEK_SET);
278 n = read (response->
fd, buf, max);
298 (void) close (response->
fd);
331 if (
NULL == response)
334 response->
fd_off = offset;
373 void *
data,
int must_free,
int must_copy)
378 if ((
NULL == data) && (size > 0))
384 if (0 != pthread_mutex_init (&response->
mutex,
NULL))
389 if ((must_copy) && (size > 0))
391 if (
NULL == (tmp = malloc (size)))
393 pthread_mutex_destroy (&response->
mutex);
397 memcpy (tmp, data, size);
402 response->
crfc = must_free ? &free :
NULL;
448 if (
NULL == response)
450 pthread_mutex_lock (&response->
mutex);
453 pthread_mutex_unlock (&response->
mutex);
456 pthread_mutex_unlock (&response->
mutex);
457 pthread_mutex_destroy (&response->
mutex);
475 pthread_mutex_lock (&response->
mutex);
477 pthread_mutex_unlock (&response->
mutex);
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
_MHD_EXTERN 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 void free_callback(void *cls)
_MHD_EXTERN int MHD_add_response_header(struct MHD_Response *response, const char *header, const char *content)
MHD_ContentReaderFreeCallback crfc
void(* MHD_ContentReaderFreeCallback)(void *cls)
static ssize_t file_reader(void *cls, uint64_t pos, char *buf, size_t max)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset(size_t size, int fd, off_t offset)
struct MHD_HTTP_Header * first_header
Methods for managing response objects.
#define MHD_INVALID_SOCKET
internal shared structures
_MHD_EXTERN int MHD_add_response_footer(struct MHD_Response *response, const char *footer, const char *content)
unsigned int reference_count
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
void MHD_increment_response_rc(struct MHD_Response *response)
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
#define MHD_CONTENT_READER_END_OF_STREAM
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd(size_t size, int fd)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_buffer(size_t size, void *buffer, enum MHD_ResponseMemoryMode mode)
static int add_response_entry(struct MHD_Response *response, enum MHD_ValueKind kind, const char *header, const char *content)
#define MHD_CONTENT_READER_END_WITH_ERROR
MHD_ContentReaderCallback crc
_MHD_EXTERN int MHD_del_response_header(struct MHD_Response *response, const char *header, const char *content)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_data(size_t size, void *data, int must_free, int must_copy)
_MHD_EXTERN const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
_MHD_EXTERN int MHD_get_response_headers(struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)