diff options
author | Andrew Dolgov <[email protected]> | 2013-04-19 18:08:24 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-04-19 18:08:24 +0400 |
commit | 01311d86fea8788c596d46e72073dc3c7e610b76 (patch) | |
tree | bb22e1bc85cf3e01fb6a5b338abc7bf6dc6f6fbc | |
parent | 106a3de91c7c8c6c275323152de414253f01127a (diff) |
fetch: support if-modified-since without CURL
-rw-r--r-- | include/functions.php | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/include/functions.php b/include/functions.php index 88484cadd..615f0a9b7 100644 --- a/include/functions.php +++ b/include/functions.php @@ -392,7 +392,17 @@ } } - $data = @file_get_contents($url); + if (!$post_query && $timestamp) { + $context = stream_context_create(array( + 'http' => array( + 'method' => 'GET', + 'header' => "If-Modified-Since: ".gmdate("D, d M Y H:i:s \\G\\M\\T\r\n", $timestamp) + ))); + } else { + $context = NULL; + } + + $data = @file_get_contents($url, false, $context); $fetch_last_content_type = false; // reset if no type was sent from server if (is_array($http_response_header)) { @@ -402,6 +412,10 @@ // don't abort here b/c there might be more than one // e.g. if we were being redirected -- last one is the right one } + + if (substr(strtolower($h), 0, 7) == 'http/1.') { + $fetch_last_error_code = (int) substr($h, 9, 3); + } } } |