diff options
Diffstat (limited to 'src/daemon/daemontest_post.c')
-rw-r--r-- | src/daemon/daemontest_post.c | 49 |
1 files changed, 40 insertions, 9 deletions
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 | |||
40 | static int apc_all(void * cls, | 43 | static 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); |