浏览代码

Move Http\Client into Http package.

Move Cake\Network\Http\Client into the Http package. This change just
moves the implementation and not the test cases. This shows that the
correct class renames are in place. I wanted to move the implementation
first to keep this change small and easy to review. I've renamed
FormData\Part to FormDataPart as the extra directories were not
necessary.

I also wanted get consensus on the renames before doing more work.
Mark Story 10 年之前
父节点
当前提交
5d866f0dce

+ 13 - 0
config/bootstrap.php

@@ -29,6 +29,19 @@ class_alias('Cake\Mailer\Email', 'Cake\Network\Email\Email');
 class_alias('Cake\Mailer\Transport\MailTransport', 'Cake\Network\Email\MailTransport');
 class_alias('Cake\Mailer\Transport\SmtpTransport', 'Cake\Network\Email\SmtpTransport');
 
+// @deprecated Backwards compatibility with earler 3.x versions.
+class_alias('Cake\Http\Client', 'Cake\Network\Http\Client');
+class_alias('Cake\Http\Client\CookieCollection', 'Cake\Network\Http\CookieCollection');
+class_alias('Cake\Http\Client\FormData', 'Cake\Network\Http\FormData');
+class_alias('Cake\Http\Client\Message', 'Cake\Network\Http\Message');
+class_alias('Cake\Http\Client\Request', 'Cake\Network\Http\Request');
+class_alias('Cake\Http\Client\Response', 'Cake\Network\Http\Response');
+class_alias('Cake\Http\Client\Adapter\Stream', 'Cake\Network\Http\Adapter\Stream');
+class_alias('Cake\Http\Client\Auth\Basic', 'Cake\Network\Http\Auth\Basic');
+class_alias('Cake\Http\Client\Auth\Digest', 'Cake\Network\Http\Auth\Digest');
+class_alias('Cake\Http\Client\Auth\Oauth', 'Cake\Network\Http\Auth\Oauth');
+class_alias('Cake\Http\Client\FormDataPart', 'Cake\Network\Http\FormData\Part');
+
 require CAKE . 'basics.php';
 
 // Sets the initial router state so future reloads work.

+ 22 - 20
src/Network/Http/Client.php

@@ -11,11 +11,13 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http;
+namespace Cake\Http;
 
 use Cake\Core\App;
 use Cake\Core\Exception\Exception;
 use Cake\Core\InstanceConfigTrait;
+use Cake\Http\Client\CookieCollection;
+use Cake\Http\Client\Request;
 use Cake\Utility\Hash;
 
 /**
@@ -98,7 +100,7 @@ class Client
      * @var array
      */
     protected $_defaultConfig = [
-        'adapter' => 'Cake\Network\Http\Adapter\Stream',
+        'adapter' => 'Cake\Http\Client\Adapter\Stream',
         'host' => null,
         'port' => null,
         'scheme' => 'http',
@@ -116,7 +118,7 @@ class Client
      * Cookies are indexed by the cookie's domain or
      * request host name.
      *
-     * @var \Cake\Network\Http\CookieCollection
+     * @var \Cake\Http\Client\CookieCollection
      */
     protected $_cookies;
 
@@ -124,7 +126,7 @@ class Client
      * Adapter for sending requests. Defaults to
      * Cake\Network\Http\Adapter\Stream
      *
-     * @var \Cake\Network\Http\Adapter\Stream
+     * @var \Cake\Http\Client\Adapter\Stream
      */
     protected $_adapter;
 
@@ -175,7 +177,7 @@ class Client
      *
      * Returns an array of cookie data arrays.
      *
-     * @return \Cake\Network\Http\CookieCollection
+     * @return \Cake\Http\Client\CookieCollection
      */
     public function cookies()
     {
@@ -193,7 +195,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param array $data The query data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function get($url, $data = [], array $options = [])
     {
@@ -218,7 +220,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param mixed $data The post data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function post($url, $data = [], array $options = [])
     {
@@ -233,7 +235,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param mixed $data The request data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function put($url, $data = [], array $options = [])
     {
@@ -248,7 +250,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param mixed $data The request data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function patch($url, $data = [], array $options = [])
     {
@@ -263,7 +265,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param mixed $data The request data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function options($url, $data = [], array $options = [])
     {
@@ -278,7 +280,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param mixed $data The request data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function trace($url, $data = [], array $options = [])
     {
@@ -293,7 +295,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param mixed $data The request data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function delete($url, $data = [], array $options = [])
     {
@@ -308,7 +310,7 @@ class Client
      * @param string $url The url or path you want to request.
      * @param array $data The query string data you want to send.
      * @param array $options Additional options for the request.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function head($url, array $data = [], array $options = [])
     {
@@ -324,7 +326,7 @@ class Client
      * @param string $url URL to request.
      * @param mixed $data The request body.
      * @param array $options The options to use. Contains auth, proxy etc.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     protected function _doRequest($method, $url, $data, $options)
     {
@@ -354,9 +356,9 @@ class Client
      * Used internally by other methods, but can also be used to send
      * handcrafted Request objects.
      *
-     * @param \Cake\Network\Http\Request $request The request to send.
+     * @param \Cake\Http\Client\Request $request The request to send.
      * @param array $options Additional options to use.
-     * @return \Cake\Network\Http\Response
+     * @return \Cake\Http\Client\Response
      */
     public function send(Request $request, $options = [])
     {
@@ -414,7 +416,7 @@ class Client
      * @param string $url The url including query string.
      * @param mixed $data The request body.
      * @param array $options The options to use. Contains auth, proxy etc.
-     * @return \Cake\Network\Http\Request
+     * @return \Cake\Http\Client\Request
      */
     protected function _createRequest($method, $url, $data, $options)
     {
@@ -480,7 +482,7 @@ class Client
      * Uses the authentication type to choose the correct strategy
      * and use its methods to add headers.
      *
-     * @param \Cake\Network\Http\Request $request The request to modify.
+     * @param \Cake\Http\Client\Request $request The request to modify.
      * @param array $options Array of options containing the 'auth' key.
      * @return void
      */
@@ -497,7 +499,7 @@ class Client
      * Uses the authentication type to choose the correct strategy
      * and use its methods to add headers.
      *
-     * @param \Cake\Network\Http\Request $request The request to modify.
+     * @param \Cake\Http\Client\Request $request The request to modify.
      * @param array $options Array of options containing the 'proxy' key.
      * @return void
      */
@@ -525,7 +527,7 @@ class Client
             $auth['type'] = 'basic';
         }
         $name = ucfirst($auth['type']);
-        $class = App::className($name, 'Network/Http/Auth');
+        $class = App::className($name, 'Http/Client/Auth');
         if (!$class) {
             throw new Exception(
                 sprintf('Invalid authentication type %s', $name)

+ 5 - 5
src/Network/Http/Adapter/Stream.php

@@ -11,12 +11,12 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http\Adapter;
+namespace Cake\Http\Client\Adapter;
 
 use Cake\Core\Exception\Exception;
-use Cake\Network\Http\FormData;
-use Cake\Network\Http\Request;
-use Cake\Network\Http\Response;
+use Cake\Http\Client\FormData;
+use Cake\Http\Client\Request;
+use Cake\Http\Client\Response;
 
 /**
  * Implements sending Cake\Network\Http\Request
@@ -65,7 +65,7 @@ class Stream
     /**
      * Send a request and get a response back.
      *
-     * @param \Cake\Network\Http\Request $request The request object to send.
+     * @param \Cake\Http\Client\Request $request The request object to send.
      * @param array $options Array of options for the stream.
      * @return array Array of populated Response objects
      */

+ 1 - 1
src/Network/Http/Auth/Basic.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http\Auth;
+namespace Cake\Http\Client\Auth;
 
 use Cake\Network\Http\Request;
 

+ 3 - 3
src/Network/Http/Auth/Digest.php

@@ -11,10 +11,10 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http\Auth;
+namespace Cake\Http\Client\Auth;
 
-use Cake\Network\Http\Client;
-use Cake\Network\Http\Request;
+use Cake\Http\Client;
+use Cake\Http\Client\Request;
 
 /**
  * Digest authentication adapter for Cake\Network\Http\Client

+ 2 - 2
src/Network/Http/Auth/Oauth.php

@@ -11,10 +11,10 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http\Auth;
+namespace Cake\Http\Client\Auth;
 
 use Cake\Core\Exception\Exception;
-use Cake\Network\Http\Request;
+use Cake\Http\Client\Request;
 
 /**
  * Oauth 1 authentication strategy for Cake\Network\Http\Client

+ 3 - 1
src/Network/Http/CookieCollection.php

@@ -11,7 +11,9 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http;
+namespace Cake\Http\Client;
+
+use Cake\Http\Client\Response;
 
 /**
  * Container class for cookies used in Http\Client.

+ 6 - 7
src/Network/Http/FormData.php

@@ -11,9 +11,9 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http;
+namespace Cake\Http\Client;
 
-use Cake\Network\Http\FormData\Part;
+use Cake\Http\Client\FormDataPart;
 use Countable;
 use finfo;
 
@@ -23,7 +23,6 @@ use finfo;
  *
  * Used by Http\Client to upload POST/PUT data
  * and files.
- *
  */
 class FormData implements Countable
 {
@@ -75,11 +74,11 @@ class FormData implements Countable
      *
      * @param string $name The name of the part.
      * @param string $value The value to add.
-     * @return \Cake\Network\Http\FormData\Part
+     * @return \Cake\Network\Http\FormDataPart
      */
     public function newPart($name, $value)
     {
-        return new Part($name, $value);
+        return new FormDataPart($name, $value);
     }
 
     /**
@@ -109,7 +108,7 @@ class FormData implements Countable
                 E_USER_DEPRECATED
             );
             $this->_parts[] = $this->addFile($name, $value);
-        } elseif ($name instanceof Part && $value === null) {
+        } elseif ($name instanceof FormDataPart && $value === null) {
             $this->_hasComplexPart = true;
             $this->_parts[] = $name;
         } else {
@@ -140,7 +139,7 @@ class FormData implements Countable
      *
      * @param string $name The name to use.
      * @param mixed $value Either a string filename, or a filehandle.
-     * @return \Cake\Network\Http\FormData\Part
+     * @return \Cake\Network\Http\FormDataPart
      */
     public function addFile($name, $value)
     {

+ 4 - 2
src/Network/Http/FormData/Part.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http\FormData;
+namespace Cake\Http\Client;
 
 /**
  * Contains the data and behavior for a single
@@ -19,8 +19,10 @@ namespace Cake\Network\Http\FormData;
  *
  * Added to Cake\Network\Http\FormData when sending
  * data to a remote server.
+ *
+ * @internal
  */
-class Part
+class FormDataPart
 {
 
     /**

+ 1 - 1
src/Network/Http/Message.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http;
+namespace Cake\Http\Client;
 
 /**
  * Base class for other HTTP requests/responses

+ 2 - 1
src/Network/Http/Request.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http;
+namespace Cake\Http\Client;
 
 use Cake\Core\Exception\Exception;
 
@@ -20,6 +20,7 @@ use Cake\Core\Exception\Exception;
  *
  * Used by Cake\Network\Http\Client to contain request information
  * for making requests.
+ *
  */
 class Request extends Message
 {

+ 1 - 1
src/Network/Http/Response.php

@@ -11,7 +11,7 @@
  * @since         3.0.0
  * @license       http://www.opensource.org/licenses/mit-license.php MIT License
  */
-namespace Cake\Network\Http;
+namespace Cake\Http\Client;
 
 use RuntimeException;