diff options
Diffstat (limited to 'lib/inets/test/httpc_SUITE.erl')
-rw-r--r-- | lib/inets/test/httpc_SUITE.erl | 421 |
1 files changed, 250 insertions, 171 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index 22bd55355c..f89b06fddd 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -1,8 +1,8 @@ %% %% %CopyrightBegin% -%% +%% %% Copyright Ericsson AB 2004-2023. All Rights Reserved. -%% +%% %% Licensed under the Apache License, Version 2.0 (the "License"); %% you may not use this file except in compliance with the License. %% You may obtain a copy of the License at @@ -14,12 +14,12 @@ %% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %% See the License for the specific language governing permissions and %% limitations under the License. -%% +%% %% %CopyrightEnd% %% %% -%% +%% %% ct:run("../inets_test", httpc_SUITE). %% @@ -32,12 +32,14 @@ -include("http_internal.hrl"). -include("httpc_internal.hrl"). %% Note: This directive should only be used in test suites. --compile(export_all). +-compile([export_all, nowarn_export_all]). -define(URL_START, "http://"). -define(TLS_URL_START, "https://"). -define(NOT_IN_USE_PORT, 8997). +-define(SSL_NO_VERIFY, {ssl, [{verify, verify_none}]}). + %% Using hardcoded file path to keep it below 107 characters %% (maximum length supported by erlang) -define(UNIX_SOCKET, "/tmp/inets_httpc_SUITE.sock"). @@ -71,8 +73,10 @@ groups() -> %% process_leak_on_keepalive is depending on stream_fun_server_close %% and it shall be the last test case in the suite otherwise cookie %% will fail. - {sim_http, [], only_simulated() ++ server_closing_connection() ++ [process_leak_on_keepalive]}, + {sim_http, [], only_simulated() ++ server_closing_connection() ++ + [process_leak_on_keepalive]}, {http_internal, [], real_requests_esi()}, + {http_internal_minimum_bytes, [], [remote_socket_close_parallel]}, {http_unix_socket, [], simulated_unix_socket()}, {https, [], [def_ssl_opt | real_requests()]}, {sim_https, [], only_simulated()}, @@ -219,6 +223,7 @@ sim_mixed() -> %%-------------------------------------------------------------------- init_per_suite(Config) -> + logger:set_primary_config(level, warning), PrivDir = proplists:get_value(priv_dir, Config), DataDir = proplists:get_value(data_dir, Config), inets_test_lib:start_apps([inets]), @@ -239,14 +244,14 @@ init_per_group(misc = Group, Config) -> Inet = inet_version(), ok = httpc:set_options([{ipfamily, Inet}]), Config; - - init_per_group(Group, Config0) when Group =:= sim_https; Group =:= https; Group =:= sim_mixed -> catch crypto:stop(), try crypto:start() of ok -> start_apps(Group), + httpc:set_options([{keep_alive_timeout, 50000}, + {max_keep_alive_length, 5}]), do_init_per_group(Group, Config0) catch _:_ -> @@ -286,7 +291,7 @@ end_per_group(http_unix_socket, Config) -> %% it, dummy server waits in gen_tcp:accept and will not process stop request httpc:request(get, {"http://localhost/v1/kv/foo", []}, [], []), receive - {stopped, DummyServerPid} -> + {stopped, _DummyServerPid} -> ok end, file:delete(?UNIX_SOCKET), @@ -319,16 +324,20 @@ init_ssl(Config) -> ClientFileBase = filename:join([proplists:get_value(priv_dir, Config), "client"]), ServerFileBase = filename:join([proplists:get_value(priv_dir, Config), "server"]), GenCertData = - public_key:pkix_test_data(#{server_chain => - #{root => [{key, inets_test_lib:hardcode_rsa_key(1)}], - intermediates => [[{key, inets_test_lib:hardcode_rsa_key(2)}]], - peer => [{key, inets_test_lib:hardcode_rsa_key(3)} - ]}, - client_chain => - #{root => [{key, inets_test_lib:hardcode_rsa_key(4)}], - intermediates => [[{key, inets_test_lib:hardcode_rsa_key(5)}]], - peer => [{key, inets_test_lib:hardcode_rsa_key(6)}]}}), - + public_key:pkix_test_data(#{server_chain => + #{root => [{key, inets_test_lib:hardcode_rsa_key(1)}, + {digest, sha256}], + intermediates => [[{key, inets_test_lib:hardcode_rsa_key(2)}, + {digest, sha256}]], + peer => [{key, inets_test_lib:hardcode_rsa_key(3)}, + {digest, sha256}] + }, + client_chain => + #{root => [{key, inets_test_lib:hardcode_rsa_key(4)}, + {digest, sha256}], + intermediates => [[{key, inets_test_lib:hardcode_rsa_key(5)}, + {digest, sha256}]], + peer => [{key, inets_test_lib:hardcode_rsa_key(6)},{digest, sha256}]}}), Conf = inets_test_lib:gen_pem_config_files(GenCertData, ClientFileBase, ServerFileBase), [{ssl_conf, Conf} | Config]. @@ -345,7 +354,8 @@ init_per_testcase(persistent_connection, Config) -> {max_keep_alive_length, 3}], persistent), Config; -init_per_testcase(wait_for_whole_response, Config) -> +init_per_testcase(Case, Config) when Case == wait_for_whole_response; + Case == remote_socket_close_parallel -> ct:timetrap({seconds, 60*3}), Config; init_per_testcase(Case, Config) when Case == post; @@ -376,35 +386,31 @@ end_per_testcase(Case, Config) httpc:request(url(group_name(Config), "/just_close.html", Config)), ok; true -> - ct:pal("Not cleaning up because test case status was ~p", [Status]), + ct:log("Not cleaning up because test case status was ~p", [Status]), ok end; - end_per_testcase(_Case, _Config) -> ok. - - %%-------------------------------------------------------------------- %% Test Cases -------------------------------------------------------- %%-------------------------------------------------------------------- - head() -> [{doc, "Test http head request against local server."}]. head(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, - {ok, {{_,200,_}, [_ | _], []}} = httpc:request(head, Request, [], []). + {ok, {{_,200,_}, [_ | _], []}} = httpc:request(head, Request, [?SSL_NO_VERIFY], []). %%-------------------------------------------------------------------- get() -> [{doc, "Test http get request against local server"}]. get(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, - {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} = httpc:request(get, Request, [], []), + {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} = httpc:request(get, Request, [?SSL_NO_VERIFY], []), inets_test_lib:check_body(Body), - {ok, {{_,200,_}, [_ | _], BinBody}} = httpc:request(get, Request, [], [{body_format, binary}]), + {ok, {{_,200,_}, [_ | _], BinBody}} = httpc:request(get, Request, [?SSL_NO_VERIFY], [{body_format, binary}]), true = is_binary(BinBody). @@ -412,7 +418,7 @@ get_query_string() -> [{doc, "Test http get request with query string against local server"}]. get_query_string(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html?foo=bar", Config), []}, - {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} = httpc:request(get, Request, [], []), + {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} = httpc:request(get, Request, [?SSL_NO_VERIFY], []), inets_test_lib:check_body(Body). @@ -421,7 +427,7 @@ get_space() -> [{"Test http get request with '%20' in the path of the URL."}]. get_space(Config) when is_list(Config) -> Request = {url(group_name(Config), "/space%20.html", Config), []}, - {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} = httpc:request(get, Request, [], []), + {ok, {{_,200,_}, [_ | _], Body = [_ | _]}} = httpc:request(get, Request, [?SSL_NO_VERIFY], []), inets_test_lib:check_body(Body). @@ -445,11 +451,11 @@ post(Config) when is_list(Config) -> {ok, {{_,200,_}, [_ | _], [_ | _]}} = httpc:request(post, {URL, [{"expect","100-continue"}], - "text/plain", Body}, [], []), + "text/plain", Body}, [?SSL_NO_VERIFY], []), {ok, {{_,504,_}, [_ | _], []}} = httpc:request(post, {URL, [{"expect","100-continue"}], - "text/plain", "foobar"}, [], []). + "text/plain", "foobar"}, [?SSL_NO_VERIFY], []). %%-------------------------------------------------------------------- delete() -> [{"Test http delete request against local server. We do in this case " @@ -468,11 +474,11 @@ delete(Config) when is_list(Config) -> {ok, {{_,200,_}, [_ | _], [_ | _]}} = httpc:request(delete, {URL, [{"expect","100-continue"}], - "text/plain", Body}, [], []), + "text/plain", Body}, [?SSL_NO_VERIFY], []), {ok, {{_,504,_}, [_ | _], []}} = httpc:request(delete, {URL, [{"expect","100-continue"}], - "text/plain", "foobar"}, [], []). + "text/plain", "foobar"}, [?SSL_NO_VERIFY], []). %%-------------------------------------------------------------------- patch() -> @@ -494,7 +500,7 @@ patch(Config) when is_list(Config) -> {ok, {{_,200,_}, [_ | _], [_ | _]}} = httpc:request(patch, {URL, [{"expect","100-continue"}], - "text/plain", Body}, [], []). + "text/plain", Body}, [?SSL_NO_VERIFY], []). %%-------------------------------------------------------------------- post_stream() -> @@ -522,20 +528,20 @@ post_stream(Config) when is_list(Config) -> httpc:request(post, {URL, [{"expect", "100-continue"}, {"content-length", "100"}], - "text/plain", {BodyFun, 100}}, [], []), + "text/plain", {BodyFun, 100}}, [?SSL_NO_VERIFY], []), {ok, {{_,504,_}, [_ | _], []}} = httpc:request(post, {URL, [{"expect", "100-continue"}, {"content-length", "10"}], - "text/plain", {BodyFun, 10}}, [], []). + "text/plain", {BodyFun, 10}}, [?SSL_NO_VERIFY], []). %%-------------------------------------------------------------------- trace() -> [{doc, "Perform a TRACE request."}]. trace(Config) when is_list(Config) -> Request = {url(group_name(Config), "/trace.html", Config), []}, - case httpc:request(trace, Request, [], []) of + case httpc:request(trace, Request, [?SSL_NO_VERIFY], []) of {ok, {{_,200,_}, [_ | _], "TRACE /trace.html" ++ _}} -> ok; Other -> @@ -546,7 +552,7 @@ trace(Config) when is_list(Config) -> pipeline(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, - {ok, _} = httpc:request(get, Request, [], [], pipeline), + {ok, _} = httpc:request(get, Request, [?SSL_NO_VERIFY], [], pipeline), %% Make sure pipeline session is registered ct:sleep(4000), @@ -556,7 +562,7 @@ pipeline(Config) when is_list(Config) -> persistent_connection(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, - {ok, _} = httpc:request(get, Request, [], [], persistent), + {ok, _} = httpc:request(get, Request, [?SSL_NO_VERIFY], [], persistent), %% Make sure pipeline session is registered ct:sleep(4000), @@ -569,7 +575,7 @@ async(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, {ok, RequestId} = - httpc:request(get, Request, [], [{sync, false}]), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}]), Body = receive {http, {RequestId, {{_, 200, _}, _, BinBody}}} -> @@ -580,7 +586,7 @@ async(Config) when is_list(Config) -> inets_test_lib:check_body(binary_to_list(Body)), {ok, NewRequestId} = - httpc:request(get, Request, [], [{sync, false}]), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}]), ok = httpc:cancel_request(NewRequestId). %%------------------------------------------------------------------------- @@ -592,7 +598,7 @@ save_to_file(Config) when is_list(Config) -> URL = url(group_name(Config), "/dummy.html", Config), Request = {URL, []}, {ok, saved_to_file} - = httpc:request(get, Request, [], [{stream, FilePath}]), + = httpc:request(get, Request, [?SSL_NO_VERIFY], [{stream, FilePath}]), {ok, Bin} = file:read_file(FilePath), {ok, {{_,200,_}, [_ | _], Body}} = httpc:request(URL), Bin == Body. @@ -605,7 +611,7 @@ save_to_file_async(Config) when is_list(Config) -> FilePath = filename:join(PrivDir, "dummy.html"), URL = url(group_name(Config), "/dummy.html", Config), Request = {URL, []}, - {ok, RequestId} = httpc:request(get, Request, [], + {ok, RequestId} = httpc:request(get, Request, [?SSL_NO_VERIFY], [{stream, FilePath}, {sync, false}]), receive @@ -676,10 +682,10 @@ redirect_multiple_choises(Config) when is_list(Config) -> URL300 = url(group_name(Config), "/300.html", Config), catch {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, {URL300, []}, [], []), + = httpc:request(get, {URL300, []}, [?SSL_NO_VERIFY], []), {ok, {{_,300,_}, [_ | _], _}} = - httpc:request(get, {URL300, []}, [{autoredirect, false}], []). + httpc:request(get, {URL300, []}, [{autoredirect, false},?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- redirect_moved_permanently() -> [{doc, "The server SHOULD generate a Location header field in the response " @@ -692,14 +698,14 @@ redirect_moved_permanently(Config) when is_list(Config) -> URL301 = url(group_name(Config), "/301.html", Config), {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, {URL301, []}, [], []), + = httpc:request(get, {URL301, []}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], []}} - = httpc:request(head, {URL301, []}, [], []), + = httpc:request(head, {URL301, []}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], [_|_]}} = httpc:request(post, {URL301, [],"text/plain", "foobar"}, - [], []). + [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- redirect_found() -> [{doc, "The server SHOULD generate a Location header field in the response " @@ -712,14 +718,14 @@ redirect_found(Config) when is_list(Config) -> URL302 = url(group_name(Config), "/302.html", Config), {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, {URL302, []}, [], []), + = httpc:request(get, {URL302, []}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], []}} - = httpc:request(head, {URL302, []}, [], []), + = httpc:request(head, {URL302, []}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], [_|_]}} = httpc:request(post, {URL302, [],"text/plain", "foobar"}, - [], []). + [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- redirect_see_other() -> [{doc, "The different URI SHOULD be given by the Location field in the response. " @@ -730,14 +736,14 @@ redirect_see_other(Config) when is_list(Config) -> URL303 = url(group_name(Config), "/303.html", Config), {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, {URL303, []}, [], []), + = httpc:request(get, {URL303, []}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], []}} - = httpc:request(head, {URL303, []}, [], []), + = httpc:request(head, {URL303, []}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], [_|_]}} = httpc:request(post, {URL303, [],"text/plain", "foobar"}, - [], []). + [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- redirect_temporary_redirect() -> [{doc, "The server SHOULD generate a Location header field in the response " @@ -806,7 +812,7 @@ redirect_loop(Config) when is_list(Config) -> URL = url(group_name(Config), "/redirectloop.html", Config), {ok, {{_,300,_}, [_ | _], _}} - = httpc:request(get, {URL, []}, [], []). + = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- redirect_http_to_https() -> @@ -818,14 +824,15 @@ redirect_http_to_https(Config) when is_list(Config) -> Headers = [{"x-test-301-url", TargetUrl}], {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, {URL301, Headers}, [], []), + = httpc:request(get, {URL301, Headers}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], []}} - = httpc:request(head, {URL301, Headers}, [], []), + = httpc:request(head, {URL301, Headers}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], [_|_]}} = httpc:request(post, {URL301, Headers, "text/plain", "foobar"}, - [], []). + [?SSL_NO_VERIFY], []). + %%------------------------------------------------------------------------- redirect_relative_different_port() -> [{doc, "Test that a 30X redirect with a relative target, but different " @@ -859,7 +866,7 @@ cookie(Config) when is_list(Config) -> Request0 = {url(group_name(Config), "/cookie.html", Config), []}, {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, Request0, [], []), + = httpc:request(get, Request0, [?SSL_NO_VERIFY], []), %% Populate table to be used by the "dummy" server ets:new(cookie, [named_table, public, set]), @@ -868,7 +875,7 @@ cookie(Config) when is_list(Config) -> Request1 = {url(group_name(Config), "/", Config), []}, {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, Request1, [], []), + = httpc:request(get, Request1, [?SSL_NO_VERIFY], []), [{session_cookies, [_|_]}] = httpc:which_cookies(httpc:default_profile()), @@ -887,7 +894,7 @@ cookie_profile(Config) when is_list(Config) -> Request0 = {url(group_name(Config), "/cookie.html", Config), []}, {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, Request0, [], [], cookie_test), + = httpc:request(get, Request0, [?SSL_NO_VERIFY], [], cookie_test), %% Populate table to be used by the "dummy" server ets:new(cookie, [named_table, public, set]), @@ -896,7 +903,7 @@ cookie_profile(Config) when is_list(Config) -> Request1 = {url(group_name(Config), "/", Config), []}, {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, Request1, [], [], cookie_test), + = httpc:request(get, Request1, [?SSL_NO_VERIFY], [], cookie_test), ets:delete(cookie), inets:stop(httpc, cookie_test). @@ -910,7 +917,7 @@ empty_set_cookie(Config) when is_list(Config) -> Request0 = {url(group_name(Config), "/empty_set_cookie.html", Config), []}, {ok, {{_,200,_}, [_ | _], [_|_]}} - = httpc:request(get, Request0, [], []), + = httpc:request(get, Request0, [?SSL_NO_VERIFY], []), ok = httpc:set_options([{cookies, disabled}]). @@ -922,7 +929,7 @@ invalid_set_cookie(Config) when is_list(Config) -> URL = url(group_name(Config), "/invalid_set_cookie.html", Config), {ok, {{_,200,_}, [_|_], [_|_]}} = - httpc:request(get, {URL, []}, [], []), + httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []), ok = httpc:set_options([{cookies, disabled}]). @@ -933,10 +940,10 @@ headers_as_is(Config) when is_list(Config) -> URL = url(group_name(Config), "/dummy.html", Config), {ok, {{_,200,_}, [_|_], [_|_]}} = httpc:request(get, {URL, [{"Host", "localhost"},{"Te", ""}]}, - [], [{headers_as_is, true}]), + [?SSL_NO_VERIFY], [{headers_as_is, true}]), {ok, {{_,400,_}, [_|_], [_|_]}} = - httpc:request(get, {URL, [{"Te", ""}]},[], [{headers_as_is, true}]). + httpc:request(get, {URL, [{"Te", ""}]}, [?SSL_NO_VERIFY], [{headers_as_is, true}]). %%------------------------------------------------------------------------- userinfo(doc) -> @@ -948,12 +955,12 @@ userinfo(Config) when is_list(Config) -> URLAuth = url(group_name(Config), "alladin:sesame@" ++ Host ++ ":","/userinfo.html", Config), {ok, {{_,200,_}, [_ | _], _}} - = httpc:request(get, {URLAuth, []}, [], []), + = httpc:request(get, {URLAuth, []}, [?SSL_NO_VERIFY], []), URLUnAuth = url(group_name(Config), "alladin:foobar@" ++ Host ++ ":","/userinfo.html", Config), {ok, {{_,401, _}, [_ | _], _}} = - httpc:request(get, {URLUnAuth, []}, [], []). + httpc:request(get, {URLUnAuth, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -962,7 +969,7 @@ page_does_not_exist(doc) -> page_does_not_exist(Config) when is_list(Config) -> URL = url(group_name(Config), "/doesnotexist.html", Config), {ok, {{_,404,_}, [_ | _], [_ | _]}} - = httpc:request(get, {URL, []}, [], []). + = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- streaming_error(doc) -> @@ -972,9 +979,9 @@ streaming_error(Config) when is_list(Config) -> Method = get, Request = {url(group_name(Config), "/dummy.html", Config), []}, {error, streaming_error} = httpc:request(Method, Request, - [], [{sync, true}, {stream, {self, once}}]), + [?SSL_NO_VERIFY], [{sync, true}, {stream, {self, once}}]), {error, streaming_error} = httpc:request(Method, Request, - [], [{sync, true}, {stream, self}]). + [?SSL_NO_VERIFY], [{sync, true}, {stream, self}]). %%------------------------------------------------------------------------- server_does_not_exist(doc) -> @@ -984,14 +991,14 @@ server_does_not_exist(Config) when is_list(Config) -> {error, _} = httpc:request(get, {"http://localhost:" ++ integer_to_list(?NOT_IN_USE_PORT) - ++ "/", []},[], []). + ++ "/", []},[?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- no_content_204(doc) -> ["Test the case that the HTTP 204 no content header - Solves OTP 6982"]; no_content_204(Config) when is_list(Config) -> URL = url(group_name(Config), "/no_content.html", Config), - {ok, {{_,204,_}, [], []}} = httpc:request(URL). + {ok, {{_,204,_}, [], []}} = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1000,7 +1007,7 @@ tolerate_missing_CR() -> "as delimiter. Solves OTP-7304"}]. tolerate_missing_CR(Config) when is_list(Config) -> URL = url(group_name(Config), "/missing_CR.html", Config), - {ok, {{_,200,_}, _, [_ | _]}} = httpc:request(URL). + {ok, {{_,200,_}, _, [_ | _]}} = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- empty_body() -> @@ -1009,7 +1016,7 @@ empty_body() -> empty_body(Config) when is_list(Config) -> URL = url(group_name(Config), "/empty.html", Config), {ok, {{_,200,_}, [_ | _], []}} = - httpc:request(get, {URL, []}, [], []). + httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1017,13 +1024,13 @@ transfer_encoding() -> [{doc, "Transfer encoding is case insensitive. Solves OTP-6807"}]. transfer_encoding(Config) when is_list(Config) -> URL = url(group_name(Config), "/capital_transfer_encoding.html", Config), - {ok, {{_,200,_}, [_|_], [_ | _]}} = httpc:request(URL). + {ok, {{_,200,_}, [_|_], [_ | _]}} = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- transfer_encoding_identity(Config) when is_list(Config) -> URL = url(group_name(Config), "/identity_transfer_encoding.html", Config), - {ok, {{_,200,_}, [_|_], "IDENTITY"}} = httpc:request(URL). + {ok, {{_,200,_}, [_|_], "IDENTITY"}} = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1031,7 +1038,7 @@ empty_response_header() -> [{doc, "Test the case that the HTTP server does not send any headers. Solves OTP-6830"}]. empty_response_header(Config) when is_list(Config) -> URL = url(group_name(Config), "/no_headers.html", Config), - {ok, {{_,200,_}, [], [_ | _]}} = httpc:request(URL). + {ok, {{_,200,_}, [], [_ | _]}} = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1043,17 +1050,17 @@ bad_response(Config) when is_list(Config) -> URL0 = url(group_name(Config), "/missing_crlf.html", Config), URL1 = url(group_name(Config), "/wrong_statusline.html", Config), - {error, timeout} = httpc:request(get, {URL0, []}, [{timeout, 400}], []), - {error, Reason} = httpc:request(URL1), + {error, timeout} = httpc:request(get, {URL0, []}, [{timeout, 400},?SSL_NO_VERIFY], []), + {error, Reason} = httpc:request(get, {URL1, []}, [?SSL_NO_VERIFY], []), - ct:print("Wrong Statusline: ~p~n", [Reason]). + ct:log("Wrong Statusline: ~p~n", [Reason]). %%------------------------------------------------------------------------- timeout_redirect() -> [{doc, "Test that timeout works for redirects, check ERL-420."}]. timeout_redirect(Config) when is_list(Config) -> URL = url(group_name(Config), "/redirect_to_missing_crlf.html", Config), - {error, timeout} = httpc:request(get, {URL, []}, [{timeout, 400}], []). + {error, timeout} = httpc:request(get, {URL, []}, [{timeout, 400},?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1064,7 +1071,7 @@ internal_server_error(Config) when is_list(Config) -> URL500 = url(group_name(Config), "/500.html", Config), {ok, {{_,500,_}, [_ | _], _}} - = httpc:request(get, {URL500, []}, [], []), + = httpc:request(get, {URL500, []}, [?SSL_NO_VERIFY], []), URL503 = url(group_name(Config), "/503.html", Config), @@ -1073,12 +1080,12 @@ internal_server_error(Config) when is_list(Config) -> ets:insert(unavailable, {503, unavailable}), {ok, {{_,200, _}, [_ | _], [_|_]}} = - httpc:request(get, {URL503, []}, [], []), + httpc:request(get, {URL503, []}, [?SSL_NO_VERIFY], []), ets:insert(unavailable, {503, long_unavailable}), {ok, {{_,503, _}, [_ | _], [_|_]}} = - httpc:request(get, {URL503, []}, [], []), + httpc:request(get, {URL503, []}, [?SSL_NO_VERIFY], []), ets:delete(unavailable). @@ -1093,9 +1100,9 @@ invalid_http(Config) when is_list(Config) -> URL = url(group_name(Config), "/invalid_http.html", Config), {error, {could_not_parse_as_http, _} = Reason} = - httpc:request(get, {URL, []}, [], []), + httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []), - ct:print("Parse error: ~p ~n", [Reason]). + ct:log("Parse error: ~p ~n", [Reason]). %%------------------------------------------------------------------------- @@ -1108,9 +1115,9 @@ invalid_chunk_size(Config) when is_list(Config) -> URL = url(group_name(Config), "/invalid_chunk_size.html", Config), {error, {chunk_size, _} = Reason} = - httpc:request(get, {URL, []}, [], []), + httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []), - ct:print("Parse error: ~p ~n", [Reason]). + ct:log("Parse error: ~p ~n", [Reason]). %%------------------------------------------------------------------------- @@ -1121,10 +1128,10 @@ emulate_lower_versions(Config) when is_list(Config) -> URL = url(group_name(Config), "/dummy.html", Config), {ok, {{"HTTP/1.0", 200, _}, [_ | _], Body1 = [_ | _]}} = - httpc:request(get, {URL, []}, [{version, "HTTP/1.0"}], []), + httpc:request(get, {URL, []}, [{version, "HTTP/1.0"}, ?SSL_NO_VERIFY], []), inets_test_lib:check_body(Body1), {ok, {{"HTTP/1.1", 200, _}, [_ | _], Body2 = [_ | _]}} = - httpc:request(get, {URL, []}, [{version, "HTTP/1.1"}], []), + httpc:request(get, {URL, []}, [{version, "HTTP/1.1"}, ?SSL_NO_VERIFY], []), inets_test_lib:check_body(Body2). %%------------------------------------------------------------------------- @@ -1136,12 +1143,12 @@ relaxed(Config) when is_list(Config) -> URL = url(group_name(Config), "/missing_reason_phrase.html", Config), {error, Reason} = - httpc:request(get, {URL, []}, [{relaxed, false}], []), + httpc:request(get, {URL, []}, [{relaxed, false}, ?SSL_NO_VERIFY], []), - ct:print("Not relaxed: ~p~n", [Reason]), + ct:log("Not relaxed: ~p~n", [Reason]), {ok, {{_, 200, _}, [_ | _], [_ | _]}} = - httpc:request(get, {URL, []}, [{relaxed, true}], []). + httpc:request(get, {URL, []}, [{relaxed, true}, ?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1169,7 +1176,7 @@ headers(Config) when is_list(Config) -> Mod}, {"From","webmaster@erlang.se"}, {"Date", Date} - ]}, [], []), + ]}, [?SSL_NO_VERIFY], []), Mod1 = httpd_util:rfc1123_date( calendar:gregorian_seconds_to_datetime( @@ -1178,7 +1185,7 @@ headers(Config) when is_list(Config) -> {ok, {{_,200,_}, [_ | _], [_ | _]}} = httpc:request(get, {URL, [{"If-UnModified-Since", Mod1} - ]}, [], []), + ]}, [?SSL_NO_VERIFY], []), Tag = httpd_util:create_etag(FileInfo), @@ -1186,13 +1193,13 @@ headers(Config) when is_list(Config) -> {ok, {{_,200,_}, [_ | _], [_ | _]}} = httpc:request(get, {URL, [{"If-Match", Tag} - ]}, [], []), + ]}, [?SSL_NO_VERIFY], []), {ok, {{_,200,_}, [_ | _], _}} = httpc:request(get, {URL, [{"If-None-Match", "NotEtag,NeihterEtag"}, {"Connection", "Close"} - ]}, [], []). + ]}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- headers_dummy() -> ["Test the code for handling headers we do not want/can send " @@ -1251,14 +1258,14 @@ headers_dummy(Config) when is_list(Config) -> {"Last-Modified", "Sat, 29 Oct 1994 19:43:31 GMT"}, {"Trailer","1#User-Agent"} ], "text/plain", FooBar}, - [], []). + [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- headers_with_obs_fold(Config) when is_list(Config) -> Request = {url(group_name(Config), "/obs_folded_headers.html", Config), []}, - {ok, {{_,200,_}, Headers, [_|_]}} = httpc:request(get, Request, [], []), + {ok, {{_,200,_}, Headers, [_|_]}} = httpc:request(get, Request, [?SSL_NO_VERIFY], []), "a b" = proplists:get_value("folded", Headers). %%------------------------------------------------------------------------- @@ -1269,8 +1276,8 @@ headers_conflict_chunked_with_length(doc) -> "and must receive successful response in relaxed mode"]; headers_conflict_chunked_with_length(Config) when is_list(Config) -> Request = {url(group_name(Config), "/headers_conflict_chunked_with_length.html", Config), []}, - {error, {could_not_parse_as_http, _}} = httpc:request(get, Request, [{relaxed, false}], []), - {ok,{{_,200,_},_,_}} = httpc:request(get, Request, [{relaxed, true}], []), + {error, {could_not_parse_as_http, _}} = httpc:request(get, Request, [{relaxed, false}, ?SSL_NO_VERIFY], []), + {ok,{{_,200,_},_,_}} = httpc:request(get, Request, [{relaxed, true}, ?SSL_NO_VERIFY], []), ok. %%------------------------------------------------------------------------- @@ -1280,13 +1287,13 @@ invalid_headers_key(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), [{cookie, "valid cookie"}]}, {error, {headers_error, invalid_field}} = - httpc:request(get, Request, [], []). + httpc:request(get, Request, [?SSL_NO_VERIFY], []). invalid_headers_value(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), [{"cookie", atom_value}]}, {error, {headers_error, invalid_value}} = - httpc:request(get, Request, [], []). + httpc:request(get, Request, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1326,7 +1333,7 @@ test_header_type(Config, Method, Value) -> {Method, Value, httpc:request(Method, make_request(Config, Method, Value), - [], + [?SSL_NO_VERIFY], [])}. make_request(Config, Method, Value) -> @@ -1379,11 +1386,14 @@ invalid_method(Config) -> binary_url(Config) -> URL = uri_string:normalize(url(group_name(Config), "/dummy.html", Config)), - {ok, _Response} = httpc:request(unicode:characters_to_binary(URL)). + case group_name(Config) of + https -> ok; + _ -> {ok, _Response} = httpc:request(unicode:characters_to_binary(URL)) + end. %%------------------------------------------------------------------------- -iolist_body(Config) -> +iolist_body(_Config) -> {ok, ListenSocket} = gen_tcp:listen(0, [{active,once}, binary]), {ok,{_,Port}} = inet:sockname(ListenSocket), @@ -1458,7 +1468,7 @@ invalid_uri(Config) -> %%------------------------------------------------------------------------- remote_socket_close(Config) when is_list(Config) -> URL = url(group_name(Config), "/just_close.html", Config), - {error, socket_closed_remotely} = httpc:request(URL). + {error, socket_closed_remotely} = httpc:request(get, {URL, []}, [?SSL_NO_VERIFY], []). %%------------------------------------------------------------------------- @@ -1468,7 +1478,7 @@ remote_socket_close_async(Config) when is_list(Config) -> Options = [{sync, false}], Profile = httpc:default_profile(), {ok, RequestId} = - httpc:request(get, Request, [], Options, Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], Options, Profile), receive {http, {RequestId, {error, socket_closed_remotely}}} -> ok @@ -1536,7 +1546,7 @@ inet_opts(Config) when is_list(Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, Timeout = timer:seconds(1), ConnTimeout = Timeout + timer:seconds(1), - HttpOptions = [{timeout, Timeout}, {connect_timeout, ConnTimeout}], + HttpOptions = [{timeout, Timeout}, {connect_timeout, ConnTimeout}, ?SSL_NO_VERIFY], Options0 = [{socket_opts, [{tos, 87}, {recbuf, 16#FFFF}, {sndbuf, 16#FFFF}]}], @@ -1547,7 +1557,7 @@ inet_opts(Config) when is_list(Config) -> Options1 = [{socket_opts, [{tos, 84}, {recbuf, 32#1FFFF}, {sndbuf, 32#1FFFF}]}], - {ok, {{_,200,_}, [_ | _], ReplyBody1 = [_ | _]}} = httpc:request(get, Request, [], Options1), + {ok, {{_,200,_}, [_ | _], ReplyBody1 = [_ | _]}} = httpc:request(get, Request, [?SSL_NO_VERIFY], Options1), inets_test_lib:check_body(ReplyBody1). %%------------------------------------------------------------------------- @@ -1581,7 +1591,7 @@ timeout_memory_leak(Config) when is_list(Config) -> {error, timeout} -> %% And now we check the size of the handler db Info = httpc:info(), - ct:print("Info: ~p", [Info]), + ct:log("Info: ~p", [Info]), {value, {handlers, Handlers}} = lists:keysearch(handlers, 1, Info), case Handlers of @@ -1774,7 +1784,7 @@ stream_fun_server_close(Config) when is_list(Config) -> {ok, RequestId} = httpc:request(get, Request, [], [{sync, false}, {receiver, Fun}]), receive {RequestId, {error, Reason}} -> - ct:pal("Close ~p", [Reason]), + ct:log("Close ~p", [Reason]), ok after 13000 -> ct:fail(did_not_receive_close) @@ -1876,7 +1886,7 @@ post_with_content_type(Config) when is_list(Config) -> URL = url(group_name(Config), "/delete_no_body.html", Config), %% Simulated server replies 500 if 'Content-Type' header is present {ok, {{_,500,_}, _, _}} = - httpc:request(post, {URL, [], "application/x-www-form-urlencoded", ""}, [], []). + httpc:request(post, {URL, [], "application/x-www-form-urlencoded", ""}, [?SSL_NO_VERIFY], []). %%-------------------------------------------------------------------- request_options() -> @@ -1899,6 +1909,82 @@ def_ssl_opt(_Config) -> {'EXIT', _} = catch httpc:ssl_verify_host_options(other), ok. +%%------------------------------------------------------------------------- +remote_socket_close_parallel() -> + [{doc, + "Verify remote socket closure (related tickets: OTP-18509, OTP-18545," + "ERIERL-937). Transferred data size needs to be significant, so that " + "socket is closed, in the middle of a transfer." + "Note: test case is require good network and CPU - due to that " + " it is not included in all()."}]. +remote_socket_close_parallel(Config0) when is_list(Config0) -> + ClientNumber = 200, + Config = [{iterations, 10} | Config0], + ClientPids = + [spawn(?MODULE, connect, [self(), [{client_id, Id} | Config]]) || + Id <- lists:seq(1, ClientNumber)], + ct:log("Started ~p clients: ~w", [ClientNumber, ClientPids]), + Receive = fun(S) -> + receive + ok -> + ct:log("++ Client finished (~p)", [S]), + ok; + Other -> + ct:fail(Other) + end + end, + [ok = Receive(S) || S <- lists:seq(1, ClientNumber)], + ok. + +connect(From, Config) -> + From ! loop(?config(iterations, Config), + io_lib:format("C~p|", [?config(client_id, Config)]), + Config). + +loop(0, Acc, _Config) -> + ct:log("~n~s|", [Acc]), + ok; +loop(Cnt, Acc, Config) -> + case request(Config) of + {ok, {{_,200,"OK"}, _, _}} -> + case process_info(self(), message_queue_len) of + {message_queue_len,0} -> + loop(Cnt-1, Acc ++ ".", Config); + _ -> + %% queue is expected to be empty + queue_check(), + ct:pal("~n~s|", [Acc ++ "x"]), + fail + end; + {ok, NotOk} -> + ct:pal("200 OK was not received~n~p", [NotOk]), + fail; + Error -> + ct:pal("Error: ~p",[Error]), + fail + end. + +queue_check() -> + receive + {http, {ReqId, {_Result, _Head, Data}}} when is_binary(Data) -> + ct:pal("Unexpected data received: ~p ", + [ReqId]), + queue_check(); + X -> + ct:pal("Caught unexpected something else: ~p",[X]), + queue_check() + after 5000 -> + done + end. + +request(Config) -> + Request = {url(group_name(Config), "/httpc_SUITE/foo", Config), []}, + httpc:request(get, Request, [],[{sync,true}, {body_format,binary}]). + +foo(SID, _Env, _Input) -> + EightyMillionBits = 80000000, %% ~10MB transferred + mod_esi:deliver(SID, [<<0:EightyMillionBits>>]). + %%-------------------------------------------------------------------- %% Internal Functions ------------------------------------------------ %%-------------------------------------------------------------------- @@ -1906,7 +1992,7 @@ stream(ReceiverPid, Receiver, Config) -> Request = {url(group_name(Config), "/dummy.html", Config), []}, Options = [{sync, false}, {receiver, Receiver}], {ok, RequestId} = - httpc:request(get, Request, [], Options), + httpc:request(get, Request, [?SSL_NO_VERIFY], Options), Body = receive {reply, ReceiverPid, {RequestId, {{_, 200, _}, _, B}}} -> @@ -1953,9 +2039,9 @@ stream_deliver(ReplyInfo, Type, ReceiverPid) -> stream_test(Request, To) -> {ok, {{_,200,_}, [_ | _], Body}} = - httpc:request(get, Request, [], []), + httpc:request(get, Request, [?SSL_NO_VERIFY], []), {ok, RequestId} = - httpc:request(get, Request, [], [{sync, false}, To]), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}, To]), StreamedBody = receive @@ -1971,9 +2057,9 @@ stream_test(Request, To) -> not_streamed_test(Request, To) -> {ok, {{_,Code,_}, [_ | _], Body}} = - httpc:request(get, Request, [], [{body_format, binary}]), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{body_format, binary}]), {ok, RequestId} = - httpc:request(get, Request, [], [{body_format, binary}, {sync, false}, To]), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{body_format, binary}, {sync, false}, To]), receive {http, {RequestId, {{_, Code, _}, _Headers, Body}}} -> @@ -1993,12 +2079,13 @@ url(https, End, Config) -> Port = proplists:get_value(port, Config), {ok,Host} = inet:gethostname(), ?TLS_URL_START ++ Host ++ ":" ++ integer_to_list(Port) ++ End; -url(sim_http, End, Config) -> - url(http, End, Config); -url(http_internal, End, Config) -> +url(Group, End, Config) when Group == sim_http; + Group == http_internal; + Group == http_internal_minimum_bytes -> url(http, End, Config); url(sim_https, End, Config) -> url(https, End, Config). + url(http, UserInfo, End, Config) -> Port = proplists:get_value(port, Config), ?URL_START ++ UserInfo ++ integer_to_list(Port) ++ End; @@ -2063,39 +2150,32 @@ server_start(_, HttpdConfig) -> {value, {_, _, Info}} = lists:keysearch(Pid, 2, Serv), proplists:get_value(port, Info). -server_config(http, Config) -> +server_config(base, Config) -> ServerRoot = proplists:get_value(server_root, Config), [{port, 0}, {server_name,"httpc_test"}, {server_root, ServerRoot}, {document_root, proplists:get_value(doc_root, Config)}, - {bind_address, any}, - {ipfamily, inet_version()}, - {mime_type, "text/plain"}, - {script_alias, {"/cgi-bin/", filename:join(ServerRoot, "cgi-bin") ++ "/"}} - ]; -server_config(http_ipv6, Config) -> + {mime_type, "text/plain"}]; +server_config(base_http, Config) -> ServerRoot = proplists:get_value(server_root, Config), - [{port, 0}, - {server_name,"httpc_test"}, - {server_root, ServerRoot}, - {document_root, proplists:get_value(doc_root, Config)}, - {bind_address, {0,0,0,0,0,0,0,1}}, - {ipfamily, inet6}, - {mime_type, "text/plain"}, - {script_alias, {"/cgi-bin/", filename:join(ServerRoot, "cgi-bin") ++ "/"}} - ]; + server_config(base, Config) ++ + [{script_alias, + {"/cgi-bin/", filename:join(ServerRoot, "cgi-bin") ++ "/"}}]; +server_config(http, Config) -> + server_config(base_http, Config) ++ + [{bind_address, any}, + {ipfamily, inet_version()}]; +server_config(http_ipv6, Config) -> + server_config(base_http, Config) ++ + [{bind_address, {0,0,0,0,0,0,0,1}}, + {ipfamily, inet6}]; server_config(http_internal, Config) -> - ServerRoot = proplists:get_value(server_root, Config), - [{port, 0}, - {server_name,"httpc_test"}, - {server_root, ServerRoot}, - {document_root, proplists:get_value(doc_root, Config)}, - {bind_address, any}, - {ipfamily, inet_version()}, - {mime_type, "text/plain"}, - {erl_script_alias, {"", [httpc_SUITE]}} - ]; + server_config(http, Config) ++ + [{erl_script_alias, {"", [httpc_SUITE]}}]; +server_config(http_internal_minimum_bytes, Config) -> + server_config(http_internal, Config) ++ + [{minimum_bytes_per_second, 100}]; server_config(https, Config) -> [{socket_type, {ssl, ssl_config(Config)}} | server_config(http, Config)]; server_config(sim_https, Config) -> @@ -2103,7 +2183,6 @@ server_config(sim_https, Config) -> server_config(http_unix_socket, _Config) -> Socket = ?UNIX_SOCKET, [{unix_socket, Socket}]; - server_config(_, _) -> []. @@ -2156,23 +2235,23 @@ setup_server_dirs(ServerRoot, DocRoot, DataDir) -> keep_alive_requests(Request, Profile) -> {ok, RequestIdA0} = - httpc:request(get, Request, [], [{sync, false}], Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}], Profile), {ok, RequestIdA1} = - httpc:request(get, Request, [], [{sync, false}], Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}], Profile), {ok, RequestIdA2} = - httpc:request(get, Request, [], [{sync, false}], Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}], Profile), receive_replys([RequestIdA0, RequestIdA1, RequestIdA2]), {ok, RequestIdB0} = - httpc:request(get, Request, [], [{sync, false}], Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}], Profile), {ok, RequestIdB1} = - httpc:request(get, Request, [], [{sync, false}], Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}], Profile), {ok, RequestIdB2} = - httpc:request(get, Request, [], [{sync, false}], Profile), + httpc:request(get, Request, [?SSL_NO_VERIFY], [{sync, false}], Profile), ok = httpc:cancel_request(RequestIdB1, Profile), - ct:print("Cancel ~p~n", [RequestIdB1]), + ct:log("Cancel ~p~n", [RequestIdB1]), receive_replys([RequestIdB0, RequestIdB2]). @@ -2340,7 +2419,7 @@ handle_request(Module, Function, Args, Socket) -> end. handle_http_msg({Method, RelUri, _, {_, Headers}, Body}, Socket, _) -> - ct:print("Request: ~p ~p", [Method, RelUri]), + ct:log("Request: ~p ~p", [Method, RelUri]), NextRequest = case RelUri of @@ -2387,9 +2466,9 @@ handle_http_msg({Method, RelUri, _, {_, Headers}, Body}, Socket, _) -> _ when is_list(Msg) orelse is_binary(Msg) -> case Msg of [] -> - ct:print("Empty Msg", []); + ct:log("Empty Msg", []); _ -> - ct:print("Response: ~p", [Msg]), + ct:log("Response: ~p", [Msg]), send(Socket, Msg) end end, @@ -2449,10 +2528,10 @@ content_type_header([_|T]) -> handle_auth("Basic " ++ UserInfo, Challenge, DefaultResponse) -> case string:tokens(base64:decode_to_string(UserInfo), ":") of ["alladin", "sesame"] = Auth -> - ct:print("Auth: ~p~n", [Auth]), + ct:log("Auth: ~p~n", [Auth]), DefaultResponse; Other -> - ct:print("UnAuth: ~p~n", [Other]), + ct:log("UnAuth: ~p~n", [Other]), Challenge end. @@ -2965,7 +3044,7 @@ receive_streamed_body(RequestId, Body) -> receive_streamed_body(RequestId, Body, Pid) -> httpc:stream_next(Pid), - ct:print("~p:receive_streamed_body -> requested next stream ~n", [?MODULE]), + ct:log("~p:receive_streamed_body -> requested next stream ~n", [?MODULE]), receive {http, {RequestId, stream, BinBodyPart}} -> %% Make sure the httpc hasn't sent us the next 'stream' @@ -3021,19 +3100,19 @@ run_clients(NumClients, ServerPort, SeqNumServer) -> fun() -> case httpc:request(Url) of {ok, {{_,200,_}, _, Resp}} -> - ct:print("[~w] 200 response: " + ct:log("[~w] 200 response: " "~p~n", [Id, Resp]), case lists:prefix(Req++"->", Resp) of true -> exit(normal); false -> exit({bad_resp,Req,Resp}) end; {ok, {{_,EC,Reason},_,Resp}} -> - ct:print("[~w] ~w response: " + ct:pal("[~w] ~w response: " "~s~n~s~n", [Id, EC, Reason, Resp]), exit({bad_resp,Req,Resp}); Crap -> - ct:print("[~w] bad response: ~p", + ct:pal("[~w] bad response: ~p", [Id, Crap]), exit({bad_resp, Req, Crap}) end @@ -3111,14 +3190,14 @@ loop_client(N, CSock, SeqNumServer) -> Response = lists:flatten(io_lib:format("~s->resp~3..0w/~2..0w", [ReqNum, RespSeqNum, N])), Txt = lists:flatten(io_lib:format("Slow server (~p) got ~p, answering with ~p", [self(), Req, Response])), - ct:print("~s...~n", [Txt]), + ct:log("~s...~n", [Txt]), slowly_send_response(CSock, Response), case parse_connection_type(Req) of keep_alive -> - ct:print("~s...done~n", [Txt]), + ct:log("~s...done~n", [Txt]), loop_client(N+1, CSock, SeqNumServer); close -> - ct:print("~s...done (closing)~n", [Txt]), + ct:log("~s...done (closing)~n", [Txt]), gen_tcp:close(CSock) end end. @@ -3168,7 +3247,7 @@ otp_8739(Config) when is_list(Config) -> {error, timeout} -> %% And now we check the size of the handler db Info = httpc:info(), - ct:print("Info: ~p", [Info]), + ct:log("Info: ~p", [Info]), {value, {handlers, Handlers}} = lists:keysearch(handlers, 1, Info), case Handlers of @@ -3235,7 +3314,7 @@ receive_stream_n(Ref, N) -> {http, {Ref, stream_start, _}} -> receive_stream_n(Ref, N); {http, {Ref,stream, Data}} -> - ct:pal("Data: ~p", [Data]), + ct:log("Data: ~p", [Data]), receive_stream_n(Ref, N-1) end. |