diff options
author | Micael Karlberg <[email protected]> | 2011-12-01 12:27:45 +0100 |
---|---|---|
committer | Micael Karlberg <[email protected]> | 2011-12-01 12:27:45 +0100 |
commit | 38bb19c5c4bdeeb4d54a62d687d9371eb7976c3f (patch) | |
tree | 230fc0054d2394885a2512017649b769b8ea26ad /lib/inets/test/httpd_time_test.erl | |
parent | 3cf5f67f3545cc82147706cc83febc242f6e469a (diff) | |
parent | 5df28c6c7d3c5948ff02ae197f1f11eff96cc68d (diff) | |
download | otp-38bb19c5c4bdeeb4d54a62d687d9371eb7976c3f.tar.gz otp-38bb19c5c4bdeeb4d54a62d687d9371eb7976c3f.tar.bz2 otp-38bb19c5c4bdeeb4d54a62d687d9371eb7976c3f.zip |
Merge branch 'bmk/inets/inets58_integration2'
Diffstat (limited to 'lib/inets/test/httpd_time_test.erl')
-rw-r--r-- | lib/inets/test/httpd_time_test.erl | 73 |
1 files changed, 52 insertions, 21 deletions
diff --git a/lib/inets/test/httpd_time_test.erl b/lib/inets/test/httpd_time_test.erl index c54674be36..4e5f332122 100644 --- a/lib/inets/test/httpd_time_test.erl +++ b/lib/inets/test/httpd_time_test.erl @@ -333,51 +333,82 @@ poll(Error, _SocketType, _URI, _ExpRes) -> exit({failed_creating_socket, Error}). await_poll_response(ok, SocketType, Socket, ExpStatusCode) -> + await_poll_response2(SocketType, Socket, ExpStatusCode, []); +await_poll_response(Error, _SocketType, _Socket, _ExpStatusCode) -> + exit(Error). + +%% The reply *can* be split into two messages (this is a +%% result of OTP-9757 for ssl), so we read them all until +%% the sockets closes, then we analyze the response. +await_poll_response2(SocketType, Socket, ExpStatusCode, Data) -> receive %% SSL receives - {ssl, Socket, Data} -> - validate(ExpStatusCode, SocketType, Socket, Data); - {ssl_closed, Socket} -> - exit(connection_closed); + {ssl, Socket, NewData} -> + d("await_poll_response2 -> " + "received part (~w bytes) of the response", [sz(NewData)]), + await_poll_response2(SocketType, Socket, ExpStatusCode, + [NewData | Data]); + {ssl_closed, Socket} -> + %% We are done or we failed + d("await_poll_response2 -> " + "we are done after receiving ~w bytes data", [sz(Data)]), + validate(ExpStatusCode, SocketType, Socket, + lists:flatten(lists:reverse(Data))); {ssl_error, Socket, Error} -> exit({connection_error, Error}); %% TCP receives - {tcp, Socket, Response} -> - validate(ExpStatusCode, SocketType, Socket, Response); + {tcp, Socket, NewData} -> + d("await_poll_response2 -> " + "received part (~w bytes) of the response", [sz(NewData)]), + await_poll_response2(SocketType, Socket, ExpStatusCode, + [NewData | Data]); {tcp_closed, Socket} -> - exit(connection_closed); + %% We are done or we failed + d("await_poll_response2 -> " + "we are done after receiving ~w bytes data", [sz(Data)]), + validate(ExpStatusCode, SocketType, Socket, + lists:flatten(lists:reverse(Data))); {tcp_error, Socket, Error} -> exit({connection_error, Error}) after 10000 -> - exit(response_timed_out) - end; -await_poll_response(Error, _SocketType, _Socket, _ExpStatusCode) -> - exit(Error). - + d("we timed out while waiting for response, " + "validate whatever we got so far"), + validate(ExpStatusCode, SocketType, Socket, + lists:flatten(lists:reverse(Data))) + %% exit(response_timed_out) + end. -validate(ExpStatusCode, SocketType, Socket, Response) -> - Sz = sz(Response), - trash_the_rest(Socket, Sz), - inets_test_lib:close(SocketType, Socket), +validate(ExpStatusCode, _SocketType, _Socket, Response) -> + %% Sz = sz(Response), + %% trash_the_rest(Socket, Sz), + %% inets_test_lib:close(SocketType, Socket), case inets_regexp:split(Response," ") of - {ok,["HTTP/1.0", ExpStatusCode|_]} -> + {ok, ["HTTP/1.0", ExpStatusCode|_]} -> ok; - {ok,["HTTP/1.0", StatusCode|_]} -> + {ok, ["HTTP/1.0", StatusCode|_]} -> error_msg("Unexpected status code: ~p (~s). " "Expected status code: ~p (~s)", [StatusCode, status_to_message(StatusCode), ExpStatusCode, status_to_message(ExpStatusCode)]), exit({unexpected_response_code, StatusCode, ExpStatusCode}); - {ok,["HTTP/1.1", ExpStatusCode|_]} -> + {ok, ["HTTP/1.1", ExpStatusCode|_]} -> ok; - {ok,["HTTP/1.1", StatusCode|_]} -> + {ok, ["HTTP/1.1", StatusCode|_]} -> error_msg("Unexpected status code: ~p (~s). " "Expected status code: ~p (~s)", [StatusCode, status_to_message(StatusCode), ExpStatusCode, status_to_message(ExpStatusCode)]), - exit({unexpected_response_code, StatusCode, ExpStatusCode}) + exit({unexpected_response_code, StatusCode, ExpStatusCode}); + {ok, Unexpected} -> + error_msg("Unexpected response split: ~p (~s)", + [Unexpected, Response]), + exit({unexpected_response, Unexpected, Response}); + {error, Reason} -> + error_msg("Failed processing response: ~p (~s)", + [Reason, Response]), + exit({failed_response_processing, Reason, Response}) end. |