From b3a31e762673fc02d0979b0ee45ec876e641d8c6 Mon Sep 17 00:00:00 2001 From: Miccah Date: Tue, 2 Mar 2021 13:31:57 -0600 Subject: [PATCH] vweb: add test for 0 Content-Length hang (#9069) --- vlib/vweb/tests/vweb_test.v | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/vlib/vweb/tests/vweb_test.v b/vlib/vweb/tests/vweb_test.v index 37ec2ea65b..eda6d26b5b 100644 --- a/vlib/vweb/tests/vweb_test.v +++ b/vlib/vweb/tests/vweb_test.v @@ -83,6 +83,16 @@ fn test_a_simple_tcp_client_simple_route() { assert received.ends_with('A simple result') } +fn test_a_simple_tcp_client_zero_content_length() { + // tests that sending a content-length header of 0 doesn't hang on a read timeout + watch := time.new_stopwatch(auto_start: true) + simple_tcp_client(path: '/', headers: 'Content-Length: 0\r\n\r\n') or { + assert err.msg == '' + return + } + assert watch.elapsed() < 1 * time.second +} + fn test_a_simple_tcp_client_html_page() { received := simple_tcp_client(path: '/html_page') or { assert err.msg == ''