]> git.mjollnir.org Git - moodle.git/commitdiff
Merged from MOODLE_18_STABLE:
authordefacer <defacer>
Sun, 25 Feb 2007 01:35:32 +0000 (01:35 +0000)
committerdefacer <defacer>
Sun, 25 Feb 2007 01:35:32 +0000 (01:35 +0000)
Fix for MDL-8653:
When updating languages through a proxy, skip to the end of the HTTP headers
as defined by RFC 1945 instead of skipping exactly 12 lines of chaff.

Credit for patch 100% to Dan Poltawski.

admin/langimport.php

index 79e99deadb5852e28f13059de2d337ad77ba9788..93835f70fa2f92a486bf58fb70fba09de23f3804 100755 (executable)
                 return false;    //failed
             }
             fputs($proxy_fp, "GET $url HTTP/1.0\r\nHost: $CFG->proxyhost\r\n\r\n");
-            $i = 0;
-                while(!feof($proxy_fp)) {
+
+            $headers_done = false;
+            while(!feof($proxy_fp)) {
                 $string = fgets($proxy_fp, 1024);
-                if ($i > 11) {    //12 lines of info skipped
+                if(!$headers_done){
+                    // A new line indicates end of HTTP headers
+                    $headers_done = ("\r\n" == $string);
+                } else {
                     $availablelangs[] = split(',', $string);
                 }
-                $i++;
             }
             fclose($proxy_fp);