Changeset 2081
- Timestamp:
- 11/08/08 17:30:21
- Files:
-
- branches/cherrypy-3.1.x/cherrypy/__init__.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/lib/safemime.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/test/test_conn.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/test/test_http.py (modified) (3 diffs)
- branches/cherrypy-3.1.x/cherrypy/test/test_logging.py (modified) (2 diffs)
- branches/cherrypy-3.1.x/cherrypy/test/test_objectmapping.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/test/test_refleaks.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/test/test_session.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/test/test_xmlrpc.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/test/webtest.py (modified) (1 diff)
- branches/cherrypy-3.1.x/cherrypy/wsgiserver/__init__.py (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/cherrypy-3.1.x/cherrypy/__init__.py
r2075 r2081 338 338 child = getattr(serving, self.__attrname__) 339 339 return len(child) 340 341 def __nonzero__(self): 342 child = getattr(serving, self.__attrname__) 343 return bool(child) 340 344 341 345 branches/cherrypy-3.1.x/cherrypy/lib/safemime.py
r1678 r2081 110 110 """Wrap request.rfile in a reader that won't crash on no trailing CRLF.""" 111 111 h = cherrypy.request.headers 112 if not h.get('Content-Type' ).startswith('multipart/'):112 if not h.get('Content-Type','').startswith('multipart/'): 113 113 return 114 114 if flash_only and not 'Shockwave Flash' in h.get('User-Agent', ''): branches/cherrypy-3.1.x/cherrypy/test/test_conn.py
r2002 r2081 172 172 # Make another request on the same connection, which should error. 173 173 self.assertRaises(httplib.NotConnected, self.getPage, "/") 174 175 # Try HEAD. See http://www.cherrypy.org/ticket/864. 176 self.getPage("/stream", method='HEAD') 177 self.assertStatus('200 OK') 178 self.assertBody('') 179 self.assertNoHeader("Transfer-Encoding") 174 180 else: 175 181 self.PROTOCOL = "HTTP/1.0" branches/cherrypy-3.1.x/cherrypy/test/test_http.py
r2074 r2081 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() branches/cherrypy-3.1.x/cherrypy/test/test_logging.py
r1984 r2081 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) branches/cherrypy-3.1.x/cherrypy/test/test_objectmapping.py
r2074 r2081 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 branches/cherrypy-3.1.x/cherrypy/test/test_refleaks.py
r2005 r2081 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) branches/cherrypy-3.1.x/cherrypy/test/test_session.py
r1922 r2081 194 194 def request(index): 195 195 if self.scheme == 'https': 196 c = httplib.HTTPSConnection(' 127.0.0.1:%s' % self.PORT)196 c = httplib.HTTPSConnection('%s:%s' % (self.interface(), self.PORT)) 197 197 else: 198 c = httplib.HTTPConnection(' 127.0.0.1:%s' % self.PORT)198 c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)) 199 199 for i in xrange(request_count): 200 200 c.putrequest('GET', '/') branches/cherrypy-3.1.x/cherrypy/test/test_xmlrpc.py
r2068 r2081 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 branches/cherrypy-3.1.x/cherrypy/test/webtest.py
r1901 r2081 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): branches/cherrypy-3.1.x/cherrypy/wsgiserver/__init__.py
r2075 r2081 653 653 pass 654 654 else: 655 if self.response_protocol == 'HTTP/1.1': 655 if (self.response_protocol == 'HTTP/1.1' 656 and self.environ["REQUEST_METHOD"] != 'HEAD'): 656 657 # Use the chunked transfer-coding 657 658 self.chunked_write = True … … 746 747 return self._sock.recv(size) 747 748 except socket.error, e: 748 if e.args[0] not in socket_errors_nonblocking: 749 if (e.args[0] not in socket_errors_nonblocking 750 and e.args[0] not in socket_error_eintr): 749 751 raise 750 752 … … 923 925 return self._sock.recv(size) 924 926 except socket.error, e: 925 if e.args[0] not in socket_errors_nonblocking: 927 if (e.args[0] not in socket_errors_nonblocking 928 and e.args[0] not in socket_error_eintr): 926 929 raise 927 930 … … 1616 1619 self.socket = SSLConnection(ctx, self.socket) 1617 1620 self.populate_ssl_environ() 1621 1622 # If listening on the IPV6 any address ('::' = IN6ADDR_ANY), 1623 # activate dual-stack. See http://www.cherrypy.org/ticket/871. 1624 if (not isinstance(self.bind_addr, basestring) 1625 and self.bind_addr[0] == '::' and family == socket.AF_INET6): 1626 try: 1627 self.socket.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 0) 1628 except (AttributeError, socket.error): 1629 # Apparently, the socket option is not available in 1630 # this machine's TCP stack 1631 pass 1632 1618 1633 self.socket.bind(self.bind_addr) 1619 1634

