diff options
author | Kirilll Zaborsky <[email protected]> | 2014-05-16 17:23:43 +0400 |
---|---|---|
committer | Kirilll Zaborsky <[email protected]> | 2014-05-16 23:05:44 +0400 |
commit | a027c412d7cb6cf6ad00422b7dfd8534bf8c212b (patch) | |
tree | 79c043216c409ee30b92ef3196c66b0b62f0e416 /lib/inets/test/httpc_SUITE.erl | |
parent | cf3c624dc66a42d9d7bec904d8be3b8c4cce38ae (diff) | |
download | otp-a027c412d7cb6cf6ad00422b7dfd8534bf8c212b.tar.gz otp-a027c412d7cb6cf6ad00422b7dfd8534bf8c212b.tar.bz2 otp-a027c412d7cb6cf6ad00422b7dfd8534bf8c212b.zip |
inets: Fix HTTP 1.0 body end on closed connection
Receiving HTTP response with no Content-length header and
with body ending on closed connection should give the complete
response body contents up to the last byte received.
Diffstat (limited to 'lib/inets/test/httpc_SUITE.erl')
-rw-r--r-- | lib/inets/test/httpc_SUITE.erl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/inets/test/httpc_SUITE.erl b/lib/inets/test/httpc_SUITE.erl index 1e3710288b..20b624aced 100644 --- a/lib/inets/test/httpc_SUITE.erl +++ b/lib/inets/test/httpc_SUITE.erl @@ -94,6 +94,7 @@ only_simulated() -> trace, stream_once, stream_single_chunk, + stream_no_length, no_content_204, tolerate_missing_CR, userinfo, @@ -386,6 +387,15 @@ stream_single_chunk() -> stream_single_chunk(Config) when is_list(Config) -> Request = {url(group_name(Config), "/single_chunk.html", Config), []}, stream_test(Request, {stream, self}). +%%------------------------------------------------------------------------- +stream_no_length() -> + [{doc, "Test the option stream for asynchrony requests with HTTP 1.0 " + "body end on closed connection" }]. +stream_no_length(Config) when is_list(Config) -> + Request1 = {url(group_name(Config), "/http_1_0_no_length_single.html", Config), []}, + stream_test(Request1, {stream, self}), + Request2 = {url(group_name(Config), "/http_1_0_no_length_multiple.html", Config), []}, + stream_test(Request2, {stream, self}). %%------------------------------------------------------------------------- @@ -1651,6 +1661,22 @@ handle_uri(_,"/single_chunk.html",_,_,Socket,_) -> http_chunk:encode_last(), send(Socket, Chunk); +handle_uri(_,"/http_1_0_no_length_single.html",_,_,Socket,_) -> + Body = "HTTP/1.0 200 ok\r\n" + "Content-type:text/plain\r\n\r\n" + "single packet", + send(Socket, Body), + close(Socket); + +handle_uri(_,"/http_1_0_no_length_multiple.html",_,_,Socket,_) -> + Head = "HTTP/1.0 200 ok\r\n" + "Content-type:text/plain\r\n\r\n" + "multiple packets, ", + send(Socket, Head), + %% long body to make sure it will be sent in multiple tcp packets + send(Socket, string:copies("other multiple packets ", 200)), + close(Socket); + handle_uri(_,"/once.html",_,_,Socket,_) -> Head = "HTTP/1.1 200 ok\r\n" ++ "Content-Length:32\r\n\r\n", |