aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/handlers/resp_h.erl15
-rw-r--r--test/rfc7230_SUITE.erl28
2 files changed, 28 insertions, 15 deletions
diff --git a/test/handlers/resp_h.erl b/test/handlers/resp_h.erl
index d43152e..8031d0e 100644
--- a/test/handlers/resp_h.erl
+++ b/test/handlers/resp_h.erl
@@ -181,6 +181,12 @@ do(<<"reply4">>, Req0, Opts) ->
<<"error">> ->
ct_helper:ignore(erlang, iolist_size, 1),
cowboy_req:reply(200, #{}, ok, Req0);
+ <<"204body">> ->
+ ct_helper:ignore(cowboy_req, reply, 4),
+ cowboy_req:reply(204, #{}, <<"OK">>, Req0);
+ <<"304body">> ->
+ ct_helper:ignore(cowboy_req, reply, 4),
+ cowboy_req:reply(304, #{}, <<"OK">>, Req0);
Status ->
cowboy_req:reply(binary_to_integer(Status), #{}, <<"OK">>, Req0)
end,
@@ -199,8 +205,15 @@ do(<<"stream_reply2">>, Req0, Opts) ->
<<"204">> ->
Req = cowboy_req:stream_reply(204, Req0),
{ok, Req, Opts};
- <<"304">> ->
+ <<"204body">> ->
+ ct_helper:ignore(cowboy_req, stream_body, 3),
+ Req = cowboy_req:stream_reply(204, Req0),
+ stream_body(Req),
+ {ok, Req, Opts};
+ <<"304body">> ->
+ ct_helper:ignore(cowboy_req, stream_body, 3),
Req = cowboy_req:stream_reply(304, Req0),
+ stream_body(Req),
{ok, Req, Opts};
Status ->
Req = cowboy_req:stream_reply(binary_to_integer(Status), Req0),
diff --git a/test/rfc7230_SUITE.erl b/test/rfc7230_SUITE.erl
index e110441..9846a0f 100644
--- a/test/rfc7230_SUITE.erl
+++ b/test/rfc7230_SUITE.erl
@@ -1886,22 +1886,22 @@ no_body_in_head_response(Config) ->
%1xx responses never include a message body. (RFC7230 3.3)
no_body_in_204_response(Config) ->
- doc("204 responses never include a message body. (RFC7230 3.3)"),
+ doc("204 responses never include a message body. Cowboy produces "
+ "a 500 error response when attempting to do so. (RFC7230 3.3)"),
Client = raw_open(Config),
ok = raw_send(Client, [
- "GET /resp/reply2/204 HTTP/1.1\r\n"
+ "GET /resp/reply4/204body HTTP/1.1\r\n"
"Host: localhost\r\n"
"\r\n"]),
- {_, 204, _, Rest} = cow_http:parse_status_line(raw_recv_head(Client)),
- {_, <<>>} = cow_http:parse_headers(Rest),
- {error, timeout} = raw_recv(Client, 1, 1000),
+ {_, 500, _, _} = cow_http:parse_status_line(raw_recv_head(Client)),
ok.
no_body_in_204_response_stream(Config) ->
- doc("204 responses never include a message body. (RFC7230 3.3)"),
+ doc("204 responses never include a message body. Attempting to "
+ "stream the body produces a crash on the server-side. (RFC7230 3.3)"),
Client = raw_open(Config),
ok = raw_send(Client, [
- "GET /resp/stream_reply2/204 HTTP/1.1\r\n"
+ "GET /resp/stream_reply2/204body HTTP/1.1\r\n"
"Host: localhost\r\n"
"\r\n"]),
{_, 204, _, Rest} = cow_http:parse_status_line(raw_recv_head(Client)),
@@ -1910,22 +1910,22 @@ no_body_in_204_response_stream(Config) ->
ok.
no_body_in_304_response(Config) ->
- doc("304 responses never include a message body. (RFC7230 3.3)"),
+ doc("304 responses never include a message body. Cowboy produces "
+ "a 500 error response when attempting to do so. (RFC7230 3.3)"),
Client = raw_open(Config),
ok = raw_send(Client, [
- "GET /resp/reply2/304 HTTP/1.1\r\n"
+ "GET /resp/reply4/304body HTTP/1.1\r\n"
"Host: localhost\r\n"
"\r\n"]),
- {_, 304, _, Rest} = cow_http:parse_status_line(raw_recv_head(Client)),
- {_, <<>>} = cow_http:parse_headers(Rest),
- {error, timeout} = raw_recv(Client, 1, 1000),
+ {_, 500, _, _} = cow_http:parse_status_line(raw_recv_head(Client)),
ok.
no_body_in_304_response_stream(Config) ->
- doc("304 responses never include a message body. (RFC7230 3.3)"),
+ doc("304 responses never include a message body. Attempting to "
+ "stream the body produces a crash on the server-side. (RFC7230 3.3)"),
Client = raw_open(Config),
ok = raw_send(Client, [
- "GET /resp/stream_reply2/304 HTTP/1.1\r\n"
+ "GET /resp/stream_reply2/304body HTTP/1.1\r\n"
"Host: localhost\r\n"
"\r\n"]),
{_, 304, _, Rest} = cow_http:parse_status_line(raw_recv_head(Client)),