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

Changeset 2019

Show
Ignore:
Timestamp:
07/09/08 15:20:48
Author:
nick125
Message:

Added a unit test, fixed an issue in the core unittest with ipv6-enabled systems and fixed an issue in parseRequestLine() when URL paths contained spaces (or anything that would split on a space)

* Added a encoded URL unittest to test/test_core.py
* Fixed lib/httptools.py's parseRequestLine() to not barf when the request line did not unpack to three values (i.e., if the path contained spaces)
* Fixed the logging test in test_core.py to fix an issue where the logger would log ipv6 addresses.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/lib/httptools.py

    r1571 r2019  
    318318def parseRequestLine(requestLine): 
    319319    """Return (method, path, querystring, protocol) from a requestLine.""" 
    320     method, path, protocol = requestLine.split() 
    321      
     320    splitLine = requestLine.split() 
     321    method, protocol = splitLine[0], splitLine[-1] 
     322    path = " ".join(splitLine[1:-1]) 
     323 
    322324    # path may be an abs_path (including "http://host.domain.tld"); 
    323325    # Ignore scheme, location, and fragments (so config lookups work). 
  • branches/cherrypy-2.x/cherrypy/test/test_core.py

    r1855 r2019  
    328328    cherrypy.root.divorce = Divorce() 
    329329 
     330    class Encoded: 
     331        def default(self, *args): 
     332            return "Encoded response" 
     333        default.exposed = True 
     334 
     335    cherrypy.root.encoded = Encoded() 
    330336 
    331337    class Cookies(Test): 
     
    464470         
    465471        data = open(log_access_file, "rb").readlines() 
    466         self.assertEqual(data[0][:15], '127.0.0.1 - - [') 
     472        address = data[0].split()[0] 
     473        if address not in ['127.0.0.1', '::ffff:127.0.0.1', '::1']: 
     474            self.fail('access log did not contain remote IP:\n%s' % (data[0])) 
     475           
    467476        haslength = False 
    468477        for k, v in self.headers: 
     
    476485                                          % self.prefix())) 
    477486         
    478         self.assertEqual(data[1][:15], '127.0.0.1 - - [') 
     487        address = data[1].split()[0] 
     488        if address not in ['127.0.0.1', '::ffff:127.0.0.1', '::1']: 
     489            self.fail('access log did not contain remote IP:\n%s' % (data[0])) 
     490 
    479491        haslength = False 
    480492        for k, v in self.headers: 
     
    933945        self.assertEqual(results, ["None"] * 20) 
    934946     
     947    def testEncodedURL(self): 
     948        self.getPage('/encoded/%0Ax') 
     949        self.assertBody("Encoded response") 
     950 
    935951    def testDefaultContentType(self): 
    936952        self.getPage('/') 

Hosted by WebFaction

Log in as guest/cpguest to create tickets