mirror of
https://github.com/libevent/libevent.git
synced 2025-01-20 05:02:55 +08:00
test/http: add a helper for creating timedout/failed request
This commit is contained in:
parent
d02a2858fa
commit
376f107318
@ -1362,6 +1362,17 @@ enum http_cancel_test_type {
|
|||||||
SERVER_TIMEOUT = 16,
|
SERVER_TIMEOUT = 16,
|
||||||
NS_TIMEOUT = 32,
|
NS_TIMEOUT = 32,
|
||||||
};
|
};
|
||||||
|
static struct evhttp_request *
|
||||||
|
http_cancel_test_bad_request_new(enum http_cancel_test_type type,
|
||||||
|
struct event_base *base)
|
||||||
|
{
|
||||||
|
if (!(type & NO_NS) && (type & SERVER_TIMEOUT))
|
||||||
|
return evhttp_request_new(http_timed_out_request_done, base);
|
||||||
|
else if ((type & INACTIVE_SERVER) || (type & NO_NS))
|
||||||
|
return evhttp_request_new(http_failed_request_done, base);
|
||||||
|
else
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
static void
|
static void
|
||||||
http_cancel_test(void *arg)
|
http_cancel_test(void *arg)
|
||||||
{
|
{
|
||||||
@ -1465,11 +1476,8 @@ http_cancel_test(void *arg)
|
|||||||
if (type & SERVER_TIMEOUT)
|
if (type & SERVER_TIMEOUT)
|
||||||
evcons = http_fill_backlog(inactive_base ?: data->base, port);
|
evcons = http_fill_backlog(inactive_base ?: data->base, port);
|
||||||
|
|
||||||
if (!(type & NO_NS) && (type & SERVER_TIMEOUT))
|
req = http_cancel_test_bad_request_new(type, data->base);
|
||||||
req = evhttp_request_new(http_timed_out_request_done, data->base);
|
if (!req)
|
||||||
else if ((type & INACTIVE_SERVER) || (type & NO_NS))
|
|
||||||
req = evhttp_request_new(http_failed_request_done, data->base);
|
|
||||||
else
|
|
||||||
req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY);
|
req = evhttp_request_new(http_request_done, (void*) BASIC_REQUEST_BODY);
|
||||||
|
|
||||||
/* Add the information that we care about */
|
/* Add the information that we care about */
|
||||||
@ -1488,11 +1496,8 @@ http_cancel_test(void *arg)
|
|||||||
if (type & SERVER_TIMEOUT)
|
if (type & SERVER_TIMEOUT)
|
||||||
evcons = http_fill_backlog(inactive_base ?: data->base, port);
|
evcons = http_fill_backlog(inactive_base ?: data->base, port);
|
||||||
|
|
||||||
if (!(type & NO_NS) && (type & SERVER_TIMEOUT))
|
req = http_cancel_test_bad_request_new(type, data->base);
|
||||||
req = evhttp_request_new(http_timed_out_request_done, data->base);
|
if (!req)
|
||||||
else if ((type & INACTIVE_SERVER) || (type & NO_NS))
|
|
||||||
req = evhttp_request_new(http_failed_request_done, data->base);
|
|
||||||
else
|
|
||||||
req = evhttp_request_new(http_request_empty_done, data->base);
|
req = evhttp_request_new(http_request_empty_done, data->base);
|
||||||
|
|
||||||
/* Add the information that we care about */
|
/* Add the information that we care about */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user