summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Schneider2024-04-22 18:30:34 +0200
committerChristian Schneider2024-04-22 18:32:50 +0200
commitc5d0d46693b58e5fecc3f87d19fdf272fd29e0ab (patch)
tree048d36c395fddaac9ccda1e1e77e6f2720614d9f
parentdc7b8557d6bbcbdcef9874ff199bf93a39a11c32 (diff)
downloaditools-c5d0d46693b58e5fecc3f87d19fdf272fd29e0ab.tar.gz
itools-c5d0d46693b58e5fecc3f87d19fdf272fd29e0ab.tar.bz2
itools-c5d0d46693b58e5fecc3f87d19fdf272fd29e0ab.zip
Send notice to schneider@search.ch to check where chaning default to empty_on_fail=true would have an impact
-rw-r--r--it_url.class4
-rwxr-xr-xtest/it_url.t6
2 files changed, 7 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class
index da1de16..cd23360 100644
--- a/it_url.class
+++ b/it_url.class
@@ -352,6 +352,10 @@ function request($p=array())
}
else
{
+ # Send a notice in cases where changing the default to empty_on_fail=true would change result for text results
+ if ($url->result >= 400 && $url->data && !isset($p['empty_on_fail']) && it::match('^text/', $url->headers['Content-Type']))
+ it::error(['to' => 'schneider@search.ch', 'title' => 'Failing it_url::get() without empty_on_fail but non-empty data', 'body' => ['p' => $p, 'url' => $url]]);
+
if ($url->result >= 400 && ($p['empty_on_fail'] || $p['keepfailed']))
$got = $url->data = false;
$result =& $url->data;
diff --git a/test/it_url.t b/test/it_url.t
index 01de74b..b141670 100755
--- a/test/it_url.t
+++ b/test/it_url.t
@@ -348,15 +348,15 @@ is(count($pages), 2, 'it_url::get_multi no additional array elements');
handle_server(
is(
- it_url::get("http://$host/maybe_error?chance=0"),
+ it_url::get(['url' => "http://$host/maybe_error?chance=0"]),
"success"
),
is(
- it_url::get("http://$host/maybe_error?chance=100"),
+ it_url::get(['url' => "http://$host/maybe_error?chance=100", 'empty_on_fail' => false]),
"failure"
),
is(
- it_url::get(['url' => "http://$host/maybe_error?chance=10", 'retries' => 10]),
+ it_url::get(['url' => "http://$host/maybe_error?chance=10", 'empty_on_fail' => true, 'retries' => 10]),
"success",
"Retry on sporadically failing url in ::get"
),