static void
http_connection_test_(struct basic_test_data *data, int persistent,
- const char *address, struct evdns_base *dnsbase, int ipv6, int family)
+ const char *address, struct evdns_base *dnsbase, int ipv6, int family,
+ int ssl)
{
ev_uint16_t port = 0;
struct evhttp_connection *evcon = NULL;
struct evhttp_request *req = NULL;
- struct evhttp *http = http_setup(&port, data->base, ipv6);
+ struct evhttp *http;
+
+ int mask = 0;
+ if (ipv6)
+ mask |= HTTP_BIND_IPV6;
+ if (ssl)
+ mask |= HTTP_BIND_SSL;
+
+ http = http_setup(&port, data->base, mask);
test_ok = 0;
if (!http && ipv6) {
}
tt_assert(http);
- evcon = evhttp_connection_base_new(data->base, dnsbase, address, port);
+ if (ssl) {
+#ifdef EVENT__HAVE_OPENSSL
+ SSL *ssl = SSL_new(get_ssl_ctx());
+ struct bufferevent *bev = bufferevent_openssl_socket_new(
+ data->base, -1, ssl,
+ BUFFEREVENT_SSL_CONNECTING, BEV_OPT_DEFER_CALLBACKS);
+ bufferevent_openssl_set_allow_dirty_shutdown(bev, 1);
+
+ evcon = evhttp_connection_base_bufferevent_new(data->base, dnsbase, bev, address, port);
+#else
+ tt_skip();
+#endif
+ } else {
+ evcon = evhttp_connection_base_new(data->base, dnsbase, address, port);
+ }
tt_assert(evcon);
evhttp_connection_set_family(evcon, family);
static void
http_connection_test(void *arg)
{
- http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC);
+ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC, 0);
}
static void
http_persist_connection_test(void *arg)
{
- http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC);
+ http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC, 0);
}
static struct regress_dns_server_table search_table[] = {
{
const char *what = arg;
+ if (!req) {
+ fprintf(stderr, "FAILED\n");
+ exit(1);
+ }
+
if (evhttp_request_get_response_code(req) != HTTP_OK) {
fprintf(stderr, "FAILED\n");
exit(1);
evdns_base_nameserver_ip_add(dns_base, address);
http_connection_test_(arg, 0 /* not persistent */, "localhost", dns_base,
- 1 /* ipv6 */, family);
+ 1 /* ipv6 */, family, 0);
end:
if (dns_base)
static void
http_set_family_test(void *arg)
{
- http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC);
+ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC, 0);
}
static void
http_set_family_ipv4_test(void *arg)
{
- http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_INET);
+ http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_INET, 0);
}
static void
http_set_family_ipv6_test(void *arg)
{ return http_connection_fail_test_impl(arg, 1); }
static void https_write_during_read_test(void *arg)
{ return http_write_during_read_test_impl(arg, 1); }
+static void https_connection_test(void *arg)
+{ return http_connection_test_(arg, 0, "127.0.0.1", NULL, 0, AF_UNSPEC, 1); }
+static void https_persist_connection_test(void *arg)
+{ return http_connection_test_(arg, 1, "127.0.0.1", NULL, 0, AF_UNSPEC, 1); }
#endif
struct testcase_t http_testcases[] = {
HTTPS(stream_out),
HTTPS(connection_fail),
HTTPS(write_during_read),
+ HTTPS(connection),
+ HTTPS(persist_connection),
#endif
END_OF_TESTCASES