miniupnpc: Fix UPnP UDA 1.1 content-type charset compliance

and user-agent also in asynchronous sample code. The commits a6aa371166 and b557fdf4db were incomplete.

Field value MUST be "text/xml; charset="utf-8"".
Field value MUST be "text/xml; charset="utf-8"" for description documents.
https://openconnectivity.org/upnp-specs/UPnP-arch-DeviceArchitecture-v1.1.pdf
This commit is contained in:
Self-Hosting-Group 2024-01-08 20:32:51 +01:00
parent e98515ac5e
commit 4fbe3ce431
2 changed files with 7 additions and 7 deletions

View File

@ -400,7 +400,7 @@ static int upnpc_send_request(upnpc_device_t * p)
static const char reqfmt[] = "GET %s HTTP/1.1\r\n"
"Host: %s:%hu\r\n"
"Connection: Close\r\n"
"User-Agent: MiniUPnPc-async\r\n"
"User-Agent: OS/version UPnP/1.1 MiniUPnPc-async/2.2\r\n"
"\r\n";
/* retrieve "our" IP address used to connect to the UPnP device */
@ -689,9 +689,9 @@ static int upnpc_build_soap_request(upnpc_device_t * p, const char * url,
const char fmt_http[] =
"POST %s HTTP/1.1\r\n"
"Host: %s%s\r\n"
"User-Agent: MiniUPnPc-async\r\n"
"User-Agent: OS/version UPnP/1.1 MiniUPnPc-async/2.2\r\n"
"Content-Length: %d\r\n"
"Content-Type: text/xml\r\n"
"Content-Type: text/xml charset=\"utf-8\"\r\n"
"SOAPAction: \"%s#%s\"\r\n"
"Connection: Close\r\n"
"Cache-Control: no-cache\r\n" /* ??? */

View File

@ -528,7 +528,7 @@ static int upnpc_get_desc(upnpc_device_t * d, const char * url)
headers = evhttp_request_get_output_headers(req);
evhttp_add_header(headers, "Host", hostname_port);
evhttp_add_header(headers, "Connection", "close");
/*evhttp_add_header(headers, "User-Agent", "***");*/
/*evhttp_add_header(headers, "User-Agent", "OS/version UPnP/1.1 MiniUPnPc-libevent/2.2");*/
return evhttp_make_request(d->desc_conn, req, EVHTTP_REQ_GET, path);
}
@ -644,8 +644,8 @@ static int upnpc_send_soap_request(upnpc_device_t * p, const char * url,
buffer = evhttp_request_get_output_buffer(req);
evhttp_add_header(headers, "Host", hostname_port);
evhttp_add_header(headers, "SOAPAction", action);
evhttp_add_header(headers, "Content-Type", "text/xml");
/*evhttp_add_header(headers, "User-Agent", "***");*/
evhttp_add_header(headers, "Content-Type", "text/xml; charset=\"utf-8\"");
/*evhttp_add_header(headers, "User-Agent", "OS/version UPnP/1.1 MiniUPnPc-libevent/2.2");*/
/*evhttp_add_header(headers, "Cache-Control", "no-cache");*/
/*evhttp_add_header(headers, "Pragma", "no-cache");*/
evbuffer_add(buffer, body, body_len);
@ -958,7 +958,7 @@ int upnpc_event_subscribe(upnpc_device_t * p)
headers = evhttp_request_get_output_headers(req);
/*buffer = evhttp_request_get_output_buffer(req);*/
evhttp_add_header(headers, "Host", hostname_port);
/*evhttp_add_header(headers, "User-Agent", "***");*/
/*evhttp_add_header(headers, "User-Agent", "OS/version UPnP/1.1 MiniUPnPc-libevent/2.2");*/
snprintf(callback_header, sizeof(callback_header), "<http://%s:%hu/evt_conn>", p->parent->local_address, p->parent->local_port);
evhttp_add_header(headers, "Callback", callback_header);
evhttp_add_header(headers, "NT", "upnp:event");