miniupnpd/upnphttp: Support for Accept-Language/Content-Language HTTP headers
This commit is contained in:
parent
988594dfe6
commit
727eaeb2e8
|
@ -5,6 +5,7 @@ $Id: Changelog.txt,v 1.309 2012/09/27 16:01:10 nanard Exp $
|
|||
and UPNP_STRICT
|
||||
UPC must be a 12 decimal digit code
|
||||
SetDefaultConnectionService() checks its argumnents in UPNP_STRICT mode
|
||||
Support for Accept-Language/Content-Language HTTP headers
|
||||
|
||||
2012/09/20:
|
||||
Cleaning code in ipfw (Jardel Weyrich)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: upnphttp.c,v 1.73 2012/05/28 13:26:58 nanard Exp $ */
|
||||
/* $Id: upnphttp.c,v 1.76 2012/09/27 13:15:03 nanard Exp $ */
|
||||
/* Project : miniupnp
|
||||
* Website : http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* Author : Thomas Bernard
|
||||
|
@ -111,6 +111,24 @@ ParseHttpHeaders(struct upnphttp * h)
|
|||
h->req_soapActionOff = p - h->req_buf;
|
||||
h->req_soapActionLen = n;
|
||||
}
|
||||
else if(strncasecmp(line, "accept-language", 15) == 0)
|
||||
{
|
||||
p = colon;
|
||||
n = 0;
|
||||
while(*p == ':' || *p == ' ' || *p == '\t')
|
||||
p++;
|
||||
while(p[n]>=' ')
|
||||
n++;
|
||||
syslog(LOG_DEBUG, "accept-language HTTP header : '%.*s'", n, p);
|
||||
/* keep only the 1st accepted language */
|
||||
n = 0;
|
||||
while(p[n]>' ' && p[n] != ',')
|
||||
n++;
|
||||
if(n >= (int)sizeof(h->accept_language))
|
||||
n = (int)sizeof(h->accept_language) - 1;
|
||||
memcpy(h->accept_language, p, n);
|
||||
h->accept_language[n] = '\0';
|
||||
}
|
||||
#ifdef ENABLE_EVENTS
|
||||
else if(strncasecmp(line, "Callback", 8)==0)
|
||||
{
|
||||
|
@ -708,6 +726,13 @@ BuildHeader_upnphttp(struct upnphttp * h, int respcode,
|
|||
h->res_buf_alloclen - h->res_buflen,
|
||||
"Allow: %s\r\n", "SUBSCRIBE, UNSUBSCRIBE");
|
||||
}
|
||||
if(h->accept_language[0] != '\0') {
|
||||
/* defaulting to "en" */
|
||||
h->res_buflen += snprintf(h->res_buf + h->res_buflen,
|
||||
h->res_buf_alloclen - h->res_buflen,
|
||||
"Content-Language: %s\r\n",
|
||||
h->accept_language[0] == '*' ? "en" : h->accept_language);
|
||||
}
|
||||
h->res_buf[h->res_buflen++] = '\r';
|
||||
h->res_buf[h->res_buflen++] = '\n';
|
||||
if(h->res_buf_alloclen < (h->res_buflen + bodylen))
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: upnphttp.h,v 1.31 2012/05/28 11:00:44 nanard Exp $ */
|
||||
/* $Id: upnphttp.h,v 1.34 2012/09/27 15:47:15 nanard Exp $ */
|
||||
/* MiniUPnP project
|
||||
* http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/
|
||||
* (c) 2006-2012 Thomas Bernard
|
||||
|
@ -57,6 +57,7 @@ struct upnphttp {
|
|||
char HttpVer[16];
|
||||
/* request */
|
||||
char * req_buf;
|
||||
char accept_language[8];
|
||||
int req_buflen;
|
||||
int req_contentlen;
|
||||
int req_contentoff; /* header length */
|
||||
|
@ -92,6 +93,7 @@ struct upnphttp {
|
|||
#define FLAG_ALLOW_POST 0x100
|
||||
#define FLAG_ALLOW_SUB_UNSUB 0x200
|
||||
|
||||
|
||||
/* New_upnphttp() */
|
||||
struct upnphttp *
|
||||
New_upnphttp(int);
|
||||
|
|
Loading…
Reference in New Issue