summaryrefslogtreecommitdiff
path: root/test/etap/test_util.erl.in
diff options
context:
space:
mode:
authorFilipe David Borba Manana <fdmanana@apache.org>2011-09-29 23:34:40 +0000
committerFilipe David Borba Manana <fdmanana@apache.org>2011-09-29 23:34:40 +0000
commit1285cd95c8fe351991218f886bbfe28d9a9a3b09 (patch)
treea62af53acc1fb9be4e943ab1935e6fa92889863f /test/etap/test_util.erl.in
parent89a5c28775f24f2706f443c76afa3edf9df78ce4 (diff)
Remove usage of http module from etap tests
This module is deprecated in OTP R15, which is going to be released by the end of this year. The etap tests now use ibrowse instead. This is a backport of revision 1177459 from trunk. git-svn-id: https://svn.apache.org/repos/asf/couchdb/branches/1.1.x@1177463 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'test/etap/test_util.erl.in')
-rw-r--r--test/etap/test_util.erl.in28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/etap/test_util.erl.in b/test/etap/test_util.erl.in
index 460b0293..b986ff35 100644
--- a/test/etap/test_util.erl.in
+++ b/test/etap/test_util.erl.in
@@ -14,6 +14,7 @@
-export([init_code_path/0]).
-export([source_file/1, build_file/1, config_files/0]).
+-export([request/3, request/4]).
srcdir() ->
"@abs_top_srcdir@".
@@ -40,3 +41,30 @@ config_files() ->
source_file("test/etap/random_port.ini")
].
+request(Url, Headers, Method) ->
+ request(Url, Headers, Method, []).
+
+request(Url, Headers, Method, Body) ->
+ request(Url, Headers, Method, Body, 3).
+
+request(_Url, _Headers, _Method, _Body, 0) ->
+ {error, request_failed};
+request(Url, Headers, Method, Body, N) ->
+ case code:is_loaded(ibrowse) of
+ false ->
+ {ok, _} = ibrowse:start();
+ _ ->
+ ok
+ end,
+ case ibrowse:send_req(Url, Headers, Method, Body) of
+ {ok, Code0, RespHeaders, RespBody0} ->
+ Code = list_to_integer(Code0),
+ RespBody = iolist_to_binary(RespBody0),
+ {ok, Code, RespHeaders, RespBody};
+ {error, {'EXIT', {normal, _}}} ->
+ % Connection closed right after a successful request that
+ % used the same connection.
+ request(Url, Headers, Method, Body, N - 1);
+ Error ->
+ Error
+ end.