Plug.Test multiple instances of request headers

So, Conn.get_req_header/2 returns [binary()] and I’m trying to figure out how to properly test multiple instances of a header with Plug.Test. Using Conn.Test.put_req_header/3 twice overwrites the header, and doesn’t add the second instance of the header, and it accepts only a single binary() as the value.

This does not work:

conn =
  "get"
  |> conn("/")
  |> put_req_header("test-header", "v1")
  |> put_req_header("test-header", "v2")
  |> call()

When get_req_header("test-header") is called, I would expect ["v1", "v2"], but instead get ["v2"].

This does not compile:

conn =
  "get"
  |> conn("/")
  |> put_req_header("test-header", ["v1", "v2"])
  |> call()

Any suggestions?

This feels like an oversight in favor of the common intention when setting headers and maybe matching put_resp_header. I’d consider opening an issue/pr for plug to allow for adding multiple values per header.

Yeah. That’s what I was afraid of.