Multiple HTTP Request Headers with same Key
See original GitHub issueProblem Some services in our cluster sometimes receive multiple headers with same key, for example 2 Accept-Language headers with different values. Tracetest currently sends the header-key once, with the header-value of the last applied Header in Headers List. We want to test our handling of Field Order rules: https://httpwg.org/specs/rfc7230.html#rfc.section.3.2.2
Solution We would like a way to test how our services handle this type of request by:
- Allowing sending of multiple headers with same key.
- Allowing assertions on the count or entry of headers, in case there are multiple headers.
Considerations
Here are some considerations of how to specify assertions on count/entries:
# assert on count of specific header-key
assertions:
- count(http.request.header.accept_language) = 2
- http.request.header.accept_language.count = 2
# assert on first/last header matching key - fails assertion when no header matches key, or entry of nth_child doesn't exist
assertions:
- http.request.header.accept_language:first = "["duplicate1"]"
- http.request.header.accept_language:last = "["duplicate2"]"
# assert on nth_child - fails assertion when entry of nth_child doesn't exist
assertions:
- http.request.header.accept_language:nth_child(1) = "["duplicate1"]"
- http.request.header.accept_language:nth_child(2) = "["duplicate2"]"
Additional context Tracetest UI currently doesn’t allow multiple headers with same key Add 2 headers:
Header is sent once, with the last value:
Issue Analytics
- State:
- Created a year ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Set more than one HTTP header with the same name?
A recipient MAY combine multiple header fields with the same field name into one field-name: field-value pair, without changing the semantics of the...
Read more >multiple headers of the "same name" allowed in http #3591
Multiple message-header fields with the same field-name MAY be present in a message if and only if the entire field-value for that header...
Read more >Multiple header values with the same name - HTTPie
If the request is sent with multiple headers that are sharing the same name, then the HTTPie will send them individually. It is...
Read more >Multiple Headers With Same Name and different Values - IBM
Datapower is replacing the multiple headers with same header name and different values as single header by concatinating the values.
Read more >Access multi-value HTTP headers incorrectly in an API Proxy ...
The HTTP Headers can have one or more values depending on the header field definitions. A multi-valued header will have comma separated values....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @mathnogueira,
Appreciate the quick fix, will play around with duplicate header-values in v0.7.5.
We look forward to added assertions, environment variables and test suites in v0.8 - huge changes for automation and CI/CD pipelines!
@abcl-trifork Will inform you once 0.8 releases. Plan is a few weeks - we have to bring together several elements (variables, environments, transactions / chaining) - a bit of a more tightly coupled release than normal.
Let us know how the duplicate header fix works for you.