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.c64
1 files changed, 34 insertions, 30 deletions
diff --git a/src/testcurl/test_digestauth_with_arguments.c b/src/testcurl/test_digestauth_with_arguments.c
index 17d0f7a2..be59fab7 100644
--- a/src/testcurl/test_digestauth_with_arguments.c
+++ b/src/testcurl/test_digestauth_with_arguments.c
@@ -90,39 +90,39 @@ ahc_echo (void *cls,
90 if ( (username == NULL) || 90 if ( (username == NULL) ||
91 (0 != strcmp (username, "testuser")) ) 91 (0 != strcmp (username, "testuser")) )
92 { 92 {
93 response = MHD_create_response_from_buffer(strlen (DENIED), 93 response = MHD_create_response_from_buffer(strlen (DENIED),
94 DENIED, 94 DENIED,
95 MHD_RESPMEM_PERSISTENT); 95 MHD_RESPMEM_PERSISTENT);
96 ret = MHD_queue_auth_fail_response(connection, realm, 96 ret = MHD_queue_auth_fail_response(connection, realm,
97 MY_OPAQUE, 97 MY_OPAQUE,
98 response, 98 response,
99 MHD_NO); 99 MHD_NO);
100 MHD_destroy_response(response); 100 MHD_destroy_response(response);
101 return ret; 101 return ret;
102 } 102 }
103 ret = MHD_digest_auth_check(connection, realm, 103 ret = MHD_digest_auth_check(connection, realm,
104 username, 104 username,
105 password, 105 password,
106 300); 106 300);
107 free(username); 107 free(username);
108 if ( (ret == MHD_INVALID_NONCE) || 108 if ( (ret == MHD_INVALID_NONCE) ||
109 (ret == MHD_NO) ) 109 (ret == MHD_NO) )
110 { 110 {
111 response = MHD_create_response_from_buffer(strlen (DENIED), 111 response = MHD_create_response_from_buffer(strlen (DENIED),
112 DENIED, 112 DENIED,
113 MHD_RESPMEM_PERSISTENT); 113 MHD_RESPMEM_PERSISTENT);
114 if (NULL == response) 114 if (NULL == response)
115 return MHD_NO; 115 return MHD_NO;
116 ret = MHD_queue_auth_fail_response(connection, realm, 116 ret = MHD_queue_auth_fail_response(connection, realm,
117 MY_OPAQUE, 117 MY_OPAQUE,
118 response, 118 response,
119 (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO); 119 (ret == MHD_INVALID_NONCE) ? MHD_YES : MHD_NO);
120 MHD_destroy_response(response); 120 MHD_destroy_response(response);
121 return ret; 121 return ret;
122 } 122 }
123 response = MHD_create_response_from_buffer(strlen(PAGE), PAGE, 123 response = MHD_create_response_from_buffer(strlen(PAGE), PAGE,
124 MHD_RESPMEM_PERSISTENT); 124 MHD_RESPMEM_PERSISTENT);
125 ret = MHD_queue_response(connection, MHD_HTTP_OK, response); 125 ret = MHD_queue_response(connection, MHD_HTTP_OK, response);
126 MHD_destroy_response(response); 126 MHD_destroy_response(response);
127 return ret; 127 return ret;
128} 128}
@@ -157,24 +157,25 @@ testDigestAuth ()
157 fd = open("/dev/urandom", O_RDONLY); 157 fd = open("/dev/urandom", O_RDONLY);
158 if (-1 == fd) 158 if (-1 == fd)
159 { 159 {
160 fprintf(stderr, "Failed to open `%s': %s\n", 160 fprintf(stderr, "Failed to open `%s': %s\n",
161 "/dev/urandom", 161 "/dev/urandom",
162 strerror(errno)); 162 strerror(errno));
163 return 1; 163 return 1;
164 } 164 }
165 while (off < 8) 165 while (off < 8)
166 { 166 {
167 len = read(fd, rnd, 8); 167 len = read(fd, rnd, 8);
168 if (len == (size_t)-1) 168 if (len == (size_t)-1)
169 { 169 {
170 fprintf(stderr, "Failed to read `%s': %s\n", 170 fprintf(stderr,
171 "/dev/urandom", 171 "Failed to read `%s': %s\n",
172 strerror(errno)); 172 "/dev/urandom",
173 (void) close(fd); 173 strerror(errno));
174 return 1; 174 (void) close(fd);
175 } 175 return 1;
176 off += len; 176 }
177 } 177 off += len;
178 }
178 (void) close(fd); 179 (void) close(fd);
179#else 180#else
180 { 181 {
@@ -213,7 +214,10 @@ testDigestAuth ()
213 { MHD_stop_daemon (d); return 32; } 214 { MHD_stop_daemon (d); return 32; }
214 port = (int)dinfo->port; 215 port = (int)dinfo->port;
215 } 216 }
216 sprintf(url, "http://127.0.0.1:%d/bar%20foo%3Fkey%3Dvalue", port); 217 snprintf (url,
218 sizeof (url),
219 "http://127.0.0.1:%d/bar%%20foo%%3Fkey%%3Dvalue",
220 port);
217 c = curl_easy_init (); 221 c = curl_easy_init ();
218 curl_easy_setopt (c, CURLOPT_URL, url); 222 curl_easy_setopt (c, CURLOPT_URL, url);
219 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer); 223 curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, &copyBuffer);