From 83bd8bc935cbbba39c8c706a1f7d5a6e9ac932ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 1 Nov 2017 15:33:10 +0000 Subject: Fix two edge cases for cowboy_req:stream_body Sending data of size 0 with the fin flag set resulted in nothing being sent to the client and still considering the response to be finished for HTTP/1.1. For both HTTP/1.1 and HTTP/2, the final chunk of body that is sent automatically by Cowboy at the end of a response that the user did not properly terminate was not passing through stream handlers. This resulted in issues like compression being incorrect. Some tests still fail under 20.1.3. They are due to recent zlib changes and should be fixed in a future patch release. Unfortunately it does not seem to be any 20.1 version that is safe to use for Cowboy, although some will work better than others. --- test/req_SUITE.erl | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'test/req_SUITE.erl') diff --git a/test/req_SUITE.erl b/test/req_SUITE.erl index 107cdd8..862ee53 100644 --- a/test/req_SUITE.erl +++ b/test/req_SUITE.erl @@ -827,6 +827,16 @@ stream_reply3(Config) -> {500, _, _} = do_get("/resp/stream_reply3/error", Config), ok. +stream_body_fin0(Config) -> + doc("Streamed body with last chunk of size 0."), + {200, _, <<"Hello world!">>} = do_get("/resp/stream_body/fin0", Config), + ok. + +stream_body_nofin(Config) -> + doc("Unfinished streamed body."), + {200, _, <<"Hello world!">>} = do_get("/resp/stream_body/nofin", Config), + ok. + %% @todo Crash when calling stream_body after the fin flag has been set. %% @todo Crash when calling stream_body after calling reply. %% @todo Crash when calling stream_body before calling stream_reply. -- cgit v1.2.3