struct evhttp_connection *
evhttp_connection_new(const char *address, unsigned short port)
{
- return (evhttp_connection_base_new(NULL, address, port));
+ return (evhttp_connection_base_new(NULL, NULL, address, port));
}
struct evhttp_connection *
-evhttp_connection_base_new(struct event_base *base,
+evhttp_connection_base_new(struct event_base *base, struct evdns_base *dnsbase,
const char *address, unsigned short port)
{
struct evhttp_connection *evcon = NULL;
bufferevent_base_set(base, evcon->bufev);
}
+ evcon->dns_base = dnsbase;
+
return (evcon);
error:
return (NULL);
}
-void
-evhttp_connection_set_evdns_base(struct evhttp_connection *evcon,
- struct evdns_base *base)
-{
- EVUTIL_ASSERT(evcon->dns_base == NULL);
- evcon->dns_base = base;
-}
-
void
evhttp_connection_set_base(struct evhttp_connection *evcon,
struct event_base *base)
/* we need a connection object to put the http request on */
evcon = evhttp_connection_base_new(
- http->base, hostname, atoi(portname));
+ http->base, NULL, hostname, atoi(portname));
mm_free(hostname);
mm_free(portname);
if (evcon == NULL)
/** Frees the request object and removes associated events. */
void evhttp_request_free(struct evhttp_request *req);
+struct evdns_base;
+
/**
* A connection object that can be used to for making HTTP requests. The
* connection object tries to resolve address and establish the connection
* when it is given an http request object.
+ *
+ * @param base the event_base to use for handling the connection
+ * @param dnsbase the dns_base to use for resolving host names; if not
+ * specified host name resolution will block.
+ * @param address the address to which to connect
+ * @param port the port to connect to
+ * @return an evhttp_connection object that can be used for making requests
*/
struct evhttp_connection *evhttp_connection_base_new(
- struct event_base *base, const char *address, unsigned short port);
-
-struct evdns_base;
-/**
- * Tell the connection object to use evdns_base when resolving hostnames.
- * If no base is set, it will block when resolving hostnames.
- */
-void evhttp_connection_set_evdns_base(struct evhttp_connection *evcon,
- struct evdns_base *base);
+ struct event_base *base, struct evdns_base *dnsbase,
+ const char *address, unsigned short port);
/** Takes ownership of the request object
*