question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Multiple HTTP Request Headers with same Key

See original GitHub issue

Problem 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:

  1. Allowing sending of multiple headers with same key.
  2. 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:

image

Header is sent once, with the last value:

image

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
abcl-triforkcommented, Oct 14, 2022

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!

0reactions
kdhamriccommented, Oct 14, 2022

@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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found