Add Content-Language iff Accept-Language
Add Content-Language header in the response if and only if there is an Accept-Language header in the request.
Manually ported from revision d2238615e3
.
This commit is contained in:
parent
82beb315c2
commit
5ead3f6fee
@ -221,6 +221,13 @@ Version 1.8.0
|
|||||||
Version 1.6.7
|
Version 1.6.7
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2010-09-21 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
|
||||||
|
|
||||||
|
Add Content-Language iff Accept-Language
|
||||||
|
|
||||||
|
Add Content-Language header in the response if and only if there is an
|
||||||
|
Accept-Language header in the request.
|
||||||
|
|
||||||
2010-09-21 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
|
2010-09-21 Fabrice Fontaine <fabrice.fontaine(at)orange-ftgroup.com>
|
||||||
|
|
||||||
Addition of WEB_SERVER_CONTENT_LANGUAGE parameter
|
Addition of WEB_SERVER_CONTENT_LANGUAGE parameter
|
||||||
|
@ -1908,7 +1908,8 @@ http_SendStatusResponse( IN SOCKINFO * info,
|
|||||||
* 'G': arg = range information // add range header
|
* 'G': arg = range information // add range header
|
||||||
* 'h': arg = off_t number // appends off_t number
|
* 'h': arg = off_t number // appends off_t number
|
||||||
* 'K': (no args) // add chunky header
|
* 'K': (no args) // add chunky header
|
||||||
* 'L': (no args) appends HTTP Content-Language: header if
|
* 'L': arg = language information // add Content-Language header if
|
||||||
|
* Accept-Language header is not empty and if
|
||||||
* WEB_SERVER_CONTENT_LANGUAGE is not empty
|
* WEB_SERVER_CONTENT_LANGUAGE is not empty
|
||||||
* 'N': arg1 = off_t content_length // content-length header
|
* 'N': arg1 = off_t content_length // content-length header
|
||||||
* 'q': arg1 = http_method_t // request start line and HOST header
|
* 'q': arg1 = http_method_t // request start line and HOST header
|
||||||
@ -2055,8 +2056,13 @@ http_MakeMessage( INOUT membuffer * buf,
|
|||||||
}
|
}
|
||||||
} else if ( c == 'L' ) {
|
} else if ( c == 'L' ) {
|
||||||
// Add CONTENT-LANGUAGE header only if WEB_SERVER_CONTENT_LANGUAGE
|
// Add CONTENT-LANGUAGE header only if WEB_SERVER_CONTENT_LANGUAGE
|
||||||
// is not empty
|
// is not empty and if Accept-Language header is not empty
|
||||||
if (strcmp( WEB_SERVER_CONTENT_LANGUAGE, "" ) && http_MakeMessage(
|
struct SendInstruction *RespInstr;
|
||||||
|
RespInstr = (struct SendInstruction *)
|
||||||
|
va_arg( argp, struct SendInstruction *);
|
||||||
|
assert( RespInstr );
|
||||||
|
if (strcmp( RespInstr->AcceptLanguageHeader, "" ) &&
|
||||||
|
strcmp( WEB_SERVER_CONTENT_LANGUAGE, "" ) && http_MakeMessage(
|
||||||
buf, http_major_version, http_minor_version,
|
buf, http_major_version, http_minor_version,
|
||||||
"ssc",
|
"ssc",
|
||||||
"CONTENT-LANGUAGE: ", WEB_SERVER_CONTENT_LANGUAGE ) != 0 ) {
|
"CONTENT-LANGUAGE: ", WEB_SERVER_CONTENT_LANGUAGE ) != 0 ) {
|
||||||
|
@ -1128,6 +1128,12 @@ CheckOtherHTTPHeaders( IN http_message_t * Req,
|
|||||||
return RetCode;
|
return RetCode;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case HDR_ACCEPT_LANGUAGE:
|
||||||
|
{
|
||||||
|
memcpy( RespInstr->AcceptLanguageHeader, TmpBuf,
|
||||||
|
sizeof( RespInstr->AcceptLanguageHeader ) - 1 );
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
/*
|
/*
|
||||||
TODO
|
TODO
|
||||||
@ -1142,7 +1148,6 @@ CheckOtherHTTPHeaders( IN http_message_t * Req,
|
|||||||
case HDR_CONTENT_LOCATION://return 1;
|
case HDR_CONTENT_LOCATION://return 1;
|
||||||
case HDR_ACCEPT: //return 1;
|
case HDR_ACCEPT: //return 1;
|
||||||
case HDR_ACCEPT_CHARSET://return 1;
|
case HDR_ACCEPT_CHARSET://return 1;
|
||||||
case HDR_ACCEPT_LANGUAGE://return 1;
|
|
||||||
case HDR_USER_AGENT: break;//return 1;
|
case HDR_USER_AGENT: break;//return 1;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1404,6 +1409,7 @@ process_request( IN http_message_t * req,
|
|||||||
HTTP_PARTIAL_CONTENT, // status code
|
HTTP_PARTIAL_CONTENT, // status code
|
||||||
UpnpFileInfo_get_ContentType(finfo), // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
RespInstr, // range info
|
RespInstr, // range info
|
||||||
|
RespInstr, // language info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
UpnpFileInfo_get_LastModified(finfo),
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT,
|
X_USER_AGENT,
|
||||||
@ -1420,6 +1426,7 @@ process_request( IN http_message_t * req,
|
|||||||
RespInstr->ReadSendSize, // content length
|
RespInstr->ReadSendSize, // content length
|
||||||
UpnpFileInfo_get_ContentType(finfo), // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
RespInstr, // range info
|
RespInstr, // range info
|
||||||
|
RespInstr, // language info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
UpnpFileInfo_get_LastModified(finfo),
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT,
|
X_USER_AGENT,
|
||||||
@ -1435,6 +1442,7 @@ process_request( IN http_message_t * req,
|
|||||||
"RK" "TLD" "s" "tcS" "Xc" "sCc",
|
"RK" "TLD" "s" "tcS" "Xc" "sCc",
|
||||||
HTTP_OK, // status code
|
HTTP_OK, // status code
|
||||||
UpnpFileInfo_get_ContentType(finfo), // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
|
RespInstr, // language info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
UpnpFileInfo_get_LastModified(finfo),
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT,
|
X_USER_AGENT,
|
||||||
@ -1452,6 +1460,7 @@ process_request( IN http_message_t * req,
|
|||||||
HTTP_OK, // status code
|
HTTP_OK, // status code
|
||||||
RespInstr->ReadSendSize, // content length
|
RespInstr->ReadSendSize, // content length
|
||||||
UpnpFileInfo_get_ContentType(finfo), // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
|
RespInstr, // language info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
UpnpFileInfo_get_LastModified(finfo),
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT,
|
X_USER_AGENT,
|
||||||
@ -1466,6 +1475,7 @@ process_request( IN http_message_t * req,
|
|||||||
"R" "TLD" "s" "tcS" "b" "Xc" "sCc",
|
"R" "TLD" "s" "tcS" "b" "Xc" "sCc",
|
||||||
HTTP_OK, // status code
|
HTTP_OK, // status code
|
||||||
UpnpFileInfo_get_ContentType(finfo), // content type
|
UpnpFileInfo_get_ContentType(finfo), // content type
|
||||||
|
RespInstr, // language info
|
||||||
"LAST-MODIFIED: ",
|
"LAST-MODIFIED: ",
|
||||||
UpnpFileInfo_get_LastModified(finfo),
|
UpnpFileInfo_get_LastModified(finfo),
|
||||||
X_USER_AGENT,
|
X_USER_AGENT,
|
||||||
@ -1699,6 +1709,8 @@ web_server_callback( IN http_parser_t * parser,
|
|||||||
RespInstr.IsChunkActive = 0;
|
RespInstr.IsChunkActive = 0;
|
||||||
RespInstr.IsRangeActive = 0;
|
RespInstr.IsRangeActive = 0;
|
||||||
RespInstr.IsTrailers = 0;
|
RespInstr.IsTrailers = 0;
|
||||||
|
memset( RespInstr.AcceptLanguageHeader, 0,
|
||||||
|
sizeof( RespInstr.AcceptLanguageHeader ) );
|
||||||
// init
|
// init
|
||||||
membuffer_init( &headers );
|
membuffer_init( &headers );
|
||||||
membuffer_init( &filename );
|
membuffer_init( &filename );
|
||||||
@ -1753,7 +1765,7 @@ web_server_callback( IN http_parser_t * parser,
|
|||||||
|
|
||||||
http_MakeMessage(
|
http_MakeMessage(
|
||||||
&headers, 1, 1,
|
&headers, 1, 1,
|
||||||
"RLTDSXcCc",
|
"RTLSXcCc",
|
||||||
ret,
|
ret,
|
||||||
"text/html",
|
"text/html",
|
||||||
X_USER_AGENT );
|
X_USER_AGENT );
|
||||||
|
@ -48,6 +48,7 @@ struct SendInstruction
|
|||||||
int IsRangeActive;
|
int IsRangeActive;
|
||||||
int IsTrailers;
|
int IsTrailers;
|
||||||
char RangeHeader[200];
|
char RangeHeader[200];
|
||||||
|
char AcceptLanguageHeader[200];
|
||||||
off_t RangeOffset;
|
off_t RangeOffset;
|
||||||
off_t ReadSendSize; // Read from local source and send on the network.
|
off_t ReadSendSize; // Read from local source and send on the network.
|
||||||
long RecvWriteSize; // Recv from the network and write into local file.
|
long RecvWriteSize; // Recv from the network and write into local file.
|
||||||
|
Loading…
Reference in New Issue
Block a user