   end
 
   @doc """
-  Returns the string representation of the given `URI` struct.
+  Returns the string representation of the given `Sippet.URI` struct.
       iex> Sippet.URI.to_string(Sippet.URI.parse("sip:foo@bar.com"))
       "sip:foo@bar.com"
       iex> Sippet.URI.to_string(%URI{scheme: "foo", host: "bar.baz"})

  """
  @spec encode_headers(term) :: binary
  def encode_headers(enumerable) do
    cond do
      Enum.empty?(enumerable) -> ""
      :otherwise -> "?" <> Enum.map_join(enumerable, "&", &encode_hnv_pair/1) 
    end
  end

  defp encode_hnv_pair({key, _}) when is_list(key) do
    raise ArgumentError, "encode_headers/1 keys cannot be lists, got: #{inspect key}"
  end

  defp encode_hnv_pair({_, value}) when is_list(value) do
    raise ArgumentError, "encode_headers/1 values cannot be lists, got: #{inspect value}"
  end

  defp encode_hnv_pair({key, value}) do
    cond do
      is_nil(value) -> encode_hnvchar(Kernel.to_string(key))
      :otherwise -> encode_hnvchar(Kernel.to_string(key)) <>
          "=" <> encode_hnvchar(Kernel.to_string(value)) 
    end
  end

  @doc """

      end

    {next_pair, rest}
  end

  @doc """
  Returns a stream of two-element tuples representing key-value pairs in the
  given `parameters`.
  Key and value in each tuple will be binaries and will be percent-unescaped.
  ## Examples
      iex> Sippet.URI.parameters_decoder(";foo=1;bar=2") |> Enum.to_list()
      [{"foo", "1"}, {"bar", "2"}]
  """
  @spec parameters_decoder(binary) :: Enumerable.t
  def parameters_decoder(parameters) when is_binary(parameters) do
    middle = remove_first_char("parameters_decoder/1", parameters, ";")
    Stream.unfold(middle, &decode_next_pair(&1, ";"))
  end

  @doc """
