Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow Headers.add to get a list of parameters on *args #1100

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion werkzeug/datastructures.py
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ def __iter__(self):
def __len__(self):
return len(self._list)

def add(self, _key, _value, **kw):
def add(self, _key, _value, *args, **kw):

This comment was marked as off-topic.

"""Add a new header tuple to the list.

Keyword arguments can specify additional parameters for the header
Expand All @@ -1153,9 +1153,15 @@ def add(self, _key, _value, **kw):
The keyword argument dumping uses :func:`dump_options_header`
behind the scenes.

In some cases, it would be needed to ensure the order of parameters.

This comment was marked as off-topic.

For those cases, a list of ``(key, value)`` tuples can be passed in
*args.

This comment was marked as off-topic.


.. versionadded:: 0.4.1
keyword arguments were added for :mod:`wsgiref` compatibility.
"""
if args:
_value = dump_options_header(_value, args)

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

This comment was marked as off-topic.

if kw:
_value = _options_header_vkw(_value, kw)
_value = _unicodify_header_value(_value)
Expand Down
6 changes: 5 additions & 1 deletion werkzeug/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,11 @@ def dump_options_header(header, options):
segments = []
if header is not None:
segments.append(header)
for key, value in iteritems(options):
if isinstance(options, tuple):
iter_func = iter
else:
iter_func = iteritems

This comment was marked as off-topic.

for key, value in iter_func(options):
if value is None:
segments.append(key)
else:
Expand Down