From: Nick Mathewson Date: Thu, 21 Oct 2010 16:19:28 +0000 (-0400) Subject: Add evhttp_connection_get_base() to get the event_base from an http connection X-Git-Tag: release-2.0.9-rc~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cd00079b2266893472fac795a69fe8aaea6c52e0;p=libevent Add evhttp_connection_get_base() to get the event_base from an http connection Based on a patch by Mark Ellzey from 27 July 2010. Closes ticket 3052406 --- diff --git a/http.c b/http.c index 6aca33c3..aceff253 100644 --- a/http.c +++ b/http.c @@ -3045,6 +3045,11 @@ evhttp_request_get_connection(struct evhttp_request *req) return req->evcon; } +struct event_base * +evhttp_connection_get_base(struct evhttp_connection *conn) +{ + return conn->base; +} void evhttp_request_set_chunked_cb(struct evhttp_request *req, diff --git a/include/event2/http.h b/include/event2/http.h index d872a189..a4cbbcc8 100644 --- a/include/event2/http.h +++ b/include/event2/http.h @@ -383,6 +383,11 @@ int evhttp_request_is_owned(struct evhttp_request *req); */ struct evhttp_connection *evhttp_request_get_connection(struct evhttp_request *req); +/** + * Returns the underlying event_base for this connection + */ +struct event_base *evhttp_connection_get_base(struct evhttp_connection *req); + void evhttp_connection_set_max_headers_size(struct evhttp_connection *evcon, ev_ssize_t new_max_headers_size); diff --git a/test/regress_http.c b/test/regress_http.c index e2fd987b..2cb0875d 100644 --- a/test/regress_http.c +++ b/test/regress_http.c @@ -670,6 +670,8 @@ _http_connection_test(int persistent) evcon = evhttp_connection_new("127.0.0.1", port); tt_assert(evcon); + tt_assert(evhttp_connection_get_base(evcon) == NULL); + /* * At this point, we want to schedule a request to the HTTP * server using our make request method.