27 #define MHD_NO_DEPRECATION 1 33 #if defined(_WIN32) && defined(MHD_W32_MUTEX_) 34 #ifndef WIN32_LEAN_AND_MEAN 35 #define WIN32_LEAN_AND_MEAN 1 61 if ( (
NULL == response) ||
64 (0 == strlen (header)) ||
65 (0 == strlen (content)) ||
66 (
NULL != strchr (header,
'\t')) ||
67 (
NULL != strchr (header,
'\r')) ||
68 (
NULL != strchr (header,
'\n')) ||
69 (
NULL != strchr (content,
'\t')) ||
70 (
NULL != strchr (content,
'\r')) ||
71 (
NULL != strchr (content,
'\n')) )
80 if (
NULL == (hdr->
value = strdup (content)))
104 const char *
header,
const char *content)
124 const char *footer,
const char *content)
150 if ( (
NULL == header) || (
NULL == content) )
156 if ((0 == strcmp (header, pos->
header)) &&
157 (0 == strcmp (content, pos->
value)))
195 if ((
NULL != iterator) &&
196 (
MHD_YES != iterator (iterator_cls,
221 if (0 == strcmp (key, pos->
header))
252 if ((
NULL == crc) || (0 == block_size))
254 if (
NULL == (response = malloc (
sizeof (
struct MHD_Response) + block_size)))
258 response->
data = (
void *) &response[1];
293 va_start (ap, flags);
323 const int64_t offset64 = (int64_t)(pos + response->
fd_off);
328 #if defined(HAVE_LSEEK64) 329 if (lseek64 (response->
fd, offset64, SEEK_SET) != offset64)
331 #elif defined(HAVE___LSEEKI64) 332 if (_lseeki64 (response->
fd, offset64, SEEK_SET) != offset64)
335 if (
sizeof(off_t) <
sizeof(uint64_t) && offset64 > (uint64_t)
INT32_MAX)
338 if (lseek (response->
fd, (off_t)offset64, SEEK_SET) != (off_t)offset64)
346 n = read (response->
fd, buf, max);
351 n = read (response->
fd, buf, (
unsigned int)max);
373 (void) close (response->
fd);
377 #undef MHD_create_response_from_fd_at_offset 427 #if !defined(HAVE___LSEEKI64) && !defined(HAVE_LSEEK64) 428 if (
sizeof(uint64_t) >
sizeof(off_t) &&
432 if ((int64_t)size < 0 || (int64_t)offset < 0 || (int64_t)(size + offset) < 0)
440 if (
NULL == response)
508 if ((
NULL == data) && (size > 0))
519 if ((must_copy) && (size > 0))
521 if (
NULL == (tmp = malloc (size)))
523 (void) MHD_mutex_destroy_ (&response->
mutex);
527 memcpy (tmp, data, size);
532 response->
crfc = must_free ? &free :
NULL;
578 if (
NULL == response)
580 (void) MHD_mutex_lock_ (&response->
mutex);
583 (void) MHD_mutex_unlock_ (&response->
mutex);
586 (void) MHD_mutex_unlock_ (&response->
mutex);
587 (void) MHD_mutex_destroy_ (&response->
mutex);
605 (void) MHD_mutex_lock_ (&response->
mutex);
607 (void) MHD_mutex_unlock_ (&response->
mutex);
int(* MHD_KeyValueIterator)(void *cls, enum MHD_ValueKind kind, const char *key, const char *value)
int MHD_set_response_options(struct MHD_Response *response, enum MHD_ResponseFlags flags,...)
_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_fd64(uint64_t size, int fd)
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)
_MHD_EXTERN struct MHD_Response * MHD_create_response_from_fd_at_offset64(uint64_t size, int fd, uint64_t offset)
ssize_t(* MHD_ContentReaderCallback)(void *cls, uint64_t pos, char *buf, size_t max)
unsigned int reference_count
_MHD_EXTERN void MHD_destroy_response(struct MHD_Response *response)
void MHD_increment_response_rc(struct MHD_Response *response)
#define MHD_CONTENT_READER_END_OF_STREAM
struct MHD_Response * MHD_create_response_from_data(size_t size, void *data, int must_free, int must_copy)
limits values definitions
_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
#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 const char * MHD_get_response_header(struct MHD_Response *response, const char *key)
struct MHD_Response * MHD_create_response_from_fd_at_offset(size_t size, int fd, off_t offset)
_MHD_EXTERN int MHD_get_response_headers(struct MHD_Response *response, MHD_KeyValueIterator iterator, void *iterator_cls)