summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
authorUrban Müller2025-11-03 15:51:10 +0100
committerUrban Müller2025-11-03 15:51:10 +0100
commit52ca54d59f044e6deb8242115c1ee2e53915412b (patch)
tree641e01daf7ad1310f59fc64d55f267c227285ae8 /it_url.class
parent2e3beb6805f5f1695953e5735ebf0040833eb655 (diff)
downloaditools-52ca54d59f044e6deb8242115c1ee2e53915412b.tar.gz
itools-52ca54d59f044e6deb8242115c1ee2e53915412b.tar.bz2
itools-52ca54d59f044e6deb8242115c1ee2e53915412b.zip
write header .json file even on failure so headers can be supplied to callersHEADmaster
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class7
1 files changed, 4 insertions, 3 deletions
diff --git a/it_url.class b/it_url.class
index dadb1d5..48dbb6f 100644
--- a/it_url.class
+++ b/it_url.class
@@ -640,14 +640,15 @@ static function get_cache($p = array())
{
$success = true;
$isnewfile = it_url::_atomicwrite($path, $p['assoc'] ? ($data['status'] === 304 ? true : it::json_encode($data)) : $data); # $data === true means not modified (no new data fetched) and instructs _atomicwrite to just touch the file
- if ($p['returnheaders'])
- it::file_put("$path.json", it::json_encode($url->headers));
}
else if ($p['keepfailed'])
- $success = $fileexists;
+ $success = $kept = $fileexists;
else
@unlink($path); # Expired and failed to get
+ if ($p['returnheaders'] && !$kept)
+ it::file_put("$path.json", it::json_encode($url->headers));
+
it_url::_unlock($path, $lock);
}
else