aboutsummaryrefslogtreecommitdiff
path: root/src/testcurl/test_digestauth.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcurl/test_digestauth.c')
-rw-r--r--src/testcurl/test_digestauth.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/testcurl/test_digestauth.c b/src/testcurl/test_digestauth.c
index 57abbbe6..3db08b4b 100644
--- a/src/testcurl/test_digestauth.c
+++ b/src/testcurl/test_digestauth.c
@@ -140,6 +140,13 @@ testDigestAuth ()
140 size_t off = 0; 140 size_t off = 0;
141 char buf[2048]; 141 char buf[2048];
142 char rnd[8]; 142 char rnd[8];
143 int port;
144 char url[128];
145
146 if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT))
147 port = 0;
148 else
149 port = 1165;
143 150
144 cbc.buf = buf; 151 cbc.buf = buf;
145 cbc.size = 2048; 152 cbc.size = 2048;
@@ -190,14 +197,23 @@ testDigestAuth ()
190 } 197 }
191#endif 198#endif
192 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, 199 d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG,
193 1337, NULL, NULL, &ahc_echo, PAGE, 200 port, NULL, NULL, &ahc_echo, PAGE,
194 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, 201 MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd,
195 MHD_OPTION_NONCE_NC_SIZE, 300, 202 MHD_OPTION_NONCE_NC_SIZE, 300,
196 MHD_OPTION_END); 203 MHD_OPTION_END);
197 if (d == NULL) 204 if (d == NULL)
198 return 1; 205 return 1;
206 if (0 == port)
207 {
208 const union MHD_DaemonInfo *dinfo;
209 dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT);
210 if (NULL == dinfo || 0 == dinfo->port)
211 { MHD_stop_daemon (d); return 32; }
212 port = (int)dinfo->port;
213 }
214 sprintf(url, "http://127.0.0.1:%d/bar%%20 foo?a=bü%%20", port);
199 c = curl_easy_init (); 215 c = curl_easy_init ();
200 curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1337/bar%20 foo?a=bü%20"); 216 curl_easy_setopt (c, CURLOPT_URL, url);
201 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 217 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);
202 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); 218 curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc);
203 curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST); 219 curl_easy_setopt (c, CURLOPT_HTTPAUTH, CURLAUTH_DIGEST);