adapt code to new libevent method extension

This commit is contained in:
Thomas Bernard 2015-09-15 23:28:59 +02:00
parent b510f06ef3
commit e1f7a63044
1 changed files with 10 additions and 0 deletions

View File

@ -651,6 +651,14 @@ static int upnpc_send_soap_request(upnpc_device_t * p, const char * url,
} }
#ifdef ENABLE_UPNP_EVENTS #ifdef ENABLE_UPNP_EVENTS
#define EVHTTP_REQ_NOTIFY ((EVHTTP_REQ_MAX) << 1)
#define EVHTTP_REQ_SUBSCRIBE ((EVHTTP_REQ_NOTIFY) << 1)
static const struct evhttp_extended_methods ext_methods[] = {
{"NOTIFY", EVHTTP_REQ_NOTIFY, EVHTTP_METHOD_HAS_BODY},
{"SUBSCRIBE", EVHTTP_REQ_SUBSCRIBE, EVHTTP_METHOD_HAS_BODY},
{NULL, 0, 0}
};
void upnpc_event_conn_req(struct evhttp_request * req, void * data) void upnpc_event_conn_req(struct evhttp_request * req, void * data)
{ {
size_t len; size_t len;
@ -894,6 +902,7 @@ int upnpc_event_subscribe(upnpc_device_t * p)
debug_printf("evhttp_new() FAILED\n"); debug_printf("evhttp_new() FAILED\n");
return -1; return -1;
} }
evhttp_set_extended_methods(p->parent->http_server, ext_methods);
evhttp_set_allowed_methods(p->parent->http_server, EVHTTP_REQ_NOTIFY); evhttp_set_allowed_methods(p->parent->http_server, EVHTTP_REQ_NOTIFY);
evhttp_set_cb(p->parent->http_server, "/evt_conn", upnpc_event_conn_req, p); evhttp_set_cb(p->parent->http_server, "/evt_conn", upnpc_event_conn_req, p);
if(evhttp_bind_socket(p->parent->http_server, p->parent->local_address, p->parent->local_port) < 0) { if(evhttp_bind_socket(p->parent->http_server, p->parent->local_address, p->parent->local_port) < 0) {
@ -912,6 +921,7 @@ int upnpc_event_subscribe(upnpc_device_t * p)
if(p->soap_conn == NULL) { if(p->soap_conn == NULL) {
p->soap_conn = evhttp_connection_base_new(p->parent->base, NULL, hostname, port); p->soap_conn = evhttp_connection_base_new(p->parent->base, NULL, hostname, port);
} }
evhttp_connection_set_extended_methods(p->soap_conn, ext_methods);
req = evhttp_request_new(upnpc_subscribe_response, p); req = evhttp_request_new(upnpc_subscribe_response, p);
headers = evhttp_request_get_output_headers(req); headers = evhttp_request_get_output_headers(req);
/*buffer = evhttp_request_get_output_buffer(req);*/ /*buffer = evhttp_request_get_output_buffer(req);*/