diff options
Diffstat (limited to 'src/testcurl/test_digestauth_with_arguments.c')
-rw-r--r-- | src/testcurl/test_digestauth_with_arguments.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c index 631169e8..a606f363 100644 --- a/src/testcurl/test_digestauth_with_arguments.c +++ b/src/testcurl/test_digestauth_with_arguments.c | |||
@@ -87,7 +87,7 @@ ahc_echo (void *cls, | |||
87 | const char *password = "testpass"; | 87 | const char *password = "testpass"; |
88 | const char *realm = "test@example.com"; | 88 | const char *realm = "test@example.com"; |
89 | enum MHD_Result ret; | 89 | enum MHD_Result ret; |
90 | enum MHD_DigestAuthResult ret_e; | 90 | int ret_i; |
91 | static int already_called_marker; | 91 | static int already_called_marker; |
92 | (void) cls; (void) url; /* Unused. Silent compiler warning. */ | 92 | (void) cls; (void) url; /* Unused. Silent compiler warning. */ |
93 | (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ | 93 | (void) method; (void) version; (void) upload_data; /* Unused. Silent compiler warning. */ |
@@ -114,24 +114,28 @@ ahc_echo (void *cls, | |||
114 | MHD_destroy_response (response); | 114 | MHD_destroy_response (response); |
115 | return ret; | 115 | return ret; |
116 | } | 116 | } |
117 | ret_e = MHD_digest_auth_check3 (connection, realm, | 117 | ret_i = MHD_digest_auth_check2 (connection, |
118 | realm, | ||
118 | username, | 119 | username, |
119 | password, | 120 | password, |
120 | 300, | 121 | 300, |
121 | MHD_DIGEST_ALG_MD5); | 122 | MHD_DIGEST_ALG_MD5); |
122 | MHD_free (username); | 123 | MHD_free (username); |
123 | if (ret_e != MHD_DAUTH_OK) | 124 | if (ret_i != MHD_YES) |
124 | { | 125 | { |
125 | response = MHD_create_response_from_buffer_static (strlen (DENIED), | 126 | response = MHD_create_response_from_buffer_static (strlen (DENIED), |
126 | DENIED); | 127 | DENIED); |
127 | if (NULL == response) | 128 | if (NULL == response) |
128 | return MHD_NO; | 129 | fprintf (stderr, "MHD_create_response_from_buffer() failed.\n"); |
129 | ret = MHD_queue_auth_fail_response2 (connection, realm, | 130 | ret = MHD_queue_auth_fail_response2 (connection, |
131 | realm, | ||
130 | MY_OPAQUE, | 132 | MY_OPAQUE, |
131 | response, | 133 | response, |
132 | (ret_e == MHD_DAUTH_NONCE_STALE) ? | 134 | (MHD_INVALID_NONCE == ret_i) ? |
133 | MHD_YES : MHD_NO, | 135 | MHD_YES : MHD_NO, |
134 | MHD_DIGEST_ALG_MD5); | 136 | MHD_DIGEST_ALG_MD5); |
137 | if (MHD_YES != ret) | ||
138 | fprintf (stderr, "MHD_queue_auth_fail_response2() failed.\n"); | ||
135 | MHD_destroy_response (response); | 139 | MHD_destroy_response (response); |
136 | return ret; | 140 | return ret; |
137 | } | 141 | } |
@@ -143,8 +147,8 @@ ahc_echo (void *cls, | |||
143 | } | 147 | } |
144 | 148 | ||
145 | 149 | ||
146 | static int | 150 | static unsigned int |
147 | testDigestAuth () | 151 | testDigestAuth (void) |
148 | { | 152 | { |
149 | CURL *c; | 153 | CURL *c; |
150 | CURLcode errornum; | 154 | CURLcode errornum; |
@@ -152,7 +156,7 @@ testDigestAuth () | |||
152 | struct CBC cbc; | 156 | struct CBC cbc; |
153 | char buf[2048]; | 157 | char buf[2048]; |
154 | char rnd[8]; | 158 | char rnd[8]; |
155 | int port; | 159 | uint16_t port; |
156 | char url[128]; | 160 | char url[128]; |
157 | #ifndef WINDOWS | 161 | #ifndef WINDOWS |
158 | int fd; | 162 | int fd; |
@@ -216,7 +220,7 @@ testDigestAuth () | |||
216 | } | 220 | } |
217 | #endif | 221 | #endif |
218 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, | 222 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | MHD_USE_ERROR_LOG, |
219 | port, NULL, NULL, &ahc_echo, PAGE, | 223 | port, NULL, NULL, &ahc_echo, NULL, |
220 | MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, | 224 | MHD_OPTION_DIGEST_AUTH_RANDOM, sizeof (rnd), rnd, |
221 | MHD_OPTION_NONCE_NC_SIZE, 300, | 225 | MHD_OPTION_NONCE_NC_SIZE, 300, |
222 | MHD_OPTION_END); | 226 | MHD_OPTION_END); |
@@ -230,13 +234,13 @@ testDigestAuth () | |||
230 | { | 234 | { |
231 | MHD_stop_daemon (d); return 32; | 235 | MHD_stop_daemon (d); return 32; |
232 | } | 236 | } |
233 | port = (int) dinfo->port; | 237 | port = dinfo->port; |
234 | } | 238 | } |
235 | snprintf (url, | 239 | snprintf (url, |
236 | sizeof (url), | 240 | sizeof (url), |
237 | "http://127.0.0.1:%d/bar%%20foo?" | 241 | "http://127.0.0.1:%d/bar%%20foo?" |
238 | "key=value&more=even%%20more&empty&=no_key&&same=one&&same=two", | 242 | "key=value&more=even%%20more&empty&=no_key&&same=one&&same=two", |
239 | port); | 243 | (int) port); |
240 | c = curl_easy_init (); | 244 | c = curl_easy_init (); |
241 | curl_easy_setopt (c, CURLOPT_URL, url); | 245 | curl_easy_setopt (c, CURLOPT_URL, url); |
242 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 246 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |