Ticket #387 (closed defect: fixed)
Webtest doesn't parse quoted cookies
| Reported by: | mgood | Owned by: | ianb |
|---|---|---|---|
| Priority: | normal | Milestone: | 1.4.1 |
| Component: | paste | Version: | svn-trunk |
| Severity: | normal | Keywords: | |
| Cc: |
Description
Included test case & fix:
-
(a) /dev/null vs. (b) b/tests/test_cookies.py
diff --git a/tests/test_cookies.py b/tests/test_cookies.py new file mode 100644 index 0000000..8611a2a
a b 1 import webtest 2 from nose.tools import eq_ 3 4 5 def cookie_app(environ, start_response): 6 status = '200 OK' 7 body = '' 8 headers = [ 9 ('Content-Type', 'text/html'), 10 ('Content-Length', str(len(body))), 11 ('Set-Cookie', 'spam=eggs'), 12 ('Set-Cookie', 'foo="bar;baz"'), 13 ] 14 start_response(status, headers) 15 return [body] 16 17 18 def test_cookies(): 19 app = webtest.TestApp(cookie_app) 20 assert not app.cookies, 'App should initially contain no cookies' 21 22 res = app.get('/') 23 assert app.cookies, 'Response should have set cookies' 24 eq_(app.cookies['spam'], 'eggs') 25 eq_(app.cookies['foo'], 'bar;baz') -
webtest/__init__.py
diff --git a/webtest/__init__.py b/webtest/__init__.py index 1e5682a..ec2beee 100644
a b 14 14 import time 15 15 import cgi 16 16 import os 17 from Cookie import BaseCookie, CookieError17 from Cookie import SimpleCookie, CookieError 18 18 from Cookie import _quote as cookie_quote 19 19 try: 20 20 from cStringIO import StringIO … … 374 374 res.cookies_set = {} 375 375 for header in res.headers.getall('set-cookie'): 376 376 try: 377 c = BaseCookie(header)377 c = SimpleCookie(header) 378 378 except CookieError, e: 379 379 raise CookieError( 380 380 "Could not parse cookie header %r: %s" % (header, e))
Change History
Note: See
TracTickets for help on using
tickets.
