]> granicus.if.org Git - libevent/commitdiff
test: http/non_lingering_close: cover ~EVHTTP_SERVER_LINGERING_CLOSE
authorAzat Khuzhin <a3at.mail@gmail.com>
Mon, 15 Feb 2016 00:13:02 +0000 (03:13 +0300)
committerAzat Khuzhin <a3at.mail@gmail.com>
Wed, 9 Mar 2016 15:52:52 +0000 (18:52 +0300)
test/regress_http.c

index 1f326de6fa2d87a825b4893d811445a11add78c6..e57a15b668ccfd3b071077c2c33eddbddff2b4ed 100644 (file)
@@ -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),