aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_urlparse.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_urlparse.c')
-rw-r--r--src/testcurl/test_urlparse.c77
1 files changed, 40 insertions, 37 deletions
diff --git a/src/testcurl/test_urlparse.c b/src/testcurl/test_urlparse.c
index d7c133ae..f1bab3d1 100644
--- a/src/testcurl/test_urlparse.c
+++ b/src/testcurl/test_urlparse.c
@@ -68,13 +68,13 @@ copyBuffer (void *ptr, size_t size, size_t nmemb, void *ctx)
68 return size * nmemb; 68 return size * nmemb;
69} 69}
70 70
71static int 71static int
72test_values (void *cls, 72test_values (void *cls,
73 enum MHD_ValueKind kind, 73 enum MHD_ValueKind kind,
74 const char *key, 74 const char *key,
75 const char *value) 75 const char *value)
76{ 76{
77 (void)cls;(void)kind; /* Unused. Silent compiler warning. */ 77 (void) cls; (void) kind; /* Unused. Silent compiler warning. */
78 if ( (0 == strcmp (key, "a")) && 78 if ( (0 == strcmp (key, "a")) &&
79 (0 == strcmp (value, "b")) ) 79 (0 == strcmp (value, "b")) )
80 matches += 1; 80 matches += 1;
@@ -100,23 +100,23 @@ ahc_echo (void *cls,
100 const char *me = cls; 100 const char *me = cls;
101 struct MHD_Response *response; 101 struct MHD_Response *response;
102 int ret; 102 int ret;
103 (void)version;(void)upload_data;(void)upload_data_size; /* Unused. Silent compiler warning. */ 103 (void) version; (void) upload_data; (void) upload_data_size; /* Unused. Silent compiler warning. */
104 104
105 if (0 != strcmp (me, method)) 105 if (0 != strcmp (me, method))
106 return MHD_NO; /* unexpected method */ 106 return MHD_NO; /* unexpected method */
107 if (&ptr != *unused) 107 if (&ptr != *unused)
108 { 108 {
109 *unused = &ptr; 109 *unused = &ptr;
110 return MHD_YES; 110 return MHD_YES;
111 } 111 }
112 MHD_get_connection_values (connection, 112 MHD_get_connection_values (connection,
113 MHD_GET_ARGUMENT_KIND, 113 MHD_GET_ARGUMENT_KIND,
114 &test_values, 114 &test_values,
115 NULL); 115 NULL);
116 *unused = NULL; 116 *unused = NULL;
117 response = MHD_create_response_from_buffer (strlen (url), 117 response = MHD_create_response_from_buffer (strlen (url),
118 (void *) url, 118 (void *) url,
119 MHD_RESPMEM_MUST_COPY); 119 MHD_RESPMEM_MUST_COPY);
120 ret = MHD_queue_response (connection, MHD_HTTP_OK, response); 120 ret = MHD_queue_response (connection, MHD_HTTP_OK, response);
121 MHD_destroy_response (response); 121 MHD_destroy_response (response);
122 if (ret == MHD_NO) 122 if (ret == MHD_NO)
@@ -138,30 +138,33 @@ testInternalGet (int poll_flag)
138 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) 138 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
139 port = 0; 139 port = 0;
140 else 140 else
141 { 141 {
142 port = 1510; 142 port = 1510;
143 if (oneone) 143 if (oneone)
144 port += 5; 144 port += 5;
145 } 145 }
146 146
147 cbc.buf = buf; 147 cbc.buf = buf;
148 cbc.size = 2048; 148 cbc.size = 2048;
149 cbc.pos = 0; 149 cbc.pos = 0;
150 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG | poll_flag, 150 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG
151 | poll_flag,
151 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END); 152 port, NULL, NULL, &ahc_echo, "GET", MHD_OPTION_END);
152 if (d == NULL) 153 if (d == NULL)
153 return 1; 154 return 1;
154 if (0 == port) 155 if (0 == port)
156 {
157 const union MHD_DaemonInfo *dinfo;
158 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
159 if ((NULL == dinfo) ||(0 == dinfo->port) )
155 { 160 {
156 const union MHD_DaemonInfo *dinfo; 161 MHD_stop_daemon (d); return 32;
157 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
158 if (NULL == dinfo || 0 == dinfo->port)
159 { MHD_stop_daemon (d); return 32; }
160 port = (int)dinfo->port;
161 } 162 }
163 port = (int) dinfo->port;
164 }
162 c = curl_easy_init (); 165 c = curl_easy_init ();
163 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world?a=b&c=&d"); 166 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world?a=b&c=&d");
164 curl_easy_setopt (c, CURLOPT_PORT, (long)port); 167 curl_easy_setopt (c, CURLOPT_PORT, (long) port);
165 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 168 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
166 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 169 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
167 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L); 170 curl_easy_setopt (c, CURLOPT_FAILONERROR, 1L);
@@ -176,14 +179,14 @@ testInternalGet (int poll_flag)
176 crashes on my system!*/ 179 crashes on my system!*/
177 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L); 180 curl_easy_setopt (c, CURLOPT_NOSIGNAL, 1L);
178 if (CURLE_OK != (errornum = curl_easy_perform (c))) 181 if (CURLE_OK != (errornum = curl_easy_perform (c)))
179 { 182 {
180 fprintf (stderr, 183 fprintf (stderr,
181 "curl_easy_perform failed: `%s'\n", 184 "curl_easy_perform failed: `%s'\n",
182 curl_easy_strerror (errornum)); 185 curl_easy_strerror (errornum));
183 curl_easy_cleanup (c); 186 curl_easy_cleanup (c);
184 MHD_stop_daemon (d); 187 MHD_stop_daemon (d);
185 return 2; 188 return 2;
186 } 189 }
187 curl_easy_cleanup (c); 190 curl_easy_cleanup (c);
188 MHD_stop_daemon (d); 191 MHD_stop_daemon (d);
189 if (cbc.pos != strlen ("/hello_world")) 192 if (cbc.pos != strlen ("/hello_world"))
@@ -200,9 +203,9 @@ int
200main (int argc, char *const *argv) 203main (int argc, char *const *argv)
201{ 204{
202 unsigned int errorCount = 0; 205 unsigned int errorCount = 0;
203 (void)argc; /* Unused. Silent compiler warning. */ 206 (void) argc; /* Unused. Silent compiler warning. */
204 207
205 if (NULL == argv || 0 == argv[0]) 208 if ((NULL == argv)||(0 == argv[0]))
206 return 99; 209 return 99;
207 oneone = has_in_name (argv[0], "11"); 210 oneone = has_in_name (argv[0], "11");
208 if (0 != curl_global_init (CURL_GLOBAL_WIN32)) 211 if (0 != curl_global_init (CURL_GLOBAL_WIN32))