aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2007-08-07 07:08:15 +0000
committerChristian Grothoff <christian@grothoff.org>2007-08-07 07:08:15 +0000
commit5b7eec5d2d858dd33aa7f65a7655de1410154f0a (patch)
tree561b1e99f41d1fcec95b1bc73347ddbf3e71e85a
parent98f89b072fe81041aa996eb388ca64f6d57f56cc (diff)
downloadlibmicrohttpd-5b7eec5d2d858dd33aa7f65a7655de1410154f0a.tar.gz
libmicrohttpd-5b7eec5d2d858dd33aa7f65a7655de1410154f0a.zip
post fixes
-rw-r--r--src/daemon/connection.c7
-rw-r--r--src/daemon/daemontest_post.c49
2 files changed, 45 insertions, 11 deletions
diff --git a/src/daemon/connection.c b/src/daemon/connection.c
index fa6450be..21b7872c 100644
--- a/src/daemon/connection.c
+++ b/src/daemon/connection.c
@@ -111,7 +111,7 @@ MHD_queue_response(struct MHD_Connection * connection,
111 (connection->response != NULL) || 111 (connection->response != NULL) ||
112 (connection->bodyReceived == 0) || 112 (connection->bodyReceived == 0) ||
113 (connection->headersReceived == 0) ) 113 (connection->headersReceived == 0) )
114 return MHD_NO; 114 return MHD_NO;
115 MHD_increment_response_rc(response); 115 MHD_increment_response_rc(response);
116 connection->response = response; 116 connection->response = response;
117 connection->responseCode = status_code; 117 connection->responseCode = status_code;
@@ -552,6 +552,9 @@ MHD_call_connection_handler(struct MHD_Connection * connection) {
552 abort(); /* bad timing... */ 552 abort(); /* bad timing... */
553 ah = MHD_find_access_handler(connection); 553 ah = MHD_find_access_handler(connection);
554 processed = connection->readLoc; 554 processed = connection->readLoc;
555 /* FIXME: in case of POST, we need to
556 process the POST data here as well
557 (adding to the header list! */
555 if (MHD_NO == ah->dh(ah->dh_cls, 558 if (MHD_NO == ah->dh(ah->dh_cls,
556 connection, 559 connection,
557 connection->url, 560 connection->url,
@@ -766,7 +769,7 @@ MHD_connection_handle_write(struct MHD_Connection * connection) {
766 } 769 }
767 return MHD_YES; 770 return MHD_YES;
768 } 771 }
769 if (response->total_size <= connection->messagePos) 772 if (response->total_size < connection->messagePos)
770 abort(); /* internal error */ 773 abort(); /* internal error */
771 if (response->crc != NULL) 774 if (response->crc != NULL)
772 pthread_mutex_lock(&response->mutex); 775 pthread_mutex_lock(&response->mutex);
diff --git a/src/daemon/daemontest_post.c b/src/daemon/daemontest_post.c
index 9dbeee20..9f5f6c6f 100644
--- a/src/daemon/daemontest_post.c
+++ b/src/daemon/daemontest_post.c
@@ -37,6 +37,9 @@
37#include <string.h> 37#include <string.h>
38#include <time.h> 38#include <time.h>
39 39
40#define POST_DATA "name=daniel&project=curl"
41
42
40static int apc_all(void * cls, 43static int apc_all(void * cls,
41 const struct sockaddr * addr, 44 const struct sockaddr * addr,
42 socklen_t addrlen) { 45 socklen_t addrlen) {
@@ -78,6 +81,25 @@ static int ahc_echo(void * cls,
78 printf("METHOD: %s\n", method); 81 printf("METHOD: %s\n", method);
79 return MHD_NO; /* unexpected method */ 82 return MHD_NO; /* unexpected method */
80 } 83 }
84 if ( (*upload_data_size < 24) &&
85 (*upload_data_size > 0) )
86 return MHD_YES; /* continue */
87 if (*upload_data_size == 24) {
88 *upload_data_size = 0;
89 if ( (0 != strcmp("daniel",
90 MHD_lookup_connection_value(connection,
91 MHD_POSTDATA_KIND,
92 "name"))) ||
93 (0 != strcmp("curl",
94 MHD_lookup_connection_value(connection,
95 MHD_POSTDATA_KIND,
96 "project"))) ) {
97 printf("POST DATA not processed correctly!\n");
98 return MHD_NO;
99 }
100
101 return MHD_YES; /* continue */
102 }
81 /* FIXME: check connection headers... */ 103 /* FIXME: check connection headers... */
82 response = MHD_create_response_from_data(strlen(url), 104 response = MHD_create_response_from_data(strlen(url),
83 (void*) url, 105 (void*) url,
@@ -119,9 +141,12 @@ static int testInternalPost() {
119 curl_easy_setopt(c, 141 curl_easy_setopt(c,
120 CURLOPT_WRITEDATA, 142 CURLOPT_WRITEDATA,
121 &cbc); 143 &cbc);
122 curl_easy_setopt(c, 144 curl_easy_setopt(c,
123 CURLOPT_HTTPPOST, 145 CURLOPT_POSTFIELDS,
124 NULL); /* FIXME! */ 146 POST_DATA);
147 curl_easy_setopt(c,
148 CURLOPT_POSTFIELDSIZE,
149 strlen(POST_DATA));
125 curl_easy_setopt(c, 150 curl_easy_setopt(c,
126 CURLOPT_POST, 151 CURLOPT_POST,
127 1L); 152 1L);
@@ -193,9 +218,12 @@ static int testMultithreadedPost() {
193 curl_easy_setopt(c, 218 curl_easy_setopt(c,
194 CURLOPT_WRITEDATA, 219 CURLOPT_WRITEDATA,
195 &cbc); 220 &cbc);
196 curl_easy_setopt(c, 221 curl_easy_setopt(c,
197 CURLOPT_HTTPPOST, 222 CURLOPT_POSTFIELDS,
198 NULL); /* FIXME! */ 223 POST_DATA);
224 curl_easy_setopt(c,
225 CURLOPT_POSTFIELDSIZE,
226 strlen(POST_DATA));
199 curl_easy_setopt(c, 227 curl_easy_setopt(c,
200 CURLOPT_POST, 228 CURLOPT_POST,
201 1L); 229 1L);
@@ -278,9 +306,12 @@ static int testExternalPost() {
278 curl_easy_setopt(c, 306 curl_easy_setopt(c,
279 CURLOPT_WRITEDATA, 307 CURLOPT_WRITEDATA,
280 &cbc); 308 &cbc);
281 curl_easy_setopt(c, 309 curl_easy_setopt(c,
282 CURLOPT_HTTPPOST, 310 CURLOPT_POSTFIELDS,
283 NULL); /* FIXME! */ 311 POST_DATA);
312 curl_easy_setopt(c,
313 CURLOPT_POSTFIELDSIZE,
314 strlen(POST_DATA));
284 curl_easy_setopt(c, 315 curl_easy_setopt(c,
285 CURLOPT_POST, 316 CURLOPT_POST,
286 1L); 317 1L);