aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/response.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-06-13 01:12:50 +0000
committerChristian Grothoff <christian@grothoff.org>2007-06-13 01:12:50 +0000
commitbaa26cd045be80620924ce41ea506bc8b043f8c7 (patch)
tree1217606ace7801f488a4b272097408a998ea53a4 /src/daemon/response.c
parent39eda678e0942382936ace4480a4457a837adc2f (diff)
downloadlibmicrohttpd-baa26cd045be80620924ce41ea506bc8b043f8c7.tar.gz
libmicrohttpd-baa26cd045be80620924ce41ea506bc8b043f8c7.zip
fixing compile errors
Diffstat (limited to 'src/daemon/response.c')
-rw-r--r--src/daemon/response.c88
1 files changed, 4 insertions, 84 deletions
diff --git a/src/daemon/response.c b/src/daemon/response.c
index a26b003b..1584dbfd 100644
--- a/src/daemon/response.c
+++ b/src/daemon/response.c
@@ -26,91 +26,11 @@
26 * @version 0.1.0 26 * @version 0.1.0
27 */ 27 */
28 28
29
30#include <stdio.h>
31#include <stdlib.h>
32#include <netdb.h>
33#include <string.h>
34#include <unistd.h>
35#include <stdarg>
36#include <fcntl.h>
37#include <pthread.h>
38#include <netinet/in.h>
39
40#include "microhttpd.h" 29#include "microhttpd.h"
41#include "response.h" 30#include "response.h"
42#include "internal.h" 31#include "internal.h"
43#include "config.h" 32#include "config.h"
44 33
45
46/**
47 * Representation of a response.
48 */
49struct MHD_Response {
50
51 /**
52 * Headers to send for the response. Initially
53 * the linked list is created in inverse order;
54 * the order should be inverted before sending!
55 */
56 struct MHD_HTTP_Header * first_header;
57
58 /**
59 * Buffer pointing to data that we are supposed
60 * to send as a response.
61 */
62 void * data;
63
64 /**
65 * Closure to give to the content reader
66 * free callback.
67 */
68 void * crc_cls;
69
70 /**
71 * How do we get more data? NULL if we are
72 * given all of the data up front.
73 */
74 MHD_ContentReaderCallback crc;
75
76 /**
77 * NULL if data must not be freed, otherwise
78 * either user-specified callback or "&free".
79 */
80 MHD_ContentReaderFreeCallback crfc;
81
82 /**
83 * Mutex to synchronize access to data/size and
84 * reference counts.
85 */
86 pthread_mutex_t mutex;
87
88 /**
89 * Reference count for this response. Free
90 * once the counter hits zero.
91 */
92 unsigned int reference_count;
93
94 /**
95 * Set to -1 if size is not known.
96 */
97 size_t total_size;
98
99 /**
100 * Size of data.
101 */
102 size_t data_size;
103
104 /**
105 * At what offset in the stream is the
106 * beginning of data located?
107 */
108 size_t data_start;
109
110};
111
112
113
114/** 34/**
115 * Add a header line to the response. 35 * Add a header line to the response.
116 * 36 *
@@ -134,9 +54,9 @@ MHD_add_response_header(struct MHD_Response * response,
134 (NULL != strstr(content, "\r")) || 54 (NULL != strstr(content, "\r")) ||
135 (NULL != strstr(content, "\n")) ) 55 (NULL != strstr(content, "\n")) )
136 return MHD_NO; 56 return MHD_NO;
137 hdr = malloc(sizeof(MHD_HTTP_Header)); 57 hdr = malloc(sizeof(struct MHD_HTTP_Header));
138 hdr->header = STRDUP(header); 58 hdr->header = strdup(header);
139 hdr->value = STRDUP(content); 59 hdr->value = strdup(content);
140 hdr->kind = MHD_HEADER_KIND; 60 hdr->kind = MHD_HEADER_KIND;
141 hdr->next = response->first_header; 61 hdr->next = response->first_header;
142 response->first_header = hdr; 62 response->first_header = hdr;
@@ -188,7 +108,7 @@ MHD_del_response_header(struct MHD_Response * response,
188 */ 108 */
189int 109int
190MHD_get_response_headers(struct MHD_Response * response, 110MHD_get_response_headers(struct MHD_Response * response,
191 MHD_KeyValueIterator * iterator, 111 MHD_KeyValueIterator iterator,
192 void * iterator_cls) { 112 void * iterator_cls) {
193 struct MHD_HTTP_Header * pos; 113 struct MHD_HTTP_Header * pos;
194 int numHeaders = 0; 114 int numHeaders = 0;