30 #if defined(_WIN32) && defined(MHD_W32_MUTEX_)
31 #ifndef WIN32_LEAN_AND_MEAN
32 #define WIN32_LEAN_AND_MEAN 1
58 if ( (
NULL == response) ||
61 (0 == strlen (header)) ||
62 (0 == strlen (content)) ||
63 (
NULL != strchr (header,
'\t')) ||
64 (
NULL != strchr (header,
'\r')) ||
65 (
NULL != strchr (header,
'\n')) ||
66 (
NULL != strchr (content,
'\t')) ||
67 (
NULL != strchr (content,
'\r')) ||
68 (
NULL != strchr (content,
'\n')) )
77 if (
NULL == (hdr->
value = strdup (content)))
101 const char *
header,
const char *content)
121 const char *footer,
const char *content)
147 if ( (
NULL == header) || (
NULL == content) )
153 if ((0 == strcmp (header, pos->
header)) &&
154 (0 == strcmp (content, pos->
value)))
192 if ((
NULL != iterator) &&
193 (
MHD_YES != iterator (iterator_cls,
218 if (0 == strcmp (key, pos->
header))
249 if ((
NULL == crc) || (0 == block_size))
251 if (
NULL == (response = malloc (
sizeof (
struct MHD_Response) + block_size)))
255 response->
data = (
void *) &response[1];
290 va_start (ap, flags);
321 (void) lseek (response->
fd, pos + response->
fd_off, SEEK_SET);
322 n = read (response->
fd, buf, max);
342 (void) close (response->
fd);
375 if (
NULL == response)
378 response->
fd_off = offset;
417 void *
data,
int must_free,
int must_copy)
422 if ((
NULL == data) && (size > 0))
433 if ((must_copy) && (size > 0))
435 if (
NULL == (tmp = malloc (size)))
437 (void) MHD_mutex_destroy_ (&response->
mutex);
441 memcpy (tmp, data, size);
446 response->
crfc = must_free ? &free :
NULL;
492 if (
NULL == response)
494 (void) MHD_mutex_lock_ (&response->
mutex);
497 (void) MHD_mutex_unlock_ (&response->
mutex);
500 (void) MHD_mutex_unlock_ (&response->
mutex);
501 (void) MHD_mutex_destroy_ (&response->
mutex);
519 (void) MHD_mutex_lock_ (&response->
mutex);
521 (void) MHD_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.
Signatures for IO functions.
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)
enum MHD_ResponseFlags flags
_MHD_EXTERN int MHD_set_response_options(struct MHD_Response *response, enum MHD_ResponseFlags flags,...)
#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)