aboutsummaryrefslogtreecommitdiffstats
path: root/test/rfc7231_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-12-06 14:05:30 +0100
committerLoïc Hoguin <[email protected]>2017-12-06 14:05:30 +0100
commitbc39b433bb20c44690b75bf28539983517002268 (patch)
treec335c45a92f535d2100d04f8a9df8899f459b013 /test/rfc7231_SUITE.erl
parent2eb3e3f994e464ae2678f7c3d321213e5eec9ad4 (diff)
downloadcowboy-bc39b433bb20c44690b75bf28539983517002268.tar.gz
cowboy-bc39b433bb20c44690b75bf28539983517002268.tar.bz2
cowboy-bc39b433bb20c44690b75bf28539983517002268.zip
Properly handle OPTIONS * requests
Support for these was broken during the development of Cowboy 2.0. It is now fixed and better handled than it ever was.
Diffstat (limited to 'test/rfc7231_SUITE.erl')
-rw-r--r--test/rfc7231_SUITE.erl24
1 files changed, 22 insertions, 2 deletions
diff --git a/test/rfc7231_SUITE.erl b/test/rfc7231_SUITE.erl
index feb53b9..e0940ab 100644
--- a/test/rfc7231_SUITE.erl
+++ b/test/rfc7231_SUITE.erl
@@ -34,6 +34,7 @@ end_per_group(Name, _) ->
init_dispatch(_) ->
cowboy_router:compile([{"[...]", [
+ {"*", asterisk_h, []},
{"/", hello_h, []},
{"/echo/:key", echo_h, []},
{"/resp/:key[/:arg]", resp_h, []}
@@ -148,8 +149,27 @@ method_options(Config) ->
{ok, <<"OPTIONS">>} = gun:await_body(ConnPid, Ref),
ok.
-%method_options_asterisk(Config) ->
-%method_options_content_length_0(Config) ->
+method_options_asterisk(Config) ->
+ doc("The OPTIONS method is accepted with an asterisk. (RFC7231 4.3.7)"),
+ ConnPid = gun_open(Config),
+ Ref = gun:options(ConnPid, "*", [
+ {<<"accept-encoding">>, <<"gzip">>},
+ {<<"x-echo">>, <<"method">>}
+ ]),
+ {response, nofin, 200, _} = gun:await(ConnPid, Ref),
+ {ok, <<"OPTIONS">>} = gun:await_body(ConnPid, Ref),
+ ok.
+
+method_options_content_length_0(Config) ->
+ doc("The OPTIONS method must set the content-length header "
+ "to 0 when no body is returned. (RFC7231 4.3.7)"),
+ ConnPid = gun_open(Config),
+ Ref = gun:options(ConnPid, "*", [
+ {<<"accept-encoding">>, <<"gzip">>}
+ ]),
+ {response, fin, 200, Headers} = gun:await(ConnPid, Ref),
+ {_, <<"0">>} = lists:keyfind(<<"content-length">>, 1, Headers),
+ ok.
method_trace(Config) ->
doc("The TRACE method is currently not implemented. (RFC7231 4.3.8)"),