Pylons / pyramid

Pyramid - A Python web framework
https://trypyramid.com/
Other
3.97k stars 887 forks source link

Allow multiple values for `header` predicate #3575

Closed merwok closed 4 years ago

merwok commented 4 years ago

Feature Request

Is your feature request related to an issue? Please describe. We can use predicates like header="X-GitHub-Whatever" or header="X-Facebook-Thing:cool-value" within a route or view config. However, it is not possible to specify more than one header, so one would need to write a custom predicate here, or perform checks inside the view.

Describe the solution you'd like header should accept a string or tuple of strings, like request_param does.

Describe alternatives you've considered New parameter headers always taking a sequence—would not fit with existing behaviour for request_param and others.

Additional context Implementation should be easy in pyramid.predicates.HeaderPredicate. Tuples were not accepted before, so no compatibility issue.

mmerickel commented 4 years ago

In general the official predicates are always an "and" operation, but if that's what you're proposing then I see no issue with accepting a PR that added that to the predicate.

merwok commented 4 years ago

Yes, the request was to have all headers matching, like other built-in predicates. PR incoming