summaryrefslogtreecommitdiff
path: root/it_url.class
diff options
context:
space:
mode:
Diffstat (limited to 'it_url.class')
-rw-r--r--it_url.class16
1 files changed, 8 insertions, 8 deletions
diff --git a/it_url.class b/it_url.class
index 8ebe1e5..6916661 100644
--- a/it_url.class
+++ b/it_url.class
@@ -201,8 +201,8 @@ static function _default_headers($url, $p)
'X-Ultra-Https' => $_SERVER['HTTPS'],
]);
- if (is_int($p['filemtime']))
- $headers['If-Modified-Since'] = date("r", $p['filemtime']);
+ if (!$p['unconditional'] && is_int($p['filemtime']))
+ $headers['If-Modified-Since'] = gmdate("D, d M Y H:i:s T", $p['filemtime']); # Use GMT as per https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/If-Modified-Since
return $headers;
}
@@ -602,6 +602,7 @@ static function get_cache_filename($p)
* @param $p['safety'] DEPRECATED. see $p['it_error']
* @param $p['it_error'] parameters for it::error(), false means ignore errors, anything else gets passed to it::error() if errors occur
* @param $p['keepfailed'] keep old versions of files if download fails
+ * @param $p['unconditional'] Make request unconditional, i.e. do not send If-Modified-Since header when refetching (Work-around for Windy webcam caching problem)
* @param $p['returnheaders'] Return array($path, $headers) instead of simply $path
* @param $p['postprocess'] UNSUPPORTED, use ::get_cache_contents
* @param $p['lock'] prevent multiple requests to same url from different processes [true]
@@ -727,9 +728,8 @@ static function get_cache($p = array())
if (EDC('getcachelog'))
it::log('debug', 'getcachelog', $p['id'], $p['url'], !$isnewfile ? "" : "fetched=" . mb_substr(is_string($data) ? $data : "(assoc)", 0, 400));
- ### EDC('getcache', $success, $path); # too verbose
return $p['returnheaders'] || $p['returncachemiss']
- ? ($success ? [$path, $headers, (bool)$isnewfile] : null)
+ ? [$success ? $path : false, $headers, (bool)$isnewfile]
: ($success ? $path : false);
}
@@ -741,7 +741,7 @@ static function get_cache($p = array())
*/
static function get_cache_contents($p)
{
- [$fn, $dummy, $cachemiss] = self::get_cache($p + ['returncachemiss' => true]);
+ [$fn, $headers, $cachemiss] = self::get_cache($p + ['returncachemiss' => true]);
if ($fn)
{
$result = it::file_get_contents($fn);
@@ -755,7 +755,7 @@ static function get_cache_contents($p)
$result = self::_postprocess($result, $p);
}
else
- $result = it::error((array)$p['it_error'] + ['title' => $p['safety'] === 0 ? false : "failed getting " . static::absolute($p['url']), 'body' => $p + ['fn' => $fn, 'dummy' => $dummy, 'cachemiss' => $cachemiss]]);
+ $result = it::error((array)$p['it_error'] + ['title' => "failed getting " . static::absolute($p['url']), 'body' => $p + ['fn' => $fn, 'headers' => $headers, 'cachemiss' => $cachemiss]]);
return $result;
}
@@ -860,9 +860,9 @@ static function _atomicwrite($path, $data)
}
/**
- * Make an URL absolute by using host and protocol from current Apache request (but not port number)
+ * Make an URL absolute by using host and protocol (but not port) from current Apache request; http: in script context
* @param $url Optional URL ( foo.html, /foo.html, //host/bar.html, https://host/bar.html ), default self
- * @param $proto_force Optional protocol to enforce, default protocol of current request or http if in script context
+ * @param $proto_force Optional protocol to enforce, even if a protocol is given in $url
* @return absolute version of URL ( http[s]://host/bar.html )
*/
static function absolute($url = null, $proto_force = null, $prefix = '')