Changeset 2076
- Timestamp:
- 11/08/08 15:51:34
- Files:
-
- trunk/cherrypy/test/test_http.py (modified) (3 diffs)
- trunk/cherrypy/test/test_logging.py (modified) (2 diffs)
- trunk/cherrypy/test/test_objectmapping.py (modified) (1 diff)
- trunk/cherrypy/test/test_refleaks.py (modified) (1 diff)
- trunk/cherrypy/test/test_session.py (modified) (1 diff)
- trunk/cherrypy/test/test_xmlrpc.py (modified) (1 diff)
- trunk/cherrypy/test/webtest.py (modified) (1 diff)
- trunk/cherrypy/wsgiserver/__init__.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/test/test_http.py
r2072 r2076 71 71 # with 411 Length Required. 72 72 if self.scheme == "https": 73 c = httplib.HTTPSConnection( "127.0.0.1:%s" % self.PORT)73 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 74 74 else: 75 c = httplib.HTTPConnection( "127.0.0.1:%s" % self.PORT)75 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 76 76 c.request("POST", "/") 77 77 self.assertEqual(c.getresponse().status, 411) … … 88 88 # post file 89 89 if self.scheme == 'https': 90 c = httplib.HTTPS(' 127.0.0.1:%s' % self.PORT)90 c = httplib.HTTPS('%s:%s' % (self.interface(), self.PORT)) 91 91 else: 92 c = httplib.HTTP(' 127.0.0.1:%s' % self.PORT)92 c = httplib.HTTP('%s:%s' % (self.interface(), self.PORT)) 93 93 c.putrequest('POST', '/post_multipart') 94 94 c.putheader('Content-Type', content_type) … … 111 111 # Test missing version in Request-Line 112 112 if self.scheme == 'https': 113 c = httplib.HTTPSConnection(' 127.0.0.1:%s' % self.PORT)113 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 114 114 else: 115 c = httplib.HTTPConnection(' 127.0.0.1:%s' % self.PORT)115 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 116 116 c._output('GET /') 117 117 c._send_output() trunk/cherrypy/test/test_logging.py
r1984 r2076 80 80 self.assertStatus(200) 81 81 82 host = self.HOST 83 if host == '0.0.0.0': 84 # INADDR_ANY, which should respond on localhost. 85 host = "127.0.0.1" 86 if host == '::': 87 # IN6ADDR_ANY, which should respond on localhost. 88 host = "::1" 89 intro = '%s - - [' % host 82 intro = '%s - - [' % self.interface() 90 83 91 84 self.assertLog(-1, intro) … … 106 99 self.assertStatus(200) 107 100 108 host = self.HOST 109 if host == '0.0.0.0': 110 # INADDR_ANY, which should respond on localhost. 111 host = "127.0.0.1" 112 if host == '::': 113 # IN6ADDR_ANY, which should respond on localhost. 114 host = "::1" 115 intro = '%s - - [' % host 101 intro = '%s - - [' % self.interface() 116 102 117 103 self.assertLog(-1, intro) trunk/cherrypy/test/test_objectmapping.py
r2072 r2076 245 245 246 246 # Test absoluteURI's in the Request-Line 247 self.getPage('http:// 127.0.0.1/')247 self.getPage('http://%s:%s/' % (self.interface(), self.PORT)) 248 248 self.assertBody('world') 249 249 trunk/cherrypy/test/test_refleaks.py
r2005 r2076 89 89 90 90 def getpage(): 91 host = '%s:%s' % (self. HOST, self.PORT)91 host = '%s:%s' % (self.interface(), self.PORT) 92 92 if self.scheme == 'https': 93 93 c = httplib.HTTPSConnection(host) trunk/cherrypy/test/test_session.py
r2062 r2076 208 208 def request(index): 209 209 if self.scheme == 'https': 210 c = httplib.HTTPSConnection(' 127.0.0.1:%s' % self.PORT)210 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 211 211 else: 212 c = httplib.HTTPConnection(' 127.0.0.1:%s' % self.PORT)212 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 213 213 for i in xrange(request_count): 214 214 c.putrequest('GET', '/') trunk/cherrypy/test/test_xmlrpc.py
r2015 r2076 117 117 pass 118 118 119 host = self.HOST120 if host == '0.0.0.0':121 # INADDR_ANY, which should respond on localhost.122 host = "127.0.0.1"123 if host == '::':124 # IN6ADDR_ANY, which should respond on localhost.125 host = "::1"126 127 119 if scheme == "https": 128 url = 'https://%s:%s/xmlrpc/' % ( host, self.PORT)120 url = 'https://%s:%s/xmlrpc/' % (self.interface(), self.PORT) 129 121 proxy = xmlrpclib.ServerProxy(url, transport=HTTPSTransport()) 130 122 else: 131 url = 'http://%s:%s/xmlrpc/' % ( host, self.PORT)123 url = 'http://%s:%s/xmlrpc/' % (self.interface(), self.PORT) 132 124 proxy = xmlrpclib.ServerProxy(url) 133 125 trunk/cherrypy/test/webtest.py
r2063 r2076 192 192 self.set_persistent(on) 193 193 persistent = property(_get_persistent, _set_persistent) 194 195 def interface(self): 196 """Return an IP address for a client connection. 197 198 If the server is listening on '0.0.0.0' (INADDR_ANY) 199 or '::' (IN6ADDR_ANY), this will return the proper localhost.""" 200 host = self.HOST 201 if host == '0.0.0.0': 202 # INADDR_ANY, which should respond on localhost. 203 return "127.0.0.1" 204 if host == '::': 205 # IN6ADDR_ANY, which should respond on localhost. 206 return "::1" 207 return host 194 208 195 209 def getPage(self, url, headers=None, method="GET", body=None, protocol=None): trunk/cherrypy/wsgiserver/__init__.py
r2069 r2076 1616 1616 self.socket = SSLConnection(ctx, self.socket) 1617 1617 self.populate_ssl_environ() 1618 1619 # If listening on the IPV6 any address ('::' = IN6ADDR_ANY), 1620 # activate dual-stack. See http://www.cherrypy.org/ticket/871. 1621 if (not isinstance(self.bind_addr, basestring) 1622 and self.bind_addr[0] == '::' and family == socket.AF_INET6): 1623 try: 1624 self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) 1625 except (AttributeError, socket.error): 1626 # Apparently, the socket option is not available in 1627 # this machine's TCP stack 1628 pass 1629 1618 1630 self.socket.bind(self.bind_addr) 1619 1631

