diff options
author | ILYA Khlopotov <iilyak@apache.org> | 2019-08-19 16:34:23 +0000 |
---|---|---|
committer | ILYA Khlopotov <iilyak@apache.org> | 2019-08-19 16:34:23 +0000 |
commit | ac4d4fcc7d161725196437520e3b5cfee8dc9954 (patch) | |
tree | 273e618d8a0ecb79926d55d59ce17cce3cfd8ae5 | |
parent | 29b3569e7d23dc96adc30fe60aa903e59a4f7e90 (diff) | |
download | couchdb-ac4d4fcc7d161725196437520e3b5cfee8dc9954.tar.gz |
Increase default HTTP timeouts
This commits ports `couch.ex` related chages from
https://github.com/apache/couchdb/pull/2104 into the world where
we don't override `process_arguments/3`
-rw-r--r-- | test/elixir/lib/couch.ex | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/test/elixir/lib/couch.ex b/test/elixir/lib/couch.ex index 65da13d75..6c7310d56 100644 --- a/test/elixir/lib/couch.ex +++ b/test/elixir/lib/couch.ex @@ -87,19 +87,10 @@ defmodule Couch do end def process_options(options) do - if Keyword.get(options, :cookie) == nil do - headers = Keyword.get(options, :headers, []) - - if headers[:basic_auth] != nil or headers[:authorization] != nil do - options - else - username = System.get_env("EX_USERNAME") || "adm" - password = System.get_env("EX_PASSWORD") || "pass" - Keyword.put(options, :basic_auth, {username, password}) - end - else - options - end + options + |> set_auth_options() + |> set_inactivity_timeout() + |> set_request_timeout() end def process_request_body(body) do @@ -120,6 +111,33 @@ defmodule Couch do end end + def set_auth_options(options) do + if Keyword.get(options, :cookie) == nil do + headers = Keyword.get(options, :headers, []) + + if headers[:basic_auth] != nil or headers[:authorization] != nil do + options + else + username = System.get_env("EX_USERNAME") || "adm" + password = System.get_env("EX_PASSWORD") || "pass" + Keyword.put(options, :basic_auth, {username, password}) + end + else + options + end + end + + def set_inactivity_timeout(options) do + Keyword.update(options, :ibrowse, [{:inactivity_timeout, @inactivity_timeout}], fn(ibrowse) -> + Keyword.put_new(ibrowse, :inactivity_timeout, @inactivity_timeout) + end) + end + + def set_request_timeout(options) do + timeout = Application.get_env(:httpotion, :default_timeout, @request_timeout) + Keyword.put_new(options, :timeout, timeout) + end + def login(userinfo) do [user, pass] = String.split(userinfo, ":", parts: 2) login(user, pass) |