r111477 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r111476‎ | r111477 | r111478 >
Date:20:17, 14 February 2012
Author:aaron
Status:ok
Tags:
Comment:
Pass in agent, XFF, and origin headers to scalers
Modified paths:
  • /trunk/extensions/SwiftMedia/wmf/rewrite.py (modified) (history)

Diff [purge]

Index: trunk/extensions/SwiftMedia/wmf/rewrite.py
@@ -98,7 +98,6 @@
9999 self.key = conf['key'].strip()
100100 self.thumbhost = conf['thumbhost'].strip()
101101 self.writethumb = 'writethumb' in conf
102 - self.user_agent = conf['user_agent'].strip()
103102 self.bind_port = conf['bind_port'].strip()
104103 self.shard_containers = conf['shard_containers'].strip() #all, some, none
105104 if (self.shard_containers == 'some'):
@@ -121,7 +120,10 @@
122121 # upload doesn't like our User-agent, otherwise we could call it
123122 # using urllib2.url()
124123 opener = urllib2.build_opener()
125 - opener.addheaders = [('User-agent', self.user_agent)]
 124+ # Pass on certain headers from the caller squid to the scalers
 125+ for header_to_pass in ['X-Forwarded-For', 'X-Original-URI', 'User-Agent']:
 126+ if reqorig.headers.get( header_to_pass ) != None:
 127+ opener.addheaders[header_to_pass] = reqorig.headers.get( header_to_pass )
126128 # At least in theory, we shouldn't be handing out links to originals
127129 # that we don't have (or in the case of thumbs, can't generate).
128130 # However, someone may have a formerly valid link to a file, so we

Follow-up revisions

RevisionCommit summaryAuthorDate
r111718correcting add header syntax, using a default user-agent if needed.ben02:10, 17 February 2012

Status & tagging log