# HTTP client libraries and wrappers

**URL:** <https://forum.elixirforum.com/t/http-client-libraries-and-wrappers/15938>\
**Category:** Discussions\
**Tags:** http\_client, http\
**Created:** [August 18, 2018, 5:57pm UTC](https://forum.elixirforum.com/t/http-client-libraries-and-wrappers/15938 "2018-08-18T17:57:58Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![dimitarvp](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/dimitarvp/32/38664_2.png) [@dimitarvp](https://forum.elixirforum.com/u/dimitarvp)\
**Post date:** [August 19, 2018, 1:14am UTC](https://forum.elixirforum.com/t/http-client-libraries-and-wrappers/15938/5 "2018-08-19T01:14:21Z")

</div>

> [@chulkilee](#):
>
> For performance, what about using NIF to parse headers?

Why not do some code generation and make use of Elixir’s pattern matching, like so?

```elixir
  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! :023: :041:

---

_[View the full topic](https://forum.elixirforum.com/t/http-client-libraries-and-wrappers/15938)._
