aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2012-03-13 03:00:05 +0100
committerLoïc Hoguin <[email protected]>2012-03-13 03:00:05 +0100
commit36a6823e50e36c201df6c7a88a4c77cdaac7f2e6 (patch)
treebd8f0c48615616f7146d94496bb466d0e917f638 /test
parente87f51e542a9ee5bdcadd5841731b32210732e08 (diff)
downloadcowboy-36a6823e50e36c201df6c7a88a4c77cdaac7f2e6.tar.gz
cowboy-36a6823e50e36c201df6c7a88a4c77cdaac7f2e6.tar.bz2
cowboy-36a6823e50e36c201df6c7a88a4c77cdaac7f2e6.zip
Do not send chunked Transfer-Encoding replies for HTTP/1.0
Fixes compatibility issue #140 reported by @majek.
Diffstat (limited to 'test')
-rw-r--r--test/http_SUITE.erl17
1 files changed, 15 insertions, 2 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl
index 72892eb..8237750 100644
--- a/test/http_SUITE.erl
+++ b/test/http_SUITE.erl
@@ -28,7 +28,7 @@
-export([http_200/1, http_404/1, handler_errors/1,
file_200/1, file_403/1, dir_403/1, file_404/1,
file_400/1]). %% http and https.
--export([http_10_hostless/1]). %% misc.
+-export([http_10_hostless/1, http_10_chunkless/1]). %% misc.
-export([rest_simple/1, rest_keepalive/1, rest_keepalive_post/1,
rest_nodelete/1, rest_resource_etags/1]). %% rest.
@@ -47,7 +47,7 @@ groups() ->
static_mimetypes_function, static_attribute_etag,
static_function_etag, multipart] ++ BaseTests},
{https, [], BaseTests},
- {misc, [], [http_10_hostless]},
+ {misc, [], [http_10_hostless, http_10_chunkless]},
{rest, [], [rest_simple, rest_keepalive, rest_keepalive_post,
rest_nodelete, rest_resource_etags]}].
@@ -89,6 +89,7 @@ init_per_group(misc, Config) ->
{ok,_} = cowboy:start_listener(misc, 100,
cowboy_tcp_transport, [{port, Port}],
cowboy_http_protocol, [{dispatch, [{'_', [
+ {[<<"chunked_response">>], chunked_handler, []},
{[], http_handler, []}
]}]}]),
[{port, Port}|Config];
@@ -562,12 +563,24 @@ file_400(Config) ->
httpc:request(build_url("/static/%2e", Config)),
{ok, {{"HTTP/1.1", 400, "Bad Request"}, _Headers2, _Body2}} =
httpc:request(build_url("/static/%2e%2e", Config)).
+
%% misc.
http_10_hostless(Config) ->
Packet = "GET / HTTP/1.0\r\n\r\n",
{Packet, 200} = raw_req(Packet, Config).
+http_10_chunkless(Config) ->
+ {port, Port} = lists:keyfind(port, 1, Config),
+ {ok, Socket} = gen_tcp:connect("localhost", Port,
+ [binary, {active, false}, {packet, raw}]),
+ Packet = "GET /chunked_response HTTP/1.0\r\nContent-Length: 0\r\n\r\n",
+ ok = gen_tcp:send(Socket, Packet),
+ {ok, Data} = gen_tcp:recv(Socket, 0, 6000),
+ nomatch = binary:match(Data, <<"Transfer-Encoding">>),
+ {_, _} = binary:match(Data, <<"chunked_handler\r\nworks fine!">>),
+ ok = gen_tcp:close(Socket).
+
%% rest.
rest_simple(Config) ->