|
|
@@ -219,7 +219,7 @@ _mhdErrorExit_func (const char *errDesc, const char *funcName, int lineNum)
|
|
|
/* Global parameters */
|
|
|
static int verbose; /**< Be verbose */
|
|
|
static int oneone; /**< If false use HTTP/1.0 for requests*/
|
|
|
-static int global_port; /**< MHD daemons listen port number */
|
|
|
+static uint16_t global_port; /**< MHD daemons listen port number */
|
|
|
static int large_req_method; /**< Large request method */
|
|
|
static int large_req_url; /**< Large request URL */
|
|
|
static int large_req_header_name; /**< Large request single header name */
|
|
|
@@ -256,8 +256,8 @@ test_global_cleanup (void)
|
|
|
struct headers_check_result
|
|
|
{
|
|
|
unsigned int num_n1_headers;
|
|
|
- unsigned int large_header_name_size;
|
|
|
- unsigned int large_header_value_size;
|
|
|
+ size_t large_header_name_size;
|
|
|
+ size_t large_header_value_size;
|
|
|
int large_header_valid;
|
|
|
};
|
|
|
|
|
|
@@ -281,7 +281,7 @@ lcurl_hdr_callback (char *buffer, size_t size, size_t nitems,
|
|
|
if (NULL != col_ptr)
|
|
|
{
|
|
|
const char *const name = buffer;
|
|
|
- const size_t name_len = col_ptr - buffer;
|
|
|
+ const size_t name_len = (size_t) (col_ptr - buffer);
|
|
|
const size_t val_pos = name_len + 2;
|
|
|
const size_t val_len = data_size - val_pos - 2; /* 2 = strlen("\r\n") */
|
|
|
const char *const value = buffer + val_pos;
|
|
|
@@ -367,8 +367,8 @@ check_uri_cb (void *cls,
|
|
|
struct mhd_header_checker_param
|
|
|
{
|
|
|
unsigned int num_n1_headers;
|
|
|
- unsigned int large_header_name_size;
|
|
|
- unsigned int large_header_value_size;
|
|
|
+ size_t large_header_name_size;
|
|
|
+ size_t large_header_value_size;
|
|
|
int large_header_valid;
|
|
|
};
|
|
|
|
|
|
@@ -520,10 +520,10 @@ ahcCheck (void *cls,
|
|
|
externalErrorExit ();
|
|
|
large_hrd_name[0] = '0'; /* Name starts with zero for unique identification */
|
|
|
for (i = 1; i < large_hdr_name_size; i++)
|
|
|
- large_hrd_name[i] = 'a' + i % ('z' - 'a' + 1);
|
|
|
+ large_hrd_name[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
|
|
|
large_hrd_name[large_hdr_name_size] = 0;
|
|
|
for (i = 0; i < large_hdr_value_size; i++)
|
|
|
- large_hrd_value[i] = 'Z' - i % ('Z' - 'A' + 1);
|
|
|
+ large_hrd_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1));
|
|
|
if (NULL != large_hrd_value)
|
|
|
large_hrd_value[large_hdr_value_size] = 0;
|
|
|
if (MHD_YES != MHD_add_response_header (response,
|
|
|
@@ -549,7 +549,7 @@ ahcCheck (void *cls,
|
|
|
|
|
|
static CURL *
|
|
|
curlEasyInitForTest (const char *queryPath, const char *method,
|
|
|
- int port,
|
|
|
+ uint16_t port,
|
|
|
struct lcurl_data_cb_param *dcbp,
|
|
|
struct headers_check_result *hdr_chk_result,
|
|
|
struct curl_slist *headers)
|
|
|
@@ -701,13 +701,13 @@ struct curlQueryParams
|
|
|
const char *method;
|
|
|
|
|
|
/* Destination port for CURL query */
|
|
|
- int queryPort;
|
|
|
+ uint16_t queryPort;
|
|
|
|
|
|
/* List of additional request headers */
|
|
|
struct curl_slist *headers;
|
|
|
|
|
|
/* CURL query result error flag */
|
|
|
- volatile int queryError;
|
|
|
+ volatile unsigned int queryError;
|
|
|
|
|
|
/* Response HTTP code, zero if no response */
|
|
|
volatile int responseCode;
|
|
|
@@ -715,7 +715,7 @@ struct curlQueryParams
|
|
|
|
|
|
|
|
|
/* Returns zero for successful response and non-zero for failed response */
|
|
|
-static int
|
|
|
+static unsigned int
|
|
|
doCurlQueryInThread (struct MHD_Daemon *d,
|
|
|
struct curlQueryParams *p,
|
|
|
struct headers_check_result *hdr_res,
|
|
|
@@ -810,13 +810,13 @@ doCurlQueryInThread (struct MHD_Daemon *d,
|
|
|
|
|
|
|
|
|
/* Perform test queries, shut down MHD daemon, and free parameters */
|
|
|
-static int
|
|
|
-performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
+static unsigned int
|
|
|
+performTestQueries (struct MHD_Daemon *d, uint16_t d_port,
|
|
|
struct ahc_cls_type *ahc_param,
|
|
|
struct check_uri_cls *uri_cb_param)
|
|
|
{
|
|
|
struct curlQueryParams qParam;
|
|
|
- int ret = 0; /* Return value */
|
|
|
+ unsigned int ret = 0; /* Return value */
|
|
|
struct headers_check_result rp_headers_check;
|
|
|
char *buf;
|
|
|
size_t i;
|
|
|
@@ -845,7 +845,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
if (large_req_method)
|
|
|
{
|
|
|
for (i = 0; i < TEST_START_SIZE; i++)
|
|
|
- buf[i] = 'A' + i % ('Z' - 'A' + 1);
|
|
|
+ buf[i] = 'A' + (char) (unsigned char) (i % ('Z' - 'A' + 1));
|
|
|
for (; i <= TEST_FAIL_SIZE; i++)
|
|
|
{
|
|
|
buf[i] = 0;
|
|
|
@@ -890,7 +890,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
if (0 != rp_headers_check.large_header_name_size)
|
|
|
mhdErrorExitDesc ("Detected unexpected large reply header");
|
|
|
|
|
|
- buf[i] = 'A' + i % ('Z' - 'A' + 1);
|
|
|
+ buf[i] = 'A' + (char) (unsigned char) (i % ('Z' - 'A' + 1));
|
|
|
}
|
|
|
}
|
|
|
else if (large_req_url)
|
|
|
@@ -901,7 +901,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
memcpy (buf, URL_SCHEME_HOST, base_size);
|
|
|
url[0] = '/';
|
|
|
for (i = 1; i < TEST_START_SIZE; i++)
|
|
|
- url[i] = 'a' + i % ('z' - 'a' + 1);
|
|
|
+ url[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
|
|
|
for (; i <= TEST_FAIL_SIZE; i++)
|
|
|
{
|
|
|
url[i] = 0;
|
|
|
@@ -947,14 +947,14 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
if (0 != rp_headers_check.large_header_name_size)
|
|
|
mhdErrorExitDesc ("Detected unexpected large reply header");
|
|
|
|
|
|
- url[i] = 'a' + i % ('z' - 'a' + 1);
|
|
|
+ url[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
|
|
|
}
|
|
|
}
|
|
|
else if (large_req_header_name)
|
|
|
{
|
|
|
buf[0] = '0'; /* Name starts with zero for unique identification */
|
|
|
for (i = 1; i < TEST_START_SIZE; i++)
|
|
|
- buf[i] = 'a' + i % ('z' - 'a' + 1);
|
|
|
+ buf[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
|
|
|
for (; i <= TEST_FAIL_SIZE; i++)
|
|
|
{
|
|
|
struct curl_slist *curl_headers;
|
|
|
@@ -1020,7 +1020,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
mhdErrorExitDesc ("Detected unexpected large reply header");
|
|
|
|
|
|
curl_slist_free_all (curl_headers);
|
|
|
- buf[i] = 'a' + i % ('z' - 'a' + 1);
|
|
|
+ buf[i] = 'a' + (char) (unsigned char) (i % ('z' - 'a' + 1));
|
|
|
}
|
|
|
}
|
|
|
else if (large_req_header_value)
|
|
|
@@ -1029,7 +1029,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
/* Name starts with zero for unique identification */
|
|
|
memcpy (buf, "0: ", 3); /* Note: strlen(": Z") is less than strlen(URL_SCHEME_HOST) */
|
|
|
for (i = 0; i < TEST_START_SIZE; i++)
|
|
|
- hdr_value[i] = 'Z' - i % ('Z' - 'A' + 1);
|
|
|
+ hdr_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1));
|
|
|
for (; i <= TEST_FAIL_SIZE; i++)
|
|
|
{
|
|
|
struct curl_slist *curl_headers;
|
|
|
@@ -1094,7 +1094,7 @@ performTestQueries (struct MHD_Daemon *d, int d_port,
|
|
|
mhdErrorExitDesc ("Detected unexpected large reply header");
|
|
|
|
|
|
curl_slist_free_all (curl_headers);
|
|
|
- hdr_value[i] = 'Z' - i % ('Z' - 'A' + 1);
|
|
|
+ hdr_value[i] = 'Z' - (char) (unsigned char) (i % ('Z' - 'A' + 1));
|
|
|
}
|
|
|
}
|
|
|
else if (large_req_headers)
|
|
|
@@ -1353,7 +1353,7 @@ enum testMhdPollType
|
|
|
static unsigned int
|
|
|
testNumThreadsForPool (enum testMhdPollType pollType)
|
|
|
{
|
|
|
- int numThreads = MHD_CPU_COUNT;
|
|
|
+ unsigned int numThreads = MHD_CPU_COUNT;
|
|
|
(void) pollType; /* Don't care about pollType for this test */
|
|
|
return numThreads; /* No practical limit for non-cleanup test */
|
|
|
}
|
|
|
@@ -1361,7 +1361,7 @@ testNumThreadsForPool (enum testMhdPollType pollType)
|
|
|
|
|
|
static struct MHD_Daemon *
|
|
|
startTestMhdDaemon (enum testMhdThreadsType thrType,
|
|
|
- enum testMhdPollType pollType, int *pport,
|
|
|
+ enum testMhdPollType pollType, uint16_t *pport,
|
|
|
struct ahc_cls_type **ahc_param,
|
|
|
struct check_uri_cls **uri_cb_param)
|
|
|
{
|
|
|
@@ -1404,7 +1404,7 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
|
|
|
}
|
|
|
|
|
|
if (testMhdThreadInternalPool != thrType)
|
|
|
- d = MHD_start_daemon (((int) thrType) | ((int) pollType)
|
|
|
+ d = MHD_start_daemon (((unsigned int) thrType) | ((unsigned int) pollType)
|
|
|
| (verbose ? MHD_USE_ERROR_LOG : 0),
|
|
|
*pport, NULL, NULL,
|
|
|
&ahcCheck, *ahc_param,
|
|
|
@@ -1414,7 +1414,8 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
|
|
|
(size_t) BUFFER_SIZE,
|
|
|
MHD_OPTION_END);
|
|
|
else
|
|
|
- d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD | ((int) pollType)
|
|
|
+ d = MHD_start_daemon (MHD_USE_INTERNAL_POLLING_THREAD
|
|
|
+ | ((unsigned int) pollType)
|
|
|
| (verbose ? MHD_USE_ERROR_LOG : 0),
|
|
|
*pport, NULL, NULL,
|
|
|
&ahcCheck, *ahc_param,
|
|
|
@@ -1440,7 +1441,7 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
|
|
|
fprintf (stderr, "MHD_get_daemon_info() failed.\n");
|
|
|
abort ();
|
|
|
}
|
|
|
- *pport = (int) dinfo->port;
|
|
|
+ *pport = dinfo->port;
|
|
|
if (0 == global_port)
|
|
|
global_port = *pport; /* Reuse the same port for all tests */
|
|
|
}
|
|
|
@@ -1452,11 +1453,11 @@ startTestMhdDaemon (enum testMhdThreadsType thrType,
|
|
|
/* Test runners */
|
|
|
|
|
|
|
|
|
-static int
|
|
|
+static unsigned int
|
|
|
testExternalGet (void)
|
|
|
{
|
|
|
struct MHD_Daemon *d;
|
|
|
- int d_port = global_port; /* Daemon's port */
|
|
|
+ uint16_t d_port = global_port; /* Daemon's port */
|
|
|
struct ahc_cls_type *ahc_param;
|
|
|
struct check_uri_cls *uri_cb_param;
|
|
|
|
|
|
@@ -1467,11 +1468,11 @@ testExternalGet (void)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static int
|
|
|
+static unsigned int
|
|
|
testInternalGet (enum testMhdPollType pollType)
|
|
|
{
|
|
|
struct MHD_Daemon *d;
|
|
|
- int d_port = global_port; /* Daemon's port */
|
|
|
+ uint16_t d_port = global_port; /* Daemon's port */
|
|
|
struct ahc_cls_type *ahc_param;
|
|
|
struct check_uri_cls *uri_cb_param;
|
|
|
|
|
|
@@ -1482,11 +1483,11 @@ testInternalGet (enum testMhdPollType pollType)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static int
|
|
|
+static unsigned int
|
|
|
testMultithreadedGet (enum testMhdPollType pollType)
|
|
|
{
|
|
|
struct MHD_Daemon *d;
|
|
|
- int d_port = global_port; /* Daemon's port */
|
|
|
+ uint16_t d_port = global_port; /* Daemon's port */
|
|
|
struct ahc_cls_type *ahc_param;
|
|
|
struct check_uri_cls *uri_cb_param;
|
|
|
|
|
|
@@ -1496,11 +1497,11 @@ testMultithreadedGet (enum testMhdPollType pollType)
|
|
|
}
|
|
|
|
|
|
|
|
|
-static int
|
|
|
+static unsigned int
|
|
|
testMultithreadedPoolGet (enum testMhdPollType pollType)
|
|
|
{
|
|
|
struct MHD_Daemon *d;
|
|
|
- int d_port = global_port; /* Daemon's port */
|
|
|
+ uint16_t d_port = global_port; /* Daemon's port */
|
|
|
struct ahc_cls_type *ahc_param;
|
|
|
struct check_uri_cls *uri_cb_param;
|
|
|
|