From f90ee95af7bcc5cc4a9734bacfdd7e99b88b4b09 Mon Sep 17 00:00:00 2001 From: Nathan Gass Date: Mon, 30 Oct 2023 16:53:51 +0100 Subject: add test that maxlength aborts early --- test/it_url_slow.t | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/it_url_slow.t b/test/it_url_slow.t index 51da6b9..1f43edc 100755 --- a/test/it_url_slow.t +++ b/test/it_url_slow.t @@ -51,6 +51,20 @@ $output = server_output(); if (!$res || !$res2) diag($output); +$start = microtime(true); +$res = ok( + !it_url::get(['url' => 'http://localhost:8000/slow_response', 'maxlength' => 10, 'retries' => 0, 'it_error' => false]), + 'it_url::get() fails for response larger than maxlength' +); +$res2 = is( + intval(microtime(true) - $start), 1, + '... and fails as soon as maxlength is surpassed' +); +sleep(1); # wait for testserver +$output = server_output(); +if (!$res || !$res2) + diag($output); + handle_server( ok( it_url::get(U('http://localhost:8000/repeat', ['string' => "abc", 'num' => 1024 * 1024])) == str_repeat("abc", 1024 * 1024), -- cgit v1.2.3