diff options
Diffstat (limited to 'src/testcurl/test_long_header.c')
-rw-r--r-- | src/testcurl/test_long_header.c | 45 |
1 files changed, 41 insertions, 4 deletions
diff --git a/src/testcurl/test_long_header.c b/src/testcurl/test_long_header.c index a82464b8..31a8581d 100644 --- a/src/testcurl/test_long_header.c +++ b/src/testcurl/test_long_header.c | |||
@@ -97,12 +97,21 @@ testLongUrlGet () | |||
97 | struct CBC cbc; | 97 | struct CBC cbc; |
98 | char *url; | 98 | char *url; |
99 | long code; | 99 | long code; |
100 | int port; | ||
100 | 101 | ||
102 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
103 | port = 0; | ||
104 | else | ||
105 | { | ||
106 | port = 1330; | ||
107 | if (oneone) | ||
108 | port += 5; | ||
109 | } | ||
101 | cbc.buf = buf; | 110 | cbc.buf = buf; |
102 | cbc.size = 2048; | 111 | cbc.size = 2048; |
103 | cbc.pos = 0; | 112 | cbc.pos = 0; |
104 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , | 113 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , |
105 | 1080, | 114 | port, |
106 | &apc_all, | 115 | &apc_all, |
107 | NULL, | 116 | NULL, |
108 | &ahc_echo, | 117 | &ahc_echo, |
@@ -111,6 +120,14 @@ testLongUrlGet () | |||
111 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); | 120 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); |
112 | if (d == NULL) | 121 | if (d == NULL) |
113 | return 1; | 122 | return 1; |
123 | if (0 == port) | ||
124 | { | ||
125 | const union MHD_DaemonInfo *dinfo; | ||
126 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
127 | if (NULL == dinfo || 0 == dinfo->port) | ||
128 | { MHD_stop_daemon (d); return 32; } | ||
129 | port = (int)dinfo->port; | ||
130 | } | ||
114 | c = curl_easy_init (); | 131 | c = curl_easy_init (); |
115 | url = malloc (VERY_LONG); | 132 | url = malloc (VERY_LONG); |
116 | if (url == NULL) | 133 | if (url == NULL) |
@@ -120,8 +137,9 @@ testLongUrlGet () | |||
120 | } | 137 | } |
121 | memset (url, 'a', VERY_LONG); | 138 | memset (url, 'a', VERY_LONG); |
122 | url[VERY_LONG - 1] = '\0'; | 139 | url[VERY_LONG - 1] = '\0'; |
123 | memcpy (url, "http://127.0.0.1:1080/", strlen ("http://127.0.0.1:1080/")); | 140 | memcpy (url, "http://127.0.0.1/", strlen ("http://127.0.0.1/")); |
124 | curl_easy_setopt (c, CURLOPT_URL, url); | 141 | curl_easy_setopt (c, CURLOPT_URL, url); |
142 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
125 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 143 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
126 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 144 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
127 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 145 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |
@@ -168,12 +186,22 @@ testLongHeaderGet () | |||
168 | char *url; | 186 | char *url; |
169 | long code; | 187 | long code; |
170 | struct curl_slist *header = NULL; | 188 | struct curl_slist *header = NULL; |
189 | int port; | ||
190 | |||
191 | if (MHD_NO != MHD_is_feature_supported (MHD_FEATURE_AUTODETECT_BIND_PORT)) | ||
192 | port = 0; | ||
193 | else | ||
194 | { | ||
195 | port = 1331; | ||
196 | if (oneone) | ||
197 | port += 5; | ||
198 | } | ||
171 | 199 | ||
172 | cbc.buf = buf; | 200 | cbc.buf = buf; |
173 | cbc.size = 2048; | 201 | cbc.size = 2048; |
174 | cbc.pos = 0; | 202 | cbc.pos = 0; |
175 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , | 203 | d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD /* | MHD_USE_ERROR_LOG */ , |
176 | 1080, | 204 | port, |
177 | &apc_all, | 205 | &apc_all, |
178 | NULL, | 206 | NULL, |
179 | &ahc_echo, | 207 | &ahc_echo, |
@@ -182,6 +210,14 @@ testLongHeaderGet () | |||
182 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); | 210 | (size_t) (VERY_LONG / 2), MHD_OPTION_END); |
183 | if (d == NULL) | 211 | if (d == NULL) |
184 | return 16; | 212 | return 16; |
213 | if (0 == port) | ||
214 | { | ||
215 | const union MHD_DaemonInfo *dinfo; | ||
216 | dinfo = MHD_get_daemon_info (d, MHD_DAEMON_INFO_BIND_PORT); | ||
217 | if (NULL == dinfo || 0 == dinfo->port) | ||
218 | { MHD_stop_daemon (d); return 32; } | ||
219 | port = (int)dinfo->port; | ||
220 | } | ||
185 | c = curl_easy_init (); | 221 | c = curl_easy_init (); |
186 | url = malloc (VERY_LONG); | 222 | url = malloc (VERY_LONG); |
187 | if (url == NULL) | 223 | if (url == NULL) |
@@ -196,7 +232,8 @@ testLongHeaderGet () | |||
196 | header = curl_slist_append (header, url); | 232 | header = curl_slist_append (header, url); |
197 | 233 | ||
198 | curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); | 234 | curl_easy_setopt (c, CURLOPT_HTTPHEADER, header); |
199 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1:1080/hello_world"); | 235 | curl_easy_setopt (c, CURLOPT_URL, "http://127.0.0.1/hello_world"); |
236 | curl_easy_setopt (c, CURLOPT_PORT, (long)port); | ||
200 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); | 237 | curl_easy_setopt (c, CURLOPT_WRITEFUNCTION, ©Buffer); |
201 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); | 238 | curl_easy_setopt (c, CURLOPT_WRITEDATA, &cbc); |
202 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); | 239 | curl_easy_setopt (c, CURLOPT_FAILONERROR, 1); |