Skip to content

Commit

Permalink
Multiple cookies can have the same name
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Genoud committed Feb 14, 2019
1 parent 4bdffd1 commit 50e3867
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
11 changes: 7 additions & 4 deletions tests/test_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from werkzeug.wsgi import LimitedStream, wrap_file
from werkzeug.datastructures import (
MultiDict, ImmutableOrderedMultiDict,
ImmutableList, ImmutableTypeConversionDict, CharsetAccept,
ImmutableList, ImmutableMultiDict, CharsetAccept,
MIMEAccept, LanguageAccept, Accept, CombinedMultiDict, Headers,
)
from werkzeug.test import Client, create_environ, run_wsgi_app
Expand Down Expand Up @@ -1071,10 +1071,13 @@ class MyRequest(wrappers.Request):
assert req.values['foo'] == u'baz'

req = wrappers.Request.from_values(headers={
'Cookie': 'foo=bar'
'Cookie': 'foo=bar;foo=baz'
})
assert type(req.cookies) is ImmutableTypeConversionDict
assert req.cookies == {'foo': 'bar'}
assert type(req.cookies) is ImmutableMultiDict
assert req.cookies.to_dict() == {'foo': 'bar'}

# it is possible to have multiple cookies with the same name
assert req.cookies.getlist('foo') == ['bar', 'baz']
assert type(req.access_route) is ImmutableList

MyRequest.list_storage_class = tuple
Expand Down
5 changes: 2 additions & 3 deletions werkzeug/wrappers/base_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from ..datastructures import EnvironHeaders
from ..datastructures import ImmutableList
from ..datastructures import ImmutableMultiDict
from ..datastructures import ImmutableTypeConversionDict
from ..datastructures import iter_multi_items
from ..datastructures import MultiDict
from ..formparser import default_stream_factory
Expand Down Expand Up @@ -119,11 +118,11 @@ class Request(BaseRequest, ETagRequestMixin):

#: the type to be used for dict values from the incoming WSGI environment.
#: By default an
#: :class:`~werkzeug.datastructures.ImmutableTypeConversionDict` is used
#: :class:`~werkzeug.datastructures.ImmutableMultiDict` is used
#: (for example for :attr:`cookies`).
#:
#: .. versionadded:: 0.6
dict_storage_class = ImmutableTypeConversionDict
dict_storage_class = ImmutableMultiDict

#: The form data parser that shoud be used. Can be replaced to customize
#: the form date parsing.
Expand Down

0 comments on commit 50e3867

Please sign in to comment.