diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/http_SUITE.erl | 20 | ||||
-rw-r--r-- | test/websocket_handler.erl | 3 |
2 files changed, 14 insertions, 9 deletions
diff --git a/test/http_SUITE.erl b/test/http_SUITE.erl index 2208256..02d6210 100644 --- a/test/http_SUITE.erl +++ b/test/http_SUITE.erl @@ -119,7 +119,7 @@ headers_dupe(Config) -> {ok, Data} = gen_tcp:recv(Socket, 0, 6000), {_Start, _Length} = binary:match(Data, <<"Connection: close">>), nomatch = binary:match(Data, <<"Connection: keep-alive">>), - ok = gen_tcp:close(Socket). + {error, closed} = gen_tcp:recv(Socket, 0, 1000). headers_huge(Config) -> Cookie = lists:flatten(["whatever_man_biiiiiiiiiiiig_cookie_me_want_77=" @@ -199,10 +199,14 @@ raw_req(Packet, Config) -> {ok, Socket} = gen_tcp:connect("localhost", Port, [binary, {active, false}, {packet, raw}]), ok = gen_tcp:send(Socket, Packet), - {ok, << "HTTP/1.1 ", Str:24/bits, _Rest/bits >>} - = gen_tcp:recv(Socket, 0, 6000), + Res = case gen_tcp:recv(Socket, 0, 6000) of + {ok, << "HTTP/1.1 ", Str:24/bits, _Rest/bits >>} -> + list_to_integer(binary_to_list(Str)); + {error, Reason} -> + Reason + end, gen_tcp:close(Socket), - {Packet, list_to_integer(binary_to_list(Str))}. + {Packet, Res}. raw(Config) -> Tests = [ @@ -211,10 +215,10 @@ raw(Config) -> {"Garbage\r\n\r\n", 400}, {"\r\n\r\n\r\n\r\n\r\n\r\n", 400}, {"GET / HTTP/1.1\r\nHost: dev-extend.eu\r\n\r\n", 400}, - {"", 408}, - {"\r\n", 408}, - {"\r\n\r\n", 408}, - {"GET / HTTP/1.1", 408}, + {"", closed}, + {"\r\n", closed}, + {"\r\n\r\n", closed}, + {"GET / HTTP/1.1", closed}, {"GET / HTTP/1.1\r\n", 408}, {"GET / HTTP/1.1\r\nHost: localhost", 408}, {"GET / HTTP/1.1\r\nHost: localhost\r\n", 408}, diff --git a/test/websocket_handler.erl b/test/websocket_handler.erl index 4ba2a67..0cfc8f3 100644 --- a/test/websocket_handler.erl +++ b/test/websocket_handler.erl @@ -18,7 +18,8 @@ terminate(_Req, _State) -> websocket_init(_TransportName, Req, _Opts) -> erlang:start_timer(1000, self(), <<"websocket_init">>), - {ok, Req, undefined}. + Req2 = cowboy_http_req:compact(Req), + {ok, Req2, undefined}. websocket_handle({text, Data}, Req, State) -> {reply, {text, Data}, Req, State}; |