Browse Source

Make stream error handling method public to handle errors in custom stream wrappers (#9001)

Marlin Cremers 9 years ago
parent
commit
f7fb9b7aa0
1 changed files with 3 additions and 14 deletions
  1. 3 14
      src/Http/Client/Adapter/Stream.php

+ 3 - 14
src/Http/Client/Adapter/Stream.php

@@ -293,7 +293,9 @@ class Stream
      */
     protected function _open($url)
     {
-        set_error_handler([$this, '_connectionErrorHandler']);
+        set_error_handler(function ($code, $message) {
+            $this->_connectionErrors[] = $message;
+        });
         $this->_stream = fopen($url, 'rb', false, $this->_context);
         restore_error_handler();
 
@@ -303,19 +305,6 @@ class Stream
     }
 
     /**
-     * Local error handler to capture errors triggered during
-     * stream connection.
-     *
-     * @param int $code Error code.
-     * @param string $message Error message.
-     * @return void
-     */
-    protected function _connectionErrorHandler($code, $message)
-    {
-        $this->_connectionErrors[] = $message;
-    }
-
-    /**
      * Get the context options
      *
      * Useful for debugging and testing context creation.