                   |> Map.put(:body, body)
 
                 {:ok, request, state, rest2}
+
+              {[], _headers} ->
+                {:error, :no_host_header}
             end
+
+          {:error, reason} ->
+            {:error, reason}
 
           {:more, :undefined} ->
             {:more, buffer}
         end
+
+      {:ok, {:http_error, invalid_line}, _rest} ->
+        {:error, {:invalid_line, invalid_line}}
 
       {:more, :undefined} ->
         {:more, buffer}

            {headers, body, state} = decode_payload(headers)
            {:ok, %Raxx.Response{status: status, headers: headers, body: body}, state, rest2}

          {:more, :undefined} ->
            {:more, :undefined}
        end

      {:more, :undefined} ->
        {:more, :undefined}

    end
  end

  defp request_line(%Raxx.Request{method: method, raw_path: path, query: query}) do
    query_string = if query, do: ["?", query], else: ""
    [Atom.to_string(method), " ", path, query_string, " HTTP/1.1", @crlf]
  end

  defp status_line(%Raxx.Response{status: status}) do
    [
      "HTTP/1.1 ",
      Integer.to_string(status),
