0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-14 12:20:24 +00:00

Add more rfc7231 tests

This commit is contained in:
Loïc Hoguin 2017-12-06 14:38:27 +01:00
parent bc39b433bb
commit 1f4c1e2c67
No known key found for this signature in database
GPG key ID: 8A9DF795F6FED764
2 changed files with 30 additions and 5 deletions

View file

@ -112,7 +112,8 @@ gun_open(Config, Opts) ->
retry => 0, retry => 0,
transport => config(type, Config), transport => config(type, Config),
transport_opts => proplists:get_value(transport_opts, Config, []), transport_opts => proplists:get_value(transport_opts, Config, []),
protocols => [config(protocol, Config)] protocols => [config(protocol, Config)],
http_opts => proplists:get_value(http_opts, Config, #{})
}), }),
ConnPid. ConnPid.

View file

@ -186,6 +186,34 @@ method_trace(Config) ->
%% Status codes. %% Status codes.
http10_status_code_100(Config) ->
case config(protocol, Config) of
http ->
doc("The 100 Continue status code must not "
"be sent to HTTP/1.0 endpoints. (RFC7231 6.2)"),
do_http10_status_code_1xx(100, Config);
http2 ->
status_code_100(Config)
end.
http10_status_code_101(Config) ->
case config(protocol, Config) of
http ->
doc("The 101 Switching Protocols status code must not "
"be sent to HTTP/1.0 endpoints. (RFC7231 6.2)"),
do_http10_status_code_1xx(101, Config);
http2 ->
status_code_101(Config)
end.
do_http10_status_code_1xx(StatusCode, Config) ->
ConnPid = gun_open([{http_opts, #{version => 'HTTP/1.0'}}|Config]),
Ref = gun:get(ConnPid, "/resp/inform2/" ++ integer_to_list(StatusCode), [
{<<"accept-encoding">>, <<"gzip">>}
]),
{response, _, 200, _} = gun:await(ConnPid, Ref),
ok.
status_code_100(Config) -> status_code_100(Config) ->
doc("The 100 Continue status code can be sent. (RFC7231 6.2.1)"), doc("The 100 Continue status code can be sent. (RFC7231 6.2.1)"),
ConnPid = gun_open(Config), ConnPid = gun_open(Config),
@ -195,8 +223,6 @@ status_code_100(Config) ->
{inform, 100, []} = gun:await(ConnPid, Ref), {inform, 100, []} = gun:await(ConnPid, Ref),
ok. ok.
%http10_status_code_100(Config) ->
status_code_101(Config) -> status_code_101(Config) ->
doc("The 101 Switching Protocols status code can be sent. (RFC7231 6.2.2)"), doc("The 101 Switching Protocols status code can be sent. (RFC7231 6.2.2)"),
ConnPid = gun_open(Config), ConnPid = gun_open(Config),
@ -206,8 +232,6 @@ status_code_101(Config) ->
{inform, 101, []} = gun:await(ConnPid, Ref), {inform, 101, []} = gun:await(ConnPid, Ref),
ok. ok.
%http10_status_code_100(Config) ->
status_code_200(Config) -> status_code_200(Config) ->
doc("The 200 OK status code can be sent. (RFC7231 6.3.1)"), doc("The 200 OK status code can be sent. (RFC7231 6.3.1)"),
ConnPid = gun_open(Config), ConnPid = gun_open(Config),