libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

commit 3330f10e6242d4ef542a67e0d5af31a0251127ab
parent 6e78e8022576955e89ff3626d9019320bd5d2228
Author: Evgeny Grin (Karlson2k) <k2k@narod.ru>
Date:   Thu,  6 Oct 2022 20:10:42 +0300

testcurl/https: some simplifications and clean-ups

Diffstat:
Msrc/testcurl/https/test_https_get.c | 9+++------
Msrc/testcurl/https/test_https_get_iovec.c | 7+++----
Msrc/testcurl/https/test_https_session_info.c | 6+++---
Msrc/testcurl/https/test_tls_options.c | 7+++----
Msrc/testcurl/https/tls_test_common.c | 34+++++++++++++++++-----------------
Msrc/testcurl/https/tls_test_common.h | 31++++++-------------------------
6 files changed, 35 insertions(+), 59 deletions(-)

diff --git a/src/testcurl/https/test_https_get.c b/src/testcurl/https/test_https_get.c @@ -26,8 +26,6 @@ #include "platform.h" #include "microhttpd.h" -#include <limits.h> -#include <sys/stat.h> #include <curl/curl.h> #ifdef MHD_HTTPS_REQUIRE_GCRYPT #include <gcrypt.h> @@ -41,8 +39,7 @@ static uint16_t global_port; /* perform a HTTP GET request via SSL/TLS */ static unsigned int -test_secure_get (FILE *test_fd, - const char *cipher_suite, +test_secure_get (const char *cipher_suite, int proto_version) { unsigned int ret; @@ -80,7 +77,7 @@ test_secure_get (FILE *test_fd, port = dinfo->port; } - ret = test_https_transfer (test_fd, + ret = test_https_transfer (NULL, port, cipher_suite, proto_version); @@ -252,7 +249,7 @@ main (int argc, char *const *argv) return 77; } errorCount += - test_secure_get (NULL, NULL, CURL_SSLVERSION_DEFAULT); + test_secure_get (NULL, CURL_SSLVERSION_DEFAULT); errorCount += testEmptyGet (0); curl_global_cleanup (); diff --git a/src/testcurl/https/test_https_get_iovec.c b/src/testcurl/https/test_https_get_iovec.c @@ -161,9 +161,9 @@ test_iovec_transfer (void *cls, cbc.size = len; cbc.pos = 0; - if (gen_test_file_url (url, - sizeof (url), - port)) + if (gen_test_uri (url, + sizeof (url), + port)) { ret = 1; goto cleanup; @@ -176,7 +176,6 @@ test_iovec_transfer (void *cls, goto cleanup; } - /* compare test file & daemon response */ if ((cbc.pos != TESTSTR_SIZE) || (0 != check_read_data (cbc.buf, cbc.pos))) { diff --git a/src/testcurl/https/test_https_session_info.c b/src/testcurl/https/test_https_session_info.c @@ -141,9 +141,9 @@ test_query_session (void) port = dinfo->port; } - gen_test_file_url (url, - sizeof (url), - port); + gen_test_uri (url, + sizeof (url), + port); c = curl_easy_init (); #ifdef _DEBUG curl_easy_setopt (c, CURLOPT_VERBOSE, 1L); diff --git a/src/testcurl/https/test_tls_options.c b/src/testcurl/https/test_tls_options.c @@ -54,9 +54,9 @@ test_unmatching_ssl_version (void *cls, uint16_t port, const char *cipher_suite, cbc.size = 256; cbc.pos = 0; - if (gen_test_file_url (url, - sizeof (url), - port)) + if (gen_test_uri (url, + sizeof (url), + port)) { free (cbc.buf); fprintf (stderr, @@ -79,7 +79,6 @@ test_unmatching_ssl_version (void *cls, uint16_t port, const char *cipher_suite, } -/* setup a temporary transfer test file */ int main (int argc, char *const *argv) { diff --git a/src/testcurl/https/tls_test_common.c b/src/testcurl/https/tls_test_common.c @@ -55,9 +55,9 @@ test_daemon_get (void *cls, cbc.pos = 0; /* construct url - this might use doc_path */ - gen_test_file_url (url, - sizeof (url), - port); + gen_test_uri (url, + sizeof (url), + port); c = curl_easy_init (); #ifdef _DEBUG @@ -308,27 +308,27 @@ send_curl_req (char *url, /** - * compile test file url pointing to the current running directory path + * compile test URI * - * @param[out] url - char buffer into which the url is compiled - * @param url_len number of bytes available in url + * @param[out] uri - char buffer into which the url is compiled + * @param uri_len number of bytes available in @a url * @param port port to use for the test * @return 1 on error */ unsigned int -gen_test_file_url (char *url, - size_t url_len, - uint16_t port) +gen_test_uri (char *uri, + size_t uri_len, + uint16_t port) { int res; - res = snprintf (url, - url_len, + res = snprintf (uri, + uri_len, "https://127.0.0.1:%u/urlpath", (unsigned int) port); if (res <= 0) return 1; - if ((size_t) res >= url_len) + if ((size_t) res >= uri_len) return 1; return 0; @@ -359,9 +359,9 @@ test_https_transfer (void *cls, cbc.size = len; cbc.pos = 0; - if (gen_test_file_url (url, - sizeof (url), - port)) + if (gen_test_uri (url, + sizeof (url), + port)) { ret = 1; goto cleanup; @@ -397,7 +397,7 @@ cleanup: * @param arg_list * @return port number on success or zero on failure */ -uint16_t +static uint16_t setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, va_list arg_list) { @@ -426,7 +426,7 @@ setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, } -void +static void teardown_testcase (struct MHD_Daemon *d) { MHD_stop_daemon (d); diff --git a/src/testcurl/https/tls_test_common.h b/src/testcurl/https/tls_test_common.h @@ -44,7 +44,6 @@ #define MHD_E_FAILED_TO_CONNECT \ "Error: server connection could not be established\n" -/* TODO rm if unused */ struct https_test_data { void *cls; @@ -60,16 +59,6 @@ struct CBC size_t size; }; -struct CipherDef -{ - int options[2]; - char *curlname; -}; - - -int -curl_check_version (const char *req_version, ...); - int curl_tls_is_gnutls (void); @@ -113,17 +102,17 @@ http_dummy_ahc (void *cls, struct MHD_Connection *connection, /** - * compile test file url pointing to the current running directory path + * compile test URI * - * @param[out] url - char buffer into which the url is compiled - * @param url_len number of bytes available in @a url + * @param[out] uri - char buffer into which the url is compiled + * @param uri_len number of bytes available in @a url * @param port port to use for the test * @return 1 on error */ unsigned int -gen_test_file_url (char *url, - size_t url_len, - uint16_t port); +gen_test_uri (char *uri, + size_t uri_len, + uint16_t port); CURLcode send_curl_req (char *url, @@ -137,14 +126,6 @@ test_https_transfer (void *cls, const char *cipher_suite, int proto_version); -uint16_t -setup_testcase (struct MHD_Daemon **d, uint16_t port, unsigned int daemon_flags, - va_list arg_list); - -void -teardown_testcase (struct MHD_Daemon *d); - - unsigned int setup_session (gnutls_session_t *session, gnutls_certificate_credentials_t *xcred);