diff options
author | Johannes Weißl <[email protected]> | 2015-11-14 16:29:13 +0100 |
---|---|---|
committer | Johannes Weißl <[email protected]> | 2015-11-15 09:09:51 +0100 |
commit | 25c9d0c38d659cc00db461d760f66369e9024c54 (patch) | |
tree | 13e07712695bb4f7466da7ba5332aa8b7a537598 /lib/inets/test/httpc_SUITE.erl | |
parent | 0db6272323fd662cb43f5bb4d24f01daa8a6647d (diff) | |
download | otp-25c9d0c38d659cc00db461d760f66369e9024c54.tar.gz otp-25c9d0c38d659cc00db461d760f66369e9024c54.tar.bz2 otp-25c9d0c38d659cc00db461d760f66369e9024c54.zip |
inets: Terminate really gracefully on bad chunk
Without this fix, httpc:request/1 crashes the httpc_handler when an
invalid chunked length header is encountered (since 77acb47):
=ERROR REPORT==== 14-Nov-2015::17:19:30 ===
** Generic server <0.651.0> terminating
** Last message in was {tcp,#Port<0.5714>,
<<"HTTP/1.1 200 ok\r\nTransfer-Encoding:chunked\r\n\r\nåäö\r\n">>}
** When Server state == {state,
[...]
** Reason for termination ==
** {bad_return_value,{error,{chunk_size,"åäö"}}}
Diffstat (limited to 'lib/inets/test/httpc_SUITE.erl')
-rw-r--r-- | lib/inets/test/httpc_SUITE.erl | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index 989563cdbc..c6c59ab1af 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -106,6 +106,7 @@ only_simulated() -> bad_response, internal_server_error, invalid_http, + invalid_chunk_size, headers_dummy, headers_with_obs_fold, empty_response_header, @@ -765,6 +766,22 @@ invalid_http(Config) when is_list(Config) -> ct:print("Parse error: ~p ~n", [Reason]). %%------------------------------------------------------------------------- + +invalid_chunk_size(doc) -> + ["Test parse error of HTTP chunk size"]; +invalid_chunk_size(suite) -> + []; +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, []}, [], []), + + ct:print("Parse error: ~p ~n", [Reason]). + +%%------------------------------------------------------------------------- + emulate_lower_versions(doc) -> [{doc, "Perform request as 0.9 and 1.0 clients."}]; emulate_lower_versions(Config) when is_list(Config) -> @@ -1876,6 +1893,10 @@ handle_uri(_,"/invalid_http.html",_,_,_,_) -> "HTTP/1.1 301\r\nDate:Sun, 09 Dec 2007 13:04:18 GMT\r\n" ++ "Transfer-Encoding:chunked\r\n\r\n"; +handle_uri(_,"/invalid_chunk_size.html",_,_,_,_) -> + "HTTP/1.1 200 ok\r\n" ++ + "Transfer-Encoding:chunked\r\n\r\nåäö\r\n"; + handle_uri(_,"/missing_reason_phrase.html",_,_,_,_) -> "HTTP/1.1 200\r\n" ++ "Content-Length: 32\r\n\r\n" |