   end
 
   defp payload(%{headers: headers, body: iodata}) do
+    # Assume well formed message so don't handle error case
     payload_headers =
-      case content_length(headers) do
-        nil ->
+      case fetch_content_length(headers) do
+        {:ok, nil} ->
           case :erlang.iolist_size(iodata) do
             0 ->
               []

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

      {:ok, {:http_error, invalid_line}, _rest} ->
        {:error, {:invalid_line, invalid_line}}

  end

  defp payload(%{headers: headers, body: true}) do
    # Assume well formed message so don't handle error case
    case fetch_content_length(headers) do
      {:ok, nil} ->
        {[{"transfer-encoding", "chunked"}], :chunked}

      {:ok, content_length} ->
        {[], {:bytes, content_length}}
    end
  end
