Changeset 1657
- Timestamp:
- 05/30/07 18:54:09
- Files:
-
- trunk/cherrypy/__init__.py (modified) (1 diff)
- trunk/cherrypy/_cpdispatch.py (modified) (3 diffs)
- trunk/cherrypy/_cperror.py (modified) (2 diffs)
- trunk/cherrypy/_cptree.py (modified) (2 diffs)
- trunk/cherrypy/test/test_misc_tools.py (modified) (3 diffs)
- trunk/cherrypy/test/test_proxy.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/__init__.py
r1656 r1657 213 213 This should start with a slash, and be the path portion of the URL 214 214 at which to mount the given root. For example, if root.index() will 215 handle requests to "http:// host.domain.tld:8080/dept/app1/", then215 handle requests to "http://www.example.com:8080/dept/app1/", then 216 216 the script_name argument would be "/dept/app1". 217 217 config: a file or dict containing application config. If this contains trunk/cherrypy/_cpdispatch.py
r1656 r1657 351 351 website structure. For example: 352 352 353 http://www. mydom1.com-> root354 http://www. mydom2.com -> root/mydom2/355 http://www. mydom2.com:443 -> root/secure353 http://www.domain.example -> root 354 http://www.domain2.example -> root/domain2/ 355 http://www.domain2.example:443 -> root/secure 356 356 357 357 can be accomplished via the following config: … … 359 359 [/] 360 360 request.dispatch = cherrypy.dispatch.VirtualHost( 361 **{'www. mydom2.com': '/mydom2',362 'www. mydom2.com:443': '/secure',361 **{'www.domain2.example': '/domain2', 362 'www.domain2.example:443': '/secure', 363 363 }) 364 364 … … 376 376 value will be prepended to the URL path before calling the 377 377 next dispatcher. Note that you often need separate entries 378 for " mysite.com" and "www.mysite.com". In addition, "Host"378 for "example.com" and "www.example.com". In addition, "Host" 379 379 headers may contain the port number. 380 380 """ trunk/cherrypy/_cperror.py
r1617 r1657 57 57 for url in urls: 58 58 # Note that urljoin will "do the right thing" whether url is: 59 # 1. a complete URL with host (e.g. "http://www. dummy.biz/test")59 # 1. a complete URL with host (e.g. "http://www.example.com/test") 60 60 # 2. a URL relative to root (e.g. "/dummy") 61 61 # 3. a URL relative to the current path … … 215 215 216 216 217 _HTTPErrorTemplate = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 217 _HTTPErrorTemplate = '''<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 218 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 218 219 <html> 219 220 <head> trunk/cherrypy/_cptree.py
r1656 r1657 57 57 script_name__doc = """ 58 58 The URI "mount point" for this app; for example, if script_name is 59 "/my/cool/app", then the URL "http:// my.domain.tld/my/cool/app/page1"59 "/my/cool/app", then the URL "http://www.example.com/my/cool/app/page1" 60 60 might be handled by a "page1" method on the root object. If script_name 61 61 is explicitly set to None, then the script_name will be provided … … 136 136 This should start with a slash, and be the path portion of the 137 137 URL at which to mount the given root. For example, if root.index() 138 will handle requests to "http:// host.domain.tld:8080/dept/app1/",138 will handle requests to "http://www.example.com:8080/dept/app1/", 139 139 then the script_name argument would be "/dept/app1". 140 140 config: a file or dict containing application config. trunk/cherrypy/test/test_misc_tools.py
r1422 r1657 57 57 58 58 conf = {'/referer': {'tools.referer.on': True, 59 'tools.referer.pattern': r'http://[^/]* thisdomain\.com',59 'tools.referer.pattern': r'http://[^/]*example\.com', 60 60 }, 61 61 '/referer/reject': {'tools.referer.accept': False, … … 93 93 94 94 self.getPage('/referer/accept', 95 headers=[('Referer', 'http://www. thisdomain.com/')])95 headers=[('Referer', 'http://www.example.com/')]) 96 96 self.assertStatus(200) 97 97 self.assertBody('Accepted!') … … 103 103 104 104 self.getPage('/referer/reject', 105 headers=[('Referer', 'http://www. thisdomain.com/')])105 headers=[('Referer', 'http://www.example.com/')]) 106 106 self.assertErrorPage(403, 'Forbidden Referer header.') 107 107 trunk/cherrypy/test/test_proxy.py
r1528 r1657 53 53 54 54 # Test X-Forwarded-Host (Apache 1.3.33+ and Apache 2) 55 self.getPage("/", headers=[('X-Forwarded-Host', 'http://www. yetanother.com')])56 self.assertHeader('Location', "http://www. yetanother.com/dummy")57 self.getPage("/", headers=[('X-Forwarded-Host', 'www. yetanother.com')])58 self.assertHeader('Location', "%s://www. yetanother.com/dummy" % self.scheme)55 self.getPage("/", headers=[('X-Forwarded-Host', 'http://www.example.com')]) 56 self.assertHeader('Location', "http://www.example.com/dummy") 57 self.getPage("/", headers=[('X-Forwarded-Host', 'www.example.com')]) 58 self.assertHeader('Location', "%s://www.example.com/dummy" % self.scheme) 59 59 60 60 # Test X-Forwarded-For (Apache2) … … 67 67 68 68 # Test X-Host (lighttpd; see https://trac.lighttpd.net/trac/ticket/418) 69 self.getPage("/xhost", headers=[('X-Host', 'www. yetanother.com')])70 self.assertHeader('Location', "%s://www. yetanother.com/blah" % self.scheme)69 self.getPage("/xhost", headers=[('X-Host', 'www.example.com')]) 70 self.assertHeader('Location', "%s://www.example.com/blah" % self.scheme) 71 71 72 72 # Test X-Forwarded-Proto (lighttpd) … … 81 81 + sn + "/this/new/page'>this page</a>.") 82 82 self.getPage(sn + "/newurl", headers=[('X-Forwarded-Host', 83 'http://www. yetanother.com')])84 self.assertBody("Browse to <a href='http://www. yetanother.com"83 'http://www.example.com')]) 84 self.assertBody("Browse to <a href='http://www.example.com" 85 85 + sn + "/this/new/page'>this page</a>.") 86 86 … … 100 100 101 101 # Test trailing slash (see http://www.cherrypy.org/ticket/562). 102 self.getPage("/xhost/", headers=[('X-Host', 'www. yetanother.com')])103 self.assertHeader('Location', "%s://www. yetanother.com/xhost"102 self.getPage("/xhost/", headers=[('X-Host', 'www.example.com')]) 103 self.assertHeader('Location', "%s://www.example.com/xhost" 104 104 % self.scheme) 105 105

