           bytes ->
             {headers, true, {:bytes, bytes}}
         end
+    end
+  end
+
+  defp decode_connection_status(headers) do
+    case Enum.split_with(headers, fn {key, _value} -> key == "connection" end) do
+      {[{"connection", "close"}], headers} ->
+        {:close, headers}
+
+      {[{"connection", "keep-alive"}], headers} ->
+        {:keepalive, headers}
+
+      {[], headers} ->
+        {nil, headers}
     end
   end
 

         query: "qs",
         raw_path: "/path",
         scheme: :https
       }, {:complete, ""}, ""}

      iex> "POST /path HTTP/1.1\\r\\nhost: example.com\\r\\ntransfer-encoding: chunked\\r\\ncontent-type: text/plain\\r\\n\\r\\n"
      ...> |> Raxx.HTTP1.parse_request(:http)
      {:ok,
       %Raxx.Request{
         authority: "example.com",
         body: true,
         headers: [{"content-type", "text/plain"}],

      ...> |> Raxx.HTTP1.parse_request(:http)
      {:error, {:invalid_line, "!!!BAD_HEADER\\r\\n"}}

      iex> "GET /path?qs HTTP/1.1\\r\\nhost: example.com\\r\\nconnection: close\\r\\naccept: text/plain\\r\\n\\r\\n"
      ...> |> Raxx.HTTP1.parse_request(:http)
      {:ok,
       {%Raxx.Request{
         authority: "example.com",
         body: false,
         headers: [{"accept", "text/plain"}],
         method: :GET,
         mount: [],
         path: ["path"],
         query: "qs",
         raw_path: "/path",
         scheme: :http
       }, :close, {:complete, ""}, ""}}


       iex> "GET /path?qs HTTP/1.1\\r\\nhost: example.com\\r\\nconnection: keep-alive\\r\\naccept: text/plain\\r\\n\\r\\n"
       ...> |> Raxx.HTTP1.parse_request(:http)
       {:ok,
        {%Raxx.Request{
          authority: "example.com",
          body: false,
          headers: [{"accept", "text/plain"}],
          method: :GET,
          mount: [],
          path: ["path"],
          query: "qs",
          raw_path: "/path",
          scheme: :http
        }, :keepalive, {:complete, ""}, ""}}
  """
  def parse_request(buffer, scheme) when is_atom(scheme) do
    case :erlang.decode_packet(:http_bin, buffer, []) do
