aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-10-06 19:10:06 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2022-10-10 11:54:31 +0300
commitf8441dac5fed1ce873728a9b71276c9321999aec (patch)
treef8fa1e195b4db9933b4ef0f94f2bdc07ca88c249
parent43e10b9088806877ad1ad2c685e205d731333f0f (diff)
downloadlibmicrohttpd-f8441dac5fed1ce873728a9b71276c9321999aec.tar.gz
libmicrohttpd-f8441dac5fed1ce873728a9b71276c9321999aec.zip
testcurl/https: significantly simplified test URI
The set URI was overcomplicated without any practical reasons. Fixed compiler warning on W32.
-rw-r--r--src/testcurl/https/tls_test_common.c53
1 files changed, 4 insertions, 49 deletions
diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c
index b44ded1e..639bccf1 100644
--- a/src/testcurl/https/tls_test_common.c
+++ b/src/testcurl/https/tls_test_common.c
@@ -321,58 +321,13 @@ gen_test_file_url (char *url,
321 uint16_t port) 321 uint16_t port)
322{ 322{
323 unsigned int ret = 0; 323 unsigned int ret = 0;
324 char *doc_path;
325 size_t doc_path_len;
326#ifdef WINDOWS
327 size_t i;
328#endif /* ! WINDOWS */
329 /* setup test file path, url */
330#ifdef PATH_MAX
331 doc_path_len = PATH_MAX > 4096 ? 4096 : PATH_MAX;
332#else /* ! PATH_MAX */
333 doc_path_len = 4096;
334#endif /* ! PATH_MAX */
335 if (NULL == (doc_path = malloc (doc_path_len)))
336 {
337 fprintf (stderr, MHD_E_MEM);
338 return 1;
339 }
340 if (NULL == getcwd (doc_path, doc_path_len))
341 {
342 fprintf (stderr,
343 "Error: failed to get working directory. %s\n",
344 strerror (errno));
345 free (doc_path);
346 return 1;
347 }
348#ifdef WINDOWS
349 for (i = 0; i < doc_path_len; i++)
350 {
351 if (doc_path[i] == 0)
352 break;
353 if (doc_path[i] == '\\')
354 {
355 doc_path[i] = '/';
356 }
357 if (doc_path[i] != ':')
358 continue;
359 if (i == 0)
360 break;
361 doc_path[i] = doc_path[i - 1];
362 doc_path[i - 1] = '/';
363 }
364#endif
365 /* construct url */ 324 /* construct url */
366 if (snprintf (url, 325 if ((size_t) snprintf (url,
367 url_len, 326 url_len,
368 "%s:%u%s/%s", 327 "https://127.0.0.1:%u/urlpath",
369 "https://127.0.0.1", 328 (unsigned int) port) >= url_len)
370 (unsigned int) port,
371 doc_path,
372 "urlpath") >= (long long) url_len)
373 ret = 1; 329 ret = 1;
374 330
375 free (doc_path);
376 return ret; 331 return ret;
377} 332}
378 333