diff options
author | Péter Dimitrov <[email protected]> | 2018-08-27 16:18:18 +0200 |
---|---|---|
committer | Péter Dimitrov <[email protected]> | 2018-08-27 16:18:18 +0200 |
commit | 7db7a1caeeee21682f37cfa95f9f026074e03ccf (patch) | |
tree | e47255259cece7ba59140f56dbe7aa2aee45bfaa /lib/inets/test/httpd_SUITE.erl | |
parent | b47fa83ff514feafa3debe841f2697c29fa2ca49 (diff) | |
parent | ab8faff46daf24db6f20dc2a307cf68d53034450 (diff) | |
download | otp-7db7a1caeeee21682f37cfa95f9f026074e03ccf.tar.gz otp-7db7a1caeeee21682f37cfa95f9f026074e03ccf.tar.bz2 otp-7db7a1caeeee21682f37cfa95f9f026074e03ccf.zip |
Merge branch 'maint-20' into maint
* maint-20:
inets: Prepare for release
inets: Robust handling of 204, 304, 1xx responses
inets: Do not use chunked encoding with 1xx, 204, 304
Change-Id: Ia88eb1d217b46fb01b1d7544d9ef34788c87abbd
Diffstat (limited to 'lib/inets/test/httpd_SUITE.erl')
-rw-r--r-- | lib/inets/test/httpd_SUITE.erl | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/lib/inets/test/httpd_SUITE.erl b/lib/inets/test/httpd_SUITE.erl index 9777c9b68e..5b6740fba3 100644 --- a/lib/inets/test/httpd_SUITE.erl +++ b/lib/inets/test/httpd_SUITE.erl @@ -120,7 +120,7 @@ groups() -> disturbing_0_9, reload_config_file ]}, - {post, [], [chunked_post, chunked_chunked_encoded_post]}, + {post, [], [chunked_post, chunked_chunked_encoded_post, post_204]}, {basic_auth, [], [basic_auth_1_1, basic_auth_1_0, basic_auth_0_9]}, {auth_api, [], [auth_api_1_1, auth_api_1_0, auth_api_0_9 ]}, @@ -753,6 +753,42 @@ chunked_chunked_encoded_post(Config) when is_list(Config) -> [{http_version, "HTTP/1.1"} | Config], [{statuscode, 200}]). +%%------------------------------------------------------------------------- +post_204() -> + [{doc,"Test that 204 responses are not chunk encoded"}]. +post_204(Config) -> + Host = proplists:get_value(host, Config), + Port = proplists:get_value(port, Config), + SockType = proplists:get_value(type, Config), + TranspOpts = transport_opts(SockType, Config), + Request = "POST /cgi-bin/erl/httpd_example:post_204 ", + + try inets_test_lib:connect_bin(SockType, Host, Port, TranspOpts) of + {ok, Socket} -> + RequestStr = http_request(Request, "HTTP/1.1", Host), + ok = inets_test_lib:send(SockType, Socket, RequestStr), + receive + {tcp, Socket, Data} -> + case binary:match(Data, <<"chunked">>,[]) of + nomatch -> + ok; + {_, _} -> + ct:fail("Chunked encoding detected.") + end + after 2000 -> + ct:fail(connection_timed_out) + end; + ConnectError -> + ct:fail({connect_error, ConnectError, + [SockType, Host, Port, TranspOpts]}) + catch + T:E -> + ct:fail({connect_failure, + [{type, T}, + {error, E}, + {stacktrace, erlang:get_stacktrace()}, + {args, [SockType, Host, Port, TranspOpts]}]}) + end. %%------------------------------------------------------------------------- htaccess_1_1(Config) when is_list(Config) -> |