Commits

Anonymous committed 608e9e4

When pypi switched to https it broke the transfer_file function because it was causing 301 responses, which didn't match the 204 expected. I added a new variable SECURE_MIRROR which when set attempts to connect to the mirror over HTTPS instead of HTTP which solves the 301 issue.

  • Participants
  • Parent commits 76af364

Comments (0)

Files changed (1)

 # where should we mirror files from?
 filesrc = 'pypi.python.org'
 #filesrc = 'localhost:8000'
+# if you need to connect to a mirror over SSL set to True
+# for pypi.python.org this needs to be True
+SECURE_MIRROR = True
 
 def rpc():
     return xmlrpclib.ServerProxy('http://pypi.python.org/pypi')
     host = os.environ['SERVER_NAME']
     if os.environ['SERVER_PORT'] != '80':
         host += ':'+os.environ['SERVER_PORT']
-    h = httplib.HTTPConnection(filesrc)
+    if SECURE_MIRROR:
+        h = httplib.HTTPSConnection(filesrc)
+    else:
+        h = httplib.HTTPConnection(filesrc)
     h.putrequest('GET', '/pypi?:action=gae_file&host=%s&secret=%s' %
                  (host, m.upload_key))
     h.endheaders()