Commits

Robert Brewer committed e8d8120

Fix for #952 (on multiple proxies getting multiple base urls) for 3.0, 3.1, 3.2 (trunk and python3).

  • Participants
  • Parent commits d505ca5
  • Branches cherrypy-3.0.x

Comments (0)

Files changed (2)

File cherrypy/lib/cptools.py

         scheme = request.base[:request.base.find("://")]
     
     if local:
-        base = request.headers.get(local, base)
+        lbase = request.headers.get(local, None)
+        if lbase is not None:
+            base = lbase.split(',')[0]
     if not base:
         port = cherrypy.request.local.port
         if port == 80:

File cherrypy/test/test_proxy.py

         self.assertHeader('Location', "http://www.yetanother.com/dummy")
         self.getPage("/", headers=[('X-Forwarded-Host', 'www.yetanother.com')])
         self.assertHeader('Location', "%s://www.yetanother.com/dummy" % self.scheme)
+        # Test multiple X-Forwarded-Host headers
+        self.getPage("/", headers=[
+            ('X-Forwarded-Host', 'http://www.example.test, www.cherrypy.test'),
+            ])
+        self.assertHeader('Location', "http://www.example.test/dummy")
         
         # Test X-Forwarded-For (Apache2)
         self.getPage("/remoteip",