Package: magpierss / 0.72-11

newlines_in_headers_break_caching.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
Index: magpierss/rss_fetch.inc
===================================================================
--- magpierss.orig/rss_fetch.inc	2009-03-04 22:21:43.000000000 -0300
+++ magpierss/rss_fetch.inc	2009-03-04 22:22:24.000000000 -0300
@@ -153,7 +153,7 @@
         // setup headers
         if ( $cache_status == 'STALE' ) {
             $rss = $cache->get( $cache_key );
-            if ( $rss and $rss->etag and $rss->last_modified ) {
+            if ( $rss and !empty($rss->etag) and !empty($rss->last_modified) ) { // moodle fixes
                 $request_headers['If-None-Match'] = $rss->etag;
                 $request_headers['If-Last-Modified'] = $rss->last_modified;
             }
@@ -301,14 +301,15 @@
                 $field = $h;
                 $val = "";
             }
-            
-            if ( $field == 'ETag' ) {
-                $rss->etag = $val;
+// start of moodle modification
+            if ( strtolower($field) == 'etag' ) { // field names are case insensitive - sites are sending Etag, ETag, etc.
+                $rss->etag = rtrim($val);         // trailing newline problem discovered by Matthew Bockol
             }
             
-            if ( $field == 'Last-Modified' ) {
-                $rss->last_modified = $val;
+            if ( strtolower($field) == 'last-modified' ) { // field names are case insensitive
+                $rss->last_modified = rtrim($val);         // we do not want any whitespace after it
             }
+// end of moodle modification
         }
         
         return $rss;