mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-08 11:53:00 -04:00
test: http/non_lingering_close: cover ~EVHTTP_SERVER_LINGERING_CLOSE
This commit is contained in:
parent
addf2b90ae
commit
f41e1b016f
@ -3862,6 +3862,57 @@ http_data_length_constraints_test(void *arg)
|
||||
evhttp_free(http);
|
||||
}
|
||||
|
||||
static void
|
||||
http_large_entity_non_lingering_test_done(struct evhttp_request *req, void *arg)
|
||||
{
|
||||
tt_assert(!req);
|
||||
end:
|
||||
event_base_loopexit(arg, NULL);
|
||||
}
|
||||
static void
|
||||
http_non_lingering_close_test(void *arg)
|
||||
{
|
||||
struct basic_test_data *data = arg;
|
||||
ev_uint16_t port = 0;
|
||||
struct evhttp_connection *evcon = NULL;
|
||||
struct evhttp_request *req = NULL;
|
||||
char long_str[(1<<20) * 3];
|
||||
|
||||
test_ok = 0;
|
||||
|
||||
http = http_setup(&port, data->base, 0);
|
||||
evhttp_set_max_body_size(http, sizeof(long_str)/2);
|
||||
|
||||
evcon = evhttp_connection_base_new(data->base, NULL, "127.0.0.1", port);
|
||||
tt_assert(evcon);
|
||||
evhttp_connection_set_local_address(evcon, "127.0.0.1");
|
||||
|
||||
/*
|
||||
* At this point, we want to schedule an HTTP GET request
|
||||
* server using our make request method.
|
||||
*/
|
||||
|
||||
memset(long_str, 'a', sizeof(long_str));
|
||||
long_str[sizeof(long_str)-1] = '\0';
|
||||
|
||||
req = evhttp_request_new(http_large_entity_non_lingering_test_done, data->base);
|
||||
tt_assert(req);
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Host", "somehost");
|
||||
evhttp_add_header(evhttp_request_get_output_headers(req), "Expect", "100-continue");
|
||||
evbuffer_add_printf(evhttp_request_get_output_buffer(req), "%s", long_str);
|
||||
if (evhttp_make_request(evcon, req, EVHTTP_REQ_POST, "/") == -1) {
|
||||
tt_abort_msg("Couldn't make request");
|
||||
}
|
||||
event_base_dispatch(data->base);
|
||||
|
||||
test_ok = 1;
|
||||
end:
|
||||
if (evcon)
|
||||
evhttp_connection_free(evcon);
|
||||
if (http)
|
||||
evhttp_free(http);
|
||||
}
|
||||
|
||||
/*
|
||||
* Testing client reset of server chunked connections
|
||||
*/
|
||||
@ -4305,6 +4356,7 @@ struct testcase_t http_testcases[] = {
|
||||
TT_ISOLATED|TT_OFF_BY_DEFAULT, &basic_setup, NULL },
|
||||
|
||||
HTTP(data_length_constraints),
|
||||
HTTP(non_lingering_close),
|
||||
|
||||
HTTP(ipv6_for_domain),
|
||||
HTTP(get_addr),
|
||||
|
Loading…
x
Reference in New Issue
Block a user