Forráskód Böngészése

ZF-6678 - Bugfix for Multiple HTTP respone status messages in cURL adapter, which are now proberly removed (Thanks to Jordan Ryan Moore for the patch)

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@16035 44c647ce-9c0f-0410-b52a-842ac1e357ba
beberlei 16 éve
szülő
commit
7273aefbc3
1 módosított fájl, 10 hozzáadás és 6 törlés
  1. 10 6
      library/Zend/Http/Client/Adapter/Curl.php

+ 10 - 6
library/Zend/Http/Client/Adapter/Curl.php

@@ -348,12 +348,16 @@ class Zend_Http_Client_Adapter_Curl implements Zend_Http_Client_Adapter_Interfac
             $this->_response = str_ireplace("Transfer-Encoding: chunked\r\n", '', $this->_response);
         }
 
-        // TODO: Probably the pattern for multiple handshake requests is always the same, several HTTP codes in the response. Use that information?
-        // cURL automactically handles Expect: 100-continue; and its responses. Delete the HTTP 100 CONTINUE from a response
-        // because it messes up Zend_Http_Response parsing
-        if (stripos($this->_response, "HTTP/1.1 100 Continue\r\n\r\n") !== false) {
-            $this->_response = str_ireplace("HTTP/1.1 100 Continue\r\n\r\n", '', $this->_response);
-        }
+        // Eliminate multiple HTTP responses.
+        do {
+            $parts  = preg_split('|(?:\r?\n){2}|m', $this->_response, 2);
+            $again  = false;
+
+            if (isset($parts[1]) && preg_match("|^HTTP/1\.[01](.*?)\r\n|mi", $parts[1])) {
+                $this->_response    = $parts[1];
+                $again              = true;
+            }
+        } while ($again);
 
         // cURL automatically handles Proxy rewrites, remove the "HTTP/1.0 200 Connection established" string:
         if (stripos($this->_response, "HTTP/1.0 200 Connection established\r\n\r\n") !== false) {