From 6bf1951c99a97adb394e0bacf6af4a2221652759 Mon Sep 17 00:00:00 2001 From: benjaminplee Date: Tue, 18 Nov 2014 20:21:53 +0000 Subject: [PATCH] Add new endpoint to test_server for slow responses New endpoint will never send back a response and can be used for verifying timeouts and long running processes. --- test/ibrowse_functional_tests.erl | 6 +++++- test/ibrowse_test_server.erl | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/ibrowse_functional_tests.erl b/test/ibrowse_functional_tests.erl index a291eb5..c2bae86 100644 --- a/test/ibrowse_functional_tests.erl +++ b/test/ibrowse_functional_tests.erl @@ -31,9 +31,13 @@ running_server_fixture_test_() -> fun setup/0, fun teardown/1, [ - ?TIMEDTEST("Simple request can be honored", simple_request) + ?TIMEDTEST("Simple request can be honored", simple_request), + ?TIMEDTEST("Slow server causes timeout", slow_server_timeout) ] }. simple_request() -> ?assertMatch({ok, "200", _, _}, ibrowse:send_req(?BASE_URL, [], get, [], [])). + +slow_server_timeout() -> + ?assertMatch({error, req_timedout}, ibrowse:send_req(?BASE_URL ++ "/never_respond", [], get, [], [], 5000)). diff --git a/test/ibrowse_test_server.erl b/test/ibrowse_test_server.erl index a00fe5b..c102431 100644 --- a/test/ibrowse_test_server.erl +++ b/test/ibrowse_test_server.erl @@ -201,6 +201,8 @@ process_request(Sock, Sock_type, uri = {abs_path, "/ibrowse_303_with_body_test"}}) -> Resp = <<"HTTP/1.1 303 See Other\r\nLocation: http://example.org\r\nContent-Length: 5\r\n\r\nabcde">>, do_send(Sock, Sock_type, Resp); +process_request(_Sock, _Sock_type, #request{uri = {abs_path, "/never_respond"} } ) -> + noop; process_request(Sock, Sock_type, Req) -> do_trace("Recvd req: ~p~n", [Req]), Resp = <<"HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n">>,