aboutsummaryrefslogtreecommitdiffstats
path: root/test/rfc7230_SUITE.erl
diff options
context:
space:
mode:
authorLoïc Hoguin <[email protected]>2017-01-03 18:07:39 +0100
committerLoïc Hoguin <[email protected]>2017-01-03 18:07:39 +0100
commit42c95b1584c245d73e6ddc052a922c8e7c68dee2 (patch)
tree88919e0f88c44da8da20c378c0349f087569f37c /test/rfc7230_SUITE.erl
parentf59c29dff02b1b79652e93dec76a5a26f207e628 (diff)
downloadcowboy-42c95b1584c245d73e6ddc052a922c8e7c68dee2.tar.gz
cowboy-42c95b1584c245d73e6ddc052a922c8e7c68dee2.tar.bz2
cowboy-42c95b1584c245d73e6ddc052a922c8e7c68dee2.zip
Rewrite the tests for header name/value limits
Putting them in the correct test suite, with the proper documentation etc.
Diffstat (limited to 'test/rfc7230_SUITE.erl')
-rw-r--r--test/rfc7230_SUITE.erl41
1 files changed, 27 insertions, 14 deletions
diff --git a/test/rfc7230_SUITE.erl b/test/rfc7230_SUITE.erl
index 22d2c37..5199795 100644
--- a/test/rfc7230_SUITE.erl
+++ b/test/rfc7230_SUITE.erl
@@ -726,20 +726,33 @@ reject_invalid_whitespace_after_version(Config) ->
%Messages that contain whitespace between the header name and
%colon must be rejected with a 400 status code and the closing
%of the connection. (RFC7230 3.2.4)
-%
-%limit_header_name(Config) ->
-%The header name must be subject to a configurable limit. A
-%good default is 50 characters, well above the longest registered
-%header. Such a request must be rejected with a 431 status code
-%and the closing of the connection. (RFC7230 3.2.5, RFC6585 5, IANA Message Headers registry)
-%
-%limit_header_value(Config) ->
-%The header value and the optional whitespace around it must be
-%subject to a configurable limit. There is no recommendations
-%for the default. 4096 characters is known to work well. Such
-%a request must be rejected with a 431 status code and the closing
-%of the connection. (RFC7230 3.2.5, RFC6585 5)
-%
+
+limit_header_name(Config) ->
+ doc("The header name must be subject to a configurable limit. A "
+ "good default is 50 characters, well above the longest registered "
+ "header. Such a request must be rejected with a 431 status code "
+ "and the closing of the connection. "
+ "(RFC7230 3.2.5, RFC6585 5, IANA Message Headers registry)"),
+ #{code := 431, client := Client} = do_raw(Config, [
+ "GET / HTTP/1.1\r\n"
+ "Host: localhost\r\n",
+ binary:copy(<<$a>>, 32768), ": bad\r\n"
+ "\r\n"]),
+ {error, closed} = raw_recv(Client, 0, 1000).
+
+limit_header_value(Config) ->
+ doc("The header value and the optional whitespace around it must be "
+ "subject to a configurable limit. There is no recommendations "
+ "for the default. 4096 characters is known to work well. Such "
+ "a request must be rejected with a 431 status code and the closing "
+ "of the connection. (RFC7230 3.2.5, RFC6585 5)"),
+ #{code := 431, client := Client} = do_raw(Config, [
+ "GET / HTTP/1.1\r\n"
+ "Host: localhost\r\n"
+ "bad: ", binary:copy(<<$a>>, 32768), "\r\n"
+ "\r\n"]),
+ {error, closed} = raw_recv(Client, 0, 1000).
+
%drop_whitespace_before_header_value(Config) ->
%drop_whitespace_after_header_value(Config) ->
%Optional whitespace before and after the header value is not