Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTPotion became soft-deprecated #2728

Open
dottorblaster opened this issue Mar 28, 2020 · 3 comments
Open

HTTPotion became soft-deprecated #2728

dottorblaster opened this issue Mar 28, 2020 · 3 comments

Comments

@dottorblaster
Copy link
Member

HTTPotion, the HTTP client we use in our integration test suite, became soft-deprecated. Should we look for an exit strategy?

Summary

As of today, doing a mix deps.get results in a correct behavior but a warning comes out telling us that HTTPotion is soft-deprecated.

Desired Behaviour

Maybe we don't want that warning, and of course we still want our libraries to be maintained.

Possible Solution

We could use another library as the HTTP client of choice.

Possible choices that I overlooked:

@iilyak
Copy link
Contributor

iilyak commented Mar 30, 2020

Be warned there might be dragons. We are not only using an API of the HTTPotion but override some of the callbacks provided by it (see here). Things we do:

  • prefix the url with the value of EX_COUCH_URL environment variable
  • inject authentication cookie into headers
  • automatically encode/decode JSON

In addition to that the prototype/fdb-layer branch also allows passing base_url in options.

@dottorblaster
Copy link
Member Author

Thanks for the response @iilyak, yeah we do a couple of things 🙂 but those aren't a problem as this kind of things is fairly common when it comes to these libs. I'm concerned more about changes_async_test.exs where we heavily use HTTPotion advanced features and I don't know how to replace functions like spawn_worker_process

@iilyak
Copy link
Contributor

iilyak commented Mar 30, 2020

I'm concerned more about changes_async_test.exs where we heavily use HTTPotion advanced features and I don't know how to replace functions like spawn_worker_process

I think tesla is better option because it supports multiple backends.

  1. We could eliminate Rawresp if we would pass additional option to control whether we should try to do JSON decode or not.
  2. The spawn_worker_process can be taken from https://github.com/myfreeweb/httpotion/blob/master/lib/httpotion.ex#L17:L25
      @doc "Starts a worker process for use with the `direct` option."
      def spawn_worker_process(url, options \\ []) do
        GenServer.start(:ibrowse_http_client, url |> process_url(options) |> String.to_charlist, options)
      end

      @doc "Starts a linked worker process for use with the `direct` option."
      def spawn_link_worker_process(url, options \\ []) do
        GenServer.start_link(:ibrowse_http_client, url |> process_url(options) |> String.to_charlist, options)
      end
  1. We need some support for direct option. We could do that if we would implement custom ibrowse backend. The current ibrowse backend is around 50 lines https://github.com/teamon/tesla/blob/9ea2e9e663b6ec3ca1acad7178a863b76da0cab9/lib/tesla/adapter/ibrowse.ex.
    We would add direct option in opts and implement a dispatch similar to one in HTTPotion (https://github.com/myfreeweb/httpotion/blob/master/lib/httpotion.ex#L242:L246):
        response = if conn_pid = Keyword.get(options, :direct) do
          :ibrowse.send_req_direct(conn_pid, args[:url], args[:headers], args[:method], args[:body], args[:ib_options], args[:timeout])
        else
          :ibrowse.send_req(args[:url], args[:headers], args[:method], args[:body], args[:ib_options], args[:timeout])
        end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants