Why not do some code generation and make use of Elixir’s pattern matching, like so?
def header_pair("Content-Encoding" <> rest), do: {"Content-Encoding", header_value(rest)}
def header_pair("If-None-Match" <> rest), do: {"If-None-Match", header_value(rest)}
# ^ these can be generated with a macro
def header_value(val) do
String.split(val, ~r/\s*:\s*/, trim: true)
|> hd
end
I am sure C code will be faster, however crossing the VM ↔ native barrier has an overhead as well. I have not measured the native approach but I would turn the question back to you: have you established with certainty that Elixir HTTP header parsing is a bottleneck in your workflow?
(EDIT: on a second thought, this is not practical if we want to accept all possible case combinations for the headers.)
BTW, awesome job compiling the list!
![]()






















