]> git.wh0rd.org Git - tt-rss.git/commitdiff
fetch: support if-modified-since without CURL
authorAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 19 Apr 2013 14:08:24 +0000 (18:08 +0400)
committerAndrew Dolgov <fox@madoka.volgo-balt.ru>
Fri, 19 Apr 2013 14:08:24 +0000 (18:08 +0400)
include/functions.php

index 88484cadd6a925ff6284934a77fa7993a8d43568..615f0a9b78aec5aa56d5d5b0cdf5c1eadc48d859 100644 (file)
                                }
                        }
 
-                       $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)) {
                                                // 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);
+                                       }
                                }
                        }