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