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:
Fabrice Fontaine 2010-09-21 17:23:58 +02:00 committed by Marcelo Roberto Jimenez
parent 82beb315c2
commit 5ead3f6fee
4 changed files with 31 additions and 5 deletions

View File

@ -221,6 +221,13 @@ Version 1.8.0
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>
Addition of WEB_SERVER_CONTENT_LANGUAGE parameter

View File

@ -1908,7 +1908,8 @@ http_SendStatusResponse( IN SOCKINFO * info,
* 'G': arg = range information // add range header
* 'h': arg = off_t number // appends off_t number
* '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
* 'N': arg1 = off_t content_length // content-length 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' ) {
// Add CONTENT-LANGUAGE header only if WEB_SERVER_CONTENT_LANGUAGE
// is not empty
if (strcmp( WEB_SERVER_CONTENT_LANGUAGE, "" ) && http_MakeMessage(
// is not empty and if Accept-Language header is not empty
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,
"ssc",
"CONTENT-LANGUAGE: ", WEB_SERVER_CONTENT_LANGUAGE ) != 0 ) {

View File

@ -1128,6 +1128,12 @@ CheckOtherHTTPHeaders( IN http_message_t * Req,
return RetCode;
}
break;
case HDR_ACCEPT_LANGUAGE:
{
memcpy( RespInstr->AcceptLanguageHeader, TmpBuf,
sizeof( RespInstr->AcceptLanguageHeader ) - 1 );
break;
}
default:
/*
TODO
@ -1142,7 +1148,6 @@ CheckOtherHTTPHeaders( IN http_message_t * Req,
case HDR_CONTENT_LOCATION://return 1;
case HDR_ACCEPT: //return 1;
case HDR_ACCEPT_CHARSET://return 1;
case HDR_ACCEPT_LANGUAGE://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
UpnpFileInfo_get_ContentType(finfo), // content type
RespInstr, // range info
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
X_USER_AGENT,
@ -1420,6 +1426,7 @@ process_request( IN http_message_t * req,
RespInstr->ReadSendSize, // content length
UpnpFileInfo_get_ContentType(finfo), // content type
RespInstr, // range info
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
X_USER_AGENT,
@ -1435,6 +1442,7 @@ process_request( IN http_message_t * req,
"RK" "TLD" "s" "tcS" "Xc" "sCc",
HTTP_OK, // status code
UpnpFileInfo_get_ContentType(finfo), // content type
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
X_USER_AGENT,
@ -1452,6 +1460,7 @@ process_request( IN http_message_t * req,
HTTP_OK, // status code
RespInstr->ReadSendSize, // content length
UpnpFileInfo_get_ContentType(finfo), // content type
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
X_USER_AGENT,
@ -1466,6 +1475,7 @@ process_request( IN http_message_t * req,
"R" "TLD" "s" "tcS" "b" "Xc" "sCc",
HTTP_OK, // status code
UpnpFileInfo_get_ContentType(finfo), // content type
RespInstr, // language info
"LAST-MODIFIED: ",
UpnpFileInfo_get_LastModified(finfo),
X_USER_AGENT,
@ -1699,6 +1709,8 @@ web_server_callback( IN http_parser_t * parser,
RespInstr.IsChunkActive = 0;
RespInstr.IsRangeActive = 0;
RespInstr.IsTrailers = 0;
memset( RespInstr.AcceptLanguageHeader, 0,
sizeof( RespInstr.AcceptLanguageHeader ) );
// init
membuffer_init( &headers );
membuffer_init( &filename );
@ -1753,7 +1765,7 @@ web_server_callback( IN http_parser_t * parser,
http_MakeMessage(
&headers, 1, 1,
"RLTDSXcCc",
"RTLSXcCc",
ret,
"text/html",
X_USER_AGENT );

View File

@ -48,6 +48,7 @@ struct SendInstruction
int IsRangeActive;
int IsTrailers;
char RangeHeader[200];
char AcceptLanguageHeader[200];
off_t RangeOffset;
off_t ReadSendSize; // Read from local source and send on the network.
long RecvWriteSize; // Recv from the network and write into local file.