Changeset 561
- Timestamp:
- 08/27/05 12:32:59
- Files:
-
- trunk/cherrypy/_cphttptools.py (modified) (2 diffs)
- trunk/cherrypy/test/test_core.py (modified) (5 diffs)
- trunk/cherrypy/test/test_objectmapping.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/cherrypy/_cphttptools.py
r559 r561 258 258 path, req.queryString = path, "" 259 259 260 # See http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 260 # Unquote the path (e.g. "/this%20path" -> "this path"). 261 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 262 # Note that cgi.parse_qs will decode the querystring for us. 263 path = urllib.unquote(path) 264 261 265 if path == "*": 266 # "...the request does not apply to a particular resource, 267 # but to the server itself". See 268 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html#sec5.1.2 262 269 path = "global" 263 270 elif not path.startswith("/"): … … 851 858 # Remove leading and trailing slash 852 859 tpath = path.strip("/") 853 # Replace quoted chars (eg %20) from url854 tpath = urllib.unquote(tpath)855 860 856 861 if not tpath: trunk/cherrypy/test/test_core.py
r558 r561 67 67 def ismap(self, x, y): 68 68 return "Coordinates: %s, %s" % (x, y) 69 70 def default(self, *args, **kwargs): 71 return "args: %s kwargs: %s" % (args, kwargs) 69 72 70 73 … … 267 270 'server.logAccessFile': logAccessFile, 268 271 }, 272 '/params': { 273 'server.logFile': logFile, 274 }, 269 275 }) 270 276 … … 311 317 ignore.pop() 312 318 319 # Test "% HEX HEX"-encoded URL, param keys, and values 320 self.getPage("/params/%e3/cheese?Gruy%E8re=Bulgn%e9ville") 321 self.assertBody(r"args: ('\xe3', 'cheese') " 322 r"kwargs: {'Gruy\xe8re': 'Bulgn\xe9ville'}") 323 324 # Make sure that encoded = and & get parsed correctly 325 self.getPage("/params/code?url=http%3A//cherrypy.org/index%3Fa%3D1%26b%3D2") 326 self.assertBody(r"args: ('code',) " 327 r"kwargs: {'url': 'http://cherrypy.org/index?a=1&b=2'}") 328 313 329 # Test coordinates sent by <img ismap> 314 330 self.getPage("/params/ismap?223,114") … … 347 363 self.assertBody('content') 348 364 self.assertStatus('200 OK') 349 350 data = open(logFile, "rb").readlines()351 self.assertEqual(data[0][-55:], ' HTTP INFO 127.0.0.1 - GET /flatten/as_string HTTP/1.1\n')352 self.assertEqual(data[1][-54:], ' HTTP INFO 127.0.0.1 - GET /flatten/as_yield HTTP/1.1\n')353 365 354 366 data = open(logAccessFile, "rb").readlines() … … 372 384 else: 373 385 self.assertEqual(data[1][-41:], '] "GET /flatten/as_yield HTTP/1.1" 200 -\n') 386 387 data = open(logFile, "rb").readlines() 388 self.assertEqual(data, []) 389 390 # Test that error log gets access messages if no logAccess defined. 391 self.getPage("/params/?thing=a") 392 self.assertBody("'a'") 393 data = open(logFile, "rb").readlines() 394 self.assertEqual(data[0][-53:], ' HTTP INFO 127.0.0.1 - GET /params/?thing=a HTTP/1.1\n') 374 395 375 396 def testRedirect(self): trunk/cherrypy/test/test_objectmapping.py
r552 r561 144 144 145 145 # Test that we can use URL's which aren't all valid Python identifiers 146 self.getPage("/Von%20B\xfclow?ID=14") 146 # This should also test the %XX-unquoting of URL's. 147 self.getPage("/Von%20B%fclow?ID=14") 147 148 self.assertBody("ID is 14") 148 149

