aboutsummaryrefslogtreecommitdiffstats
path: root/test/rfc7231_SUITE.erl
diff options
context:
space:
mode:
Diffstat (limited to 'test/rfc7231_SUITE.erl')
-rw-r--r--test/rfc7231_SUITE.erl22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/rfc7231_SUITE.erl b/test/rfc7231_SUITE.erl
index f1b3415..9eddf72 100644
--- a/test/rfc7231_SUITE.erl
+++ b/test/rfc7231_SUITE.erl
@@ -41,7 +41,8 @@ init_dispatch(_) ->
{"*", asterisk_h, []},
{"/", hello_h, []},
{"/echo/:key", echo_h, []},
- {"/resp/:key[/:arg]", resp_h, []}
+ {"/resp/:key[/:arg]", resp_h, []},
+ {"/ws", ws_init_h, []}
]}]).
%% @todo The documentation should list what methods, headers and status codes
@@ -514,6 +515,25 @@ status_code_426(Config) ->
{response, _, 426, _} = gun:await(ConnPid, Ref),
ok.
+status_code_426_upgrade_header(Config) ->
+ case config(protocol, Config) of
+ http ->
+ do_status_code_426_upgrade_header(Config);
+ http2 ->
+ doc("HTTP/2 does not support the HTTP/1.1 Upgrade mechanism.")
+ end.
+
+do_status_code_426_upgrade_header(Config) ->
+ doc("A 426 response must include a upgrade header. (RFC7231 6.5.15)"),
+ ConnPid = gun_open(Config),
+ Ref = gun:get(ConnPid, "/ws?ok", [
+ {<<"accept-encoding">>, <<"gzip">>}
+ ]),
+ {response, _, 426, Headers} = gun:await(ConnPid, Ref),
+ {_, <<"upgrade">>} = lists:keyfind(<<"connection">>, 1, Headers),
+ {_, <<"websocket">>} = lists:keyfind(<<"upgrade">>, 1, Headers),
+ ok.
+
status_code_500(Config) ->
doc("The 500 Internal Server Error status code can be sent. (RFC7231 6.6.1)"),
ConnPid = gun_open(Config),