r59529 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r59528‎ | r59529 | r59530 >
Date:20:13, 28 November 2009
Author:philip
Status:deferred (Comments)
Tags:
Comment:
follow-up r59522. "string-contains" added.
Modified paths:
  • /trunk/phase3/languages/LanguageConverter.php (modified) (history)

Diff [purge]

Index: trunk/phase3/languages/LanguageConverter.php
@@ -242,9 +242,15 @@
243243 if( $ret_language !== $this->mMainLanguageCode ) {
244244 global $wgOut, $wgUseXVO;
245245 $wgOut->addVaryHeader( 'Accept-Language' );
246 - if( $wgUseXVO )
247 - $wgOut->addXVOHeader( 'Accept-Language' );
248 -
 246+ if( $wgUseXVO ) {
 247+ $aloption = array();
 248+ foreach( $this->mVariants as $variant ) {
 249+ if($variant === $this->mMainLanguageCode)
 250+ continue;
 251+ $aloption[] = 'string-contains=' . $variant;
 252+ }
 253+ $wgOut->addXVOHeader( 'Accept-Language', $aloption );
 254+ }
249255 }
250256 return $ret_language;
251257 }

Follow-up revisions

RevisionCommit summaryAuthorDate
r59530follow-up r59522, r59529. Just include the current variant.philip20:20, 28 November 2009
r59541follow-up r59522, r59523, r59527, r59529, r59530....philip06:47, 29 November 2009

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r59522bug 21672: Add Accept-Language to Vary and XVO headers to help Squid to deter...philip19:13, 28 November 2009

Comments

#Comment by PhiLiP (talk | contribs)   20:15, 28 November 2009

Here's some test example (python):

>>> def get(lang = ): conn = httplib.HTTPConnection('127.0.0.1', '1234') conn.request('GET', '/w/index.php', headers={'Accept-Language': lang}) res = conn.getresponse() print('Vary: ' + res.getheader('vary')) print('X-Vary-Options: ' + res.getheader('x-vary-options')) conn.close() >>> get('zh-cn') Vary: Accept-Encoding,Cookie,Accept-Language X-Vary-Options: Accept-Encoding;list-contains=gzip,Accept-Language;string-contains=zh-hans;string-contains=zh-hant;string-contains=zh-cn;string-contains=zh-hk;string-contains=zh-mo;string-contains=zh-my;string-contains=zh-sg;string-contains=zh-tw,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session >>> get('en') Vary: Accept-Encoding,Cookie X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session >>> get('zh') Vary: Accept-Encoding,Cookie X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session >>> get('zh-xxx') Vary: Accept-Encoding,Cookie X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session

#Comment by PhiLiP (talk | contribs)   20:17, 28 November 2009

Here's some test example:

>>> def get(lang = ''):
	conn = httplib.HTTPConnection('127.0.0.1', '1234')
	conn.request('GET', '/w/index.php', headers={'Accept-Language': lang})
	res = conn.getresponse()
	print('Vary: ' + res.getheader('vary'))
	print('X-Vary-Options: ' + res.getheader('x-vary-options'))
	conn.close()
>>> get('zh-cn')
Vary: Accept-Encoding,Cookie,Accept-Language
X-Vary-Options: Accept-Encoding;list-contains=gzip,Accept-Language;string-contains=zh-hans;string-contains=zh-hant;string-contains=zh-cn;string-contains=zh-hk;string-contains=zh-mo;string-contains=zh-my;string-contains=zh-sg;string-contains=zh-tw,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session
>>> get('en')
Vary: Accept-Encoding,Cookie
X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session
>>> get('zh')
Vary: Accept-Encoding,Cookie
X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session
>>> get('zh-xxx')
Vary: Accept-Encoding,Cookie
X-Vary-Options: Accept-Encoding;list-contains=gzip,Cookie;string-contains=wikidb_tw_Token;string-contains=wikidb_tw_LoggedOut;string-contains=wikidb_tw__session

Status & tagging log