Changeset 1233
- Timestamp:
- 08/11/06 11:55:20
- Files:
-
- trunk/cherrypy/lib/cptools.py (modified) (2 diffs)
- trunk/cherrypy/lib/encoding.py (modified) (1 diff)
- trunk/cherrypy/test/test_proxy.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/lib/cptools.py
r1232 r1233 71 71 to '', so that the X-Forwarded-Host request header (which never includes 72 72 path info) does not override it. 73 74 cherrypy.request.remote.ip (the IP address of the client) will be 75 rewritten if the header specified by the 'remote' arg is valid. 76 By default, 'remote' is set to 'X-Forwarded-For'. If you do not 77 want to rewrite remote.ip, set the 'remote' arg to an empty string. 73 78 """ 74 79 … … 97 102 # See http://bob.pythonmac.org/archives/2005/09/23/apache-x-forwarded-for-caveat/ 98 103 xff = xff.split(',')[-1].strip() 99 request.remote. name= xff104 request.remote.ip = xff 100 105 101 106 trunk/cherrypy/lib/encoding.py
r1163 r1233 6 6 7 7 def decode(encoding=None, default_encoding='utf-8'): 8 """Decode cherrypy.request.params ."""8 """Decode cherrypy.request.params.""" 9 9 if not encoding: 10 10 ct = cherrypy.request.headers.elements("Content-Type") trunk/cherrypy/test/test_proxy.py
r1225 r1233 11 11 index.exposed = True 12 12 13 def remote host(self):14 return cherrypy.request.remote. name15 remote host.exposed = True13 def remoteip(self): 14 return cherrypy.request.remote.ip 15 remoteip.exposed = True 16 16 17 17 def xhost(self): … … 45 45 46 46 # Test X-Forwarded-For (Apache2) 47 self.getPage("/remote host",47 self.getPage("/remoteip", 48 48 headers=[('X-Forwarded-For', '192.168.0.20')]) 49 49 self.assertBody("192.168.0.20") 50 self.getPage("/remote host",50 self.getPage("/remoteip", 51 51 headers=[('X-Forwarded-For', '67.15.36.43, 192.168.0.20')]) 52 52 self.assertBody("192.168.0.20")

