   defp join([s | rest], separator, acc), do: join(rest, separator, [s, separator | acc])
 
 end
-

  end

  defp header_value(value, params) do
    params =
      params
      |> Enum.reduce([],
    fn({k, v}, acc) ->
      k = value_to_binary(k)
      v = value_to_binary(v)
      [k <> "=" <> v | acc]
    end)
    |> Enum.reverse
      join([value |params] , "; ")
  end

  defp replace_header_from_extra(headers, extra_headers) do

    |> Enum.reduce(headers, fn({ex_header, ex_value}, acc) ->
      case List.keymember?(acc, ex_header, 0) do
        true ->  List.keyreplace(acc, ex_header, 0, {ex_header, ex_value})
        false -> [{ex_header, ex_value} | acc]
      end
    end)
  end
