瀏覽代碼

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.
pull/123/head
benjaminplee 10 年之前
父節點
當前提交
6bf1951c99
共有 2 個文件被更改,包括 7 次插入1 次删除
  1. +5
    -1
      test/ibrowse_functional_tests.erl
  2. +2
    -0
      test/ibrowse_test_server.erl

+ 5
- 1
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)).

+ 2
- 0
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">>,

Loading…
取消
儲存