]> git.mjollnir.org Git - moodle.git/commitdiff
lib/simplepie MDL-7946 Set magpie HTTP headers with curl
authorpoltawski <poltawski>
Thu, 30 Jul 2009 16:11:00 +0000 (16:11 +0000)
committerpoltawski <poltawski>
Thu, 30 Jul 2009 16:11:00 +0000 (16:11 +0000)
This allows simplepie to set if-modified-since/if-none-match headers
to efficiently test if a feed has been updated without recieving the
whole content

lib/simplepie/moodle_simplepie.php

index 89680aa8e7ba79e0cd266f9e621e959282cf0dc2..5e5d946364dadf1c41315d93677bc810dc2dd6d2 100644 (file)
@@ -113,6 +113,14 @@ class moodle_simplepie_file extends SimplePie_File
         $curl = new curl();
         $curl->setopt(array('CURLOPT_HEADER'=>true));
 
+        if ($headers !== null) {
+            // translate simplepie headers to those class curl expects
+            foreach($headers as $headername => $headervalue){
+                $headerstr = "{$headername}: {$headervalue}";
+                $curl->setHeader($headerstr);
+            }
+        }
+
         $this->headers = $curl->get($url);
 
         if ($curl->error) {