r111718 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111717‎ | r111718 | r111719 >
Date:02:10, 17 February 2012
Author:ben
Status:ok
Tags:
Comment:
correcting add header syntax, using a default user-agent if needed.
Modified paths:
  • /trunk/extensions/SwiftMedia/wmf/rewrite.py (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftMedia/wmf/rewrite.py
@@ -104,6 +104,7 @@
105105 self.key = conf['key'].strip()
106106 self.thumbhost = conf['thumbhost'].strip()
107107 self.writethumb = 'writethumb' in conf
 108+ self.user_agent = conf['user_agent'].strip()
108109 self.bind_port = conf['bind_port'].strip()
109110 self.shard_containers = conf['shard_containers'].strip() #all, some, none
110111 if (self.shard_containers == 'some'):
@@ -127,9 +128,14 @@
128129 # using urllib2.url()
129130 opener = urllib2.build_opener()
130131 # Pass on certain headers from the caller squid to the scalers
131 - for header_to_pass in ['X-Forwarded-For', 'X-Original-URI', 'User-Agent']:
 132+ opener.addheaders = []
 133+ if reqorig.headers.get('User-Agent') != None:
 134+ opener.addheaders.append(('User-Agent', reqorig.headers.get('User-Agent')))
 135+ else:
 136+ opener.addheaders.append(('User-Agent', self.user_agent))
 137+ for header_to_pass in ['X-Forwarded-For', 'X-Original-URI']:
132138 if reqorig.headers.get( header_to_pass ) != None:
133 - opener.addheaders[header_to_pass] = reqorig.headers.get( header_to_pass )
 139+ opener.addheaders.append((header_to_pass, reqorig.headers.get( header_to_pass )))
134140 # At least in theory, we shouldn't be handing out links to originals
135141 # that we don't have (or in the case of thumbs, can't generate).
136142 # However, someone may have a formerly valid link to a file, so we

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r111477Pass in agent, XFF, and origin headers to scalersaaron20:17, 14 February 2012

Status & tagging log