Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 2081

Show
Ignore:
Timestamp:
11/08/08 17:30:21
Author:
fumanchu
Message:

Merge from trunk for today's fixes [2072] to [2080].

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-3.1.x/cherrypy/__init__.py

    r2075 r2081  
    338338        child = getattr(serving, self.__attrname__) 
    339339        return len(child) 
     340     
     341    def __nonzero__(self): 
     342        child = getattr(serving, self.__attrname__) 
     343        return bool(child) 
    340344 
    341345 
  • branches/cherrypy-3.1.x/cherrypy/lib/safemime.py

    r1678 r2081  
    110110    """Wrap request.rfile in a reader that won't crash on no trailing CRLF.""" 
    111111    h = cherrypy.request.headers 
    112     if not h.get('Content-Type').startswith('multipart/'): 
     112    if not h.get('Content-Type','').startswith('multipart/'): 
    113113        return 
    114114    if flash_only and not 'Shockwave Flash' in h.get('User-Agent', ''): 
  • branches/cherrypy-3.1.x/cherrypy/test/test_conn.py

    r2002 r2081  
    172172                    # Make another request on the same connection, which should error. 
    173173                    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") 
    174180        else: 
    175181            self.PROTOCOL = "HTTP/1.0" 
  • branches/cherrypy-3.1.x/cherrypy/test/test_http.py

    r2074 r2081  
    7171        # with 411 Length Required. 
    7272        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)
    7474        else: 
    75             c = httplib.HTTPConnection("127.0.0.1:%s" % self.PORT
     75            c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)
    7676        c.request("POST", "/") 
    7777        self.assertEqual(c.getresponse().status, 411) 
     
    8888        # post file 
    8989        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)
    9191        else: 
    92             c = httplib.HTTP('127.0.0.1:%s' % self.PORT
     92            c = httplib.HTTP('%s:%s' % (self.interface(), self.PORT)
    9393        c.putrequest('POST', '/post_multipart') 
    9494        c.putheader('Content-Type', content_type) 
     
    111111        # Test missing version in Request-Line 
    112112        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)
    114114        else: 
    115             c = httplib.HTTPConnection('127.0.0.1:%s' % self.PORT
     115            c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)
    116116        c._output('GET /') 
    117117        c._send_output() 
  • branches/cherrypy-3.1.x/cherrypy/test/test_logging.py

    r1984 r2081  
    8080        self.assertStatus(200) 
    8181         
    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() 
    9083         
    9184        self.assertLog(-1, intro) 
     
    10699        self.assertStatus(200) 
    107100         
    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() 
    116102         
    117103        self.assertLog(-1, intro) 
  • branches/cherrypy-3.1.x/cherrypy/test/test_objectmapping.py

    r2074 r2081  
    245245         
    246246        # 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)
    248248        self.assertBody('world') 
    249249         
  • branches/cherrypy-3.1.x/cherrypy/test/test_refleaks.py

    r2005 r2081  
    8989         
    9090        def getpage(): 
    91             host = '%s:%s' % (self.HOST, self.PORT) 
     91            host = '%s:%s' % (self.interface(), self.PORT) 
    9292            if self.scheme == 'https': 
    9393                c = httplib.HTTPSConnection(host) 
  • branches/cherrypy-3.1.x/cherrypy/test/test_session.py

    r1922 r2081  
    194194        def request(index): 
    195195            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)
    197197            else: 
    198                 c = httplib.HTTPConnection('127.0.0.1:%s' % self.PORT
     198                c = httplib.HTTPConnection('%s:%s' % (self.interface(), self.PORT)
    199199            for i in xrange(request_count): 
    200200                c.putrequest('GET', '/') 
  • branches/cherrypy-3.1.x/cherrypy/test/test_xmlrpc.py

    r2068 r2081  
    117117            pass 
    118118         
    119         host = self.HOST 
    120         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          
    127119        if scheme == "https": 
    128             url = 'https://%s:%s/xmlrpc/' % (host, self.PORT) 
     120            url = 'https://%s:%s/xmlrpc/' % (self.interface(), self.PORT) 
    129121            proxy = xmlrpclib.ServerProxy(url, transport=HTTPSTransport()) 
    130122        else: 
    131             url = 'http://%s:%s/xmlrpc/' % (host, self.PORT) 
     123            url = 'http://%s:%s/xmlrpc/' % (self.interface(), self.PORT) 
    132124            proxy = xmlrpclib.ServerProxy(url) 
    133125         
  • branches/cherrypy-3.1.x/cherrypy/test/webtest.py

    r1901 r2081  
    192192        self.set_persistent(on) 
    193193    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 
    194208     
    195209    def getPage(self, url, headers=None, method="GET", body=None, protocol=None): 
  • branches/cherrypy-3.1.x/cherrypy/wsgiserver/__init__.py

    r2075 r2081  
    653653                pass 
    654654            else: 
    655                 if self.response_protocol == 'HTTP/1.1': 
     655                if (self.response_protocol == 'HTTP/1.1' 
     656                    and self.environ["REQUEST_METHOD"] != 'HEAD'): 
    656657                    # Use the chunked transfer-coding 
    657658                    self.chunked_write = True 
     
    746747                    return self._sock.recv(size) 
    747748                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): 
    749751                        raise 
    750752 
     
    923925                    return self._sock.recv(size) 
    924926                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): 
    926929                        raise 
    927930 
     
    16161619            self.socket = SSLConnection(ctx, self.socket) 
    16171620            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         
    16181633        self.socket.bind(self.bind_addr) 
    16191634     

Hosted by WebFaction

Log in as guest/cpguest to create tickets