Better headers for outgoing proxy request.
authorMark Cote <mcote@mozilla.com>
Tue, 05 Jul 2011 18:21:22 -0400
changeset 56 ebe872edfd5ce4b2a1db1d348f017041b6464710
parent 55 2cc1f4ae2208b8ea0f4103bc87f7c5ad5c6412a7
child 57 1d76fcb57b35e1c95a30b03028ce95268b7b2732
push id54
push usermcote@mozilla.com
push dateTue, 05 Jul 2011 22:21:30 +0000
Better headers for outgoing proxy request.
server/speedtests_server.py
--- a/server/speedtests_server.py
+++ b/server/speedtests_server.py
@@ -131,17 +131,23 @@ def get_browser_id(ua):
         browser = db.select('browser', where=web.db.sqlwhere(wheredict))
     return browser[0].id
         
 
 class TestResults(object):
     
     def POST(self):
         if PROXY_TO:
-            urllib2.urlopen(PROXY_TO, web.data())
+            headers = {
+                'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
+                'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
+                'Accept-Encoding': 'gzip, deflate'
+            }
+            request = urllib2.Request(PROXY_TO, web.data(), headers)
+            response = urllib2.urlopen(request, timeout=120).read()
             return
         web_data = json.loads(web.data())
         machine_ip = web_data['ip']
         testname = web_data['testname']
         browser_id = get_browser_id(web_data['ua'])
         for results in web_data['results']:
             results['browser_id'] = browser_id
     	    results['ip'] = machine_ip