Browse Source

fix ZF-9265 - proxy adapter does not support streamed requests

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@21792 44c647ce-9c0f-0410-b52a-842ac1e357ba
stas 16 years ago
parent
commit
f62aefe879
1 changed files with 15 additions and 4 deletions
  1. 15 4
      library/Zend/Http/Client/Adapter/Proxy.php

+ 15 - 4
library/Zend/Http/Client/Adapter/Proxy.php

@@ -168,15 +168,26 @@ class Zend_Http_Client_Adapter_Proxy extends Zend_Http_Client_Adapter_Socket
             $request .= "$v\r\n";
             $request .= "$v\r\n";
         }
         }
 
 
-        // Add the request body
-        $request .= "\r\n" . $body;
-
+        if(is_resource($body)) {
+            $request .= "\r\n";
+        } else {
+            // Add the request body
+            $request .= "\r\n" . $body;
+        }
+        
         // Send the request
         // Send the request
         if (! @fwrite($this->socket, $request)) {
         if (! @fwrite($this->socket, $request)) {
             require_once 'Zend/Http/Client/Adapter/Exception.php';
             require_once 'Zend/Http/Client/Adapter/Exception.php';
             throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
             throw new Zend_Http_Client_Adapter_Exception("Error writing request to proxy server");
         }
         }
-
+        
+        if(is_resource($body)) {
+            if(stream_copy_to_stream($body, $this->socket) == 0) {
+                require_once 'Zend/Http/Client/Adapter/Exception.php';
+                throw new Zend_Http_Client_Adapter_Exception('Error writing request to server');
+            }
+        }
+        
         return $request;
         return $request;
     }
     }