diff options
Diffstat (limited to 'src/daemon/response.c')
-rw-r--r-- | src/daemon/response.c | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/daemon/response.c b/src/daemon/response.c index e0942700..4bbe0f36 100644 --- a/src/daemon/response.c +++ b/src/daemon/response.c | |||
@@ -38,11 +38,11 @@ MHD_add_response_header(struct MHD_Response * response, | |||
38 | const char * header, | 38 | const char * header, |
39 | const char * content) { | 39 | const char * content) { |
40 | struct MHD_HTTP_Header * hdr; | 40 | struct MHD_HTTP_Header * hdr; |
41 | 41 | ||
42 | if ( (response == NULL) || | 42 | if ( (response == NULL) || |
43 | (header == NULL) || | 43 | (header == NULL) || |
44 | (content == NULL) || | 44 | (content == NULL) || |
45 | (strlen(header) == 0) || | 45 | (strlen(header) == 0) || |
46 | (strlen(content) == 0) || | 46 | (strlen(content) == 0) || |
47 | (NULL != strstr(header, "\t")) || | 47 | (NULL != strstr(header, "\t")) || |
48 | (NULL != strstr(header, "\r")) || | 48 | (NULL != strstr(header, "\r")) || |
@@ -72,14 +72,14 @@ MHD_del_response_header(struct MHD_Response * response, | |||
72 | struct MHD_HTTP_Header * pos; | 72 | struct MHD_HTTP_Header * pos; |
73 | struct MHD_HTTP_Header * prev; | 73 | struct MHD_HTTP_Header * prev; |
74 | 74 | ||
75 | if ( (header == NULL) || | 75 | if ( (header == NULL) || |
76 | (content == NULL) ) | 76 | (content == NULL) ) |
77 | return MHD_NO; | 77 | return MHD_NO; |
78 | prev = NULL; | 78 | prev = NULL; |
79 | pos = response->first_header; | 79 | pos = response->first_header; |
80 | while (pos != NULL) { | 80 | while (pos != NULL) { |
81 | if ( (0 == strcmp(header, pos->header)) && | 81 | if ( (0 == strcmp(header, pos->header)) && |
82 | (0 == strcmp(content, pos->value)) ) { | 82 | (0 == strcmp(content, pos->value)) ) { |
83 | free(pos->header); | 83 | free(pos->header); |
84 | free(pos->value); | 84 | free(pos->value); |
85 | if (prev == NULL) | 85 | if (prev == NULL) |
@@ -102,7 +102,7 @@ MHD_del_response_header(struct MHD_Response * response, | |||
102 | * maybe NULL (then just count headers) | 102 | * maybe NULL (then just count headers) |
103 | * @param iterator_cls extra argument to iterator | 103 | * @param iterator_cls extra argument to iterator |
104 | * @return number of entries iterated over | 104 | * @return number of entries iterated over |
105 | */ | 105 | */ |
106 | int | 106 | int |
107 | MHD_get_response_headers(struct MHD_Response * response, | 107 | MHD_get_response_headers(struct MHD_Response * response, |
108 | MHD_KeyValueIterator iterator, | 108 | MHD_KeyValueIterator iterator, |
@@ -129,7 +129,7 @@ MHD_get_response_headers(struct MHD_Response * response, | |||
129 | * | 129 | * |
130 | * @param key which header to get | 130 | * @param key which header to get |
131 | * @return NULL if header does not exist | 131 | * @return NULL if header does not exist |
132 | */ | 132 | */ |
133 | const char * | 133 | const char * |
134 | MHD_get_response_header(struct MHD_Response * response, | 134 | MHD_get_response_header(struct MHD_Response * response, |
135 | const char * key) { | 135 | const char * key) { |
@@ -162,7 +162,7 @@ MHD_create_response_from_callback(size_t size, | |||
162 | MHD_ContentReaderFreeCallback crfc) { | 162 | MHD_ContentReaderFreeCallback crfc) { |
163 | struct MHD_Response * retVal; | 163 | struct MHD_Response * retVal; |
164 | 164 | ||
165 | if (crc == NULL) | 165 | if (crc == NULL) |
166 | return NULL; | 166 | return NULL; |
167 | retVal = malloc(sizeof(struct MHD_Response)); | 167 | retVal = malloc(sizeof(struct MHD_Response)); |
168 | memset(retVal, | 168 | memset(retVal, |
@@ -187,7 +187,7 @@ MHD_create_response_from_callback(size_t size, | |||
187 | * @param size size of the data portion of the response | 187 | * @param size size of the data portion of the response |
188 | * @param data the data itself | 188 | * @param data the data itself |
189 | * @param must_free libmicrohttpd should free data when done | 189 | * @param must_free libmicrohttpd should free data when done |
190 | * @param must_copy libmicrohttpd must make a copy of data | 190 | * @param must_copy libmicrohttpd must make a copy of data |
191 | * right away, the data maybe released anytime after | 191 | * right away, the data maybe released anytime after |
192 | * this call returns | 192 | * this call returns |
193 | * @return NULL on error (i.e. invalid arguments, out of memory) | 193 | * @return NULL on error (i.e. invalid arguments, out of memory) |
@@ -199,7 +199,7 @@ MHD_create_response_from_data(size_t size, | |||
199 | int must_copy) { | 199 | int must_copy) { |
200 | struct MHD_Response * retVal; | 200 | struct MHD_Response * retVal; |
201 | void * tmp; | 201 | void * tmp; |
202 | 202 | ||
203 | if ( (data == NULL) && | 203 | if ( (data == NULL) && |
204 | (size > 0) ) | 204 | (size > 0) ) |
205 | return NULL; | 205 | return NULL; |
@@ -215,11 +215,11 @@ MHD_create_response_from_data(size_t size, | |||
215 | (size > 0) ) { | 215 | (size > 0) ) { |
216 | tmp = malloc(size); | 216 | tmp = malloc(size); |
217 | memcpy(tmp, | 217 | memcpy(tmp, |
218 | data, | 218 | data, |
219 | size); | 219 | size); |
220 | must_free = 1; | 220 | must_free = 1; |
221 | data = tmp; | 221 | data = tmp; |
222 | } | 222 | } |
223 | retVal->crc = NULL; | 223 | retVal->crc = NULL; |
224 | retVal->crfc = must_free ? &free : NULL; | 224 | retVal->crfc = must_free ? &free : NULL; |
225 | retVal->crc_cls = must_free ? data : NULL; | 225 | retVal->crc_cls = must_free ? data : NULL; |
@@ -240,10 +240,10 @@ void | |||
240 | MHD_destroy_response(struct MHD_Response * response) { | 240 | MHD_destroy_response(struct MHD_Response * response) { |
241 | struct MHD_HTTP_Header * pos; | 241 | struct MHD_HTTP_Header * pos; |
242 | 242 | ||
243 | if (response == NULL) | 243 | if (response == NULL) |
244 | return; | 244 | return; |
245 | pthread_mutex_lock(&response->mutex); | 245 | pthread_mutex_lock(&response->mutex); |
246 | if (0 != --response->reference_count) { | 246 | if (0 != --response->reference_count) { |
247 | pthread_mutex_unlock(&response->mutex); | 247 | pthread_mutex_unlock(&response->mutex); |
248 | return; | 248 | return; |
249 | } | 249 | } |
@@ -252,7 +252,7 @@ MHD_destroy_response(struct MHD_Response * response) { | |||
252 | if (response->crfc != NULL) | 252 | if (response->crfc != NULL) |
253 | response->crfc(response->crc_cls); | 253 | response->crfc(response->crc_cls); |
254 | while (response->first_header != NULL) { | 254 | while (response->first_header != NULL) { |
255 | pos = response->first_header; | 255 | pos = response->first_header; |
256 | response->first_header = pos->next; | 256 | response->first_header = pos->next; |
257 | free(pos->header); | 257 | free(pos->header); |
258 | free(pos->value); | 258 | free(pos->value); |