aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/daemontest_post.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemon/daemontest_post.c')
-rw-r--r--src/daemon/daemontest_post.c91
1 files changed, 52 insertions, 39 deletions
diff --git a/src/daemon/daemontest_post.c b/src/daemon/daemontest_post.c
index 9f5f6c6f..3c69dadc 100644
--- a/src/daemon/daemontest_post.c
+++ b/src/daemon/daemontest_post.c
@@ -39,6 +39,7 @@
39 39
40#define POST_DATA "name=daniel&project=curl" 40#define POST_DATA "name=daniel&project=curl"
41 41
42static int oneone;
42 43
43static int apc_all(void * cls, 44static int apc_all(void * cls,
44 const struct sockaddr * addr, 45 const struct sockaddr * addr,
@@ -76,40 +77,36 @@ static int ahc_echo(void * cls,
76 unsigned int * upload_data_size) { 77 unsigned int * upload_data_size) {
77 struct MHD_Response * response; 78 struct MHD_Response * response;
78 int ret; 79 int ret;
80 const char * r1;
81 const char * r2;
79 82
80 if (0 != strcmp("POST", method)) { 83 if (0 != strcmp("POST", method)) {
81 printf("METHOD: %s\n", method); 84 printf("METHOD: %s\n", method);
82 return MHD_NO; /* unexpected method */ 85 return MHD_NO; /* unexpected method */
83 } 86 }
84 if ( (*upload_data_size < 24) && 87 r1 = MHD_lookup_connection_value(connection,
85 (*upload_data_size > 0) ) 88 MHD_POSTDATA_KIND,
86 return MHD_YES; /* continue */ 89 "name");
87 if (*upload_data_size == 24) { 90 r2 = MHD_lookup_connection_value(connection,
88 *upload_data_size = 0; 91 MHD_POSTDATA_KIND,
89 if ( (0 != strcmp("daniel", 92 "project");
90 MHD_lookup_connection_value(connection, 93 if ( (r1 != NULL) &&
91 MHD_POSTDATA_KIND, 94 (r2 != NULL) &&
92 "name"))) || 95 (0 == strcmp("daniel",
93 (0 != strcmp("curl", 96 r1)) &&
94 MHD_lookup_connection_value(connection, 97 (0 == strcmp("curl",
95 MHD_POSTDATA_KIND, 98 r2)) ) {
96 "project"))) ) { 99 response = MHD_create_response_from_data(strlen(url),
97 printf("POST DATA not processed correctly!\n"); 100 (void*) url,
98 return MHD_NO; 101 MHD_NO,
99 } 102 MHD_YES);
100 103 ret = MHD_queue_response(connection,
101 return MHD_YES; /* continue */ 104 MHD_HTTP_OK,
105 response);
106 MHD_destroy_response(response);
107 return MHD_YES; /* done */
102 } 108 }
103 /* FIXME: check connection headers... */ 109 return MHD_YES;
104 response = MHD_create_response_from_data(strlen(url),
105 (void*) url,
106 MHD_NO,
107 MHD_YES);
108 ret = MHD_queue_response(connection,
109 MHD_HTTP_OK,
110 response);
111 MHD_destroy_response(response);
112 return ret;
113} 110}
114 111
115 112
@@ -118,7 +115,7 @@ static int testInternalPost() {
118 CURL * c; 115 CURL * c;
119 char buf[2048]; 116 char buf[2048];
120 struct CBC cbc; 117 struct CBC cbc;
121 118
122 cbc.buf = buf; 119 cbc.buf = buf;
123 cbc.size = 2048; 120 cbc.size = 2048;
124 cbc.pos = 0; 121 cbc.pos = 0;
@@ -156,9 +153,14 @@ static int testInternalPost() {
156 curl_easy_setopt(c, 153 curl_easy_setopt(c,
157 CURLOPT_TIMEOUT, 154 CURLOPT_TIMEOUT,
158 2L); 155 2L);
159 curl_easy_setopt(c, 156 if (oneone)
160 CURLOPT_HTTP_VERSION, 157 curl_easy_setopt(c,
161 CURL_HTTP_VERSION_1_0); 158 CURLOPT_HTTP_VERSION,
159 CURL_HTTP_VERSION_1_1);
160 else
161 curl_easy_setopt(c,
162 CURLOPT_HTTP_VERSION,
163 CURL_HTTP_VERSION_1_0);
162 curl_easy_setopt(c, 164 curl_easy_setopt(c,
163 CURLOPT_CONNECTTIMEOUT, 165 CURLOPT_CONNECTTIMEOUT,
164 2L); 166 2L);
@@ -233,9 +235,14 @@ static int testMultithreadedPost() {
233 curl_easy_setopt(c, 235 curl_easy_setopt(c,
234 CURLOPT_TIMEOUT, 236 CURLOPT_TIMEOUT,
235 2L); 237 2L);
236 curl_easy_setopt(c, 238 if (oneone)
237 CURLOPT_HTTP_VERSION, 239 curl_easy_setopt(c,
238 CURL_HTTP_VERSION_1_0); 240 CURLOPT_HTTP_VERSION,
241 CURL_HTTP_VERSION_1_1);
242 else
243 curl_easy_setopt(c,
244 CURLOPT_HTTP_VERSION,
245 CURL_HTTP_VERSION_1_0);
239 curl_easy_setopt(c, 246 curl_easy_setopt(c,
240 CURLOPT_CONNECTTIMEOUT, 247 CURLOPT_CONNECTTIMEOUT,
241 2L); 248 2L);
@@ -321,9 +328,14 @@ static int testExternalPost() {
321 curl_easy_setopt(c, 328 curl_easy_setopt(c,
322 CURLOPT_TIMEOUT, 329 CURLOPT_TIMEOUT,
323 5L); 330 5L);
324 curl_easy_setopt(c, 331 if (oneone)
325 CURLOPT_HTTP_VERSION, 332 curl_easy_setopt(c,
326 CURL_HTTP_VERSION_1_0); 333 CURLOPT_HTTP_VERSION,
334 CURL_HTTP_VERSION_1_1);
335 else
336 curl_easy_setopt(c,
337 CURLOPT_HTTP_VERSION,
338 CURL_HTTP_VERSION_1_0);
327 curl_easy_setopt(c, 339 curl_easy_setopt(c,
328 CURLOPT_CONNECTTIMEOUT, 340 CURLOPT_CONNECTTIMEOUT,
329 5L); 341 5L);
@@ -429,11 +441,12 @@ int main(int argc,
429 char * const * argv) { 441 char * const * argv) {
430 unsigned int errorCount = 0; 442 unsigned int errorCount = 0;
431 443
444 oneone = NULL != strstr(argv[0], "11");
432 if (0 != curl_global_init(CURL_GLOBAL_WIN32)) 445 if (0 != curl_global_init(CURL_GLOBAL_WIN32))
433 return 2; 446 return 2;
434 errorCount += testInternalPost(); 447 errorCount += testInternalPost();
435 errorCount += testMultithreadedPost(); 448 errorCount += testMultithreadedPost();
436 errorCount += testExternalPost(); 449 errorCount += testExternalPost();
437 if (errorCount != 0) 450 if (errorCount != 0)
438 fprintf(stderr, 451 fprintf(stderr,
439 "Error (code: %u)\n", 452 "Error (code: %u)\n",