diff --git a/config/bootstrap.php b/config/bootstrap.php index 74d7bb443cb..e8d89c2953f 100644 --- a/config/bootstrap.php +++ b/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. diff --git a/src/Network/Http/Client.php b/src/Http/Client.php similarity index 94% rename from src/Network/Http/Client.php rename to src/Http/Client.php index ab1189f58ea..ef8a9ba464b 100644 --- a/src/Network/Http/Client.php +++ b/src/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 @@ public function __construct($config = []) * * Returns an array of cookie data arrays. * - * @return \Cake\Network\Http\CookieCollection + * @return \Cake\Http\Client\CookieCollection */ public function cookies() { @@ -193,7 +195,7 @@ public function cookies() * @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 @@ public function get($url, $data = [], array $options = []) * @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 @@ public function post($url, $data = [], array $options = []) * @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 @@ public function put($url, $data = [], array $options = []) * @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 @@ public function patch($url, $data = [], array $options = []) * @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 @@ public function options($url, $data = [], array $options = []) * @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 @@ public function trace($url, $data = [], array $options = []) * @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 @@ public function delete($url, $data = [], array $options = []) * @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 @@ public function head($url, array $data = [], array $options = []) * @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 @@ protected function _mergeOptions($options) * 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 @@ public function buildUrl($url, $query = [], $options = []) * @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 @@ protected function _typeHeaders($type) * 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 @@ protected function _addAuthentication(Request $request, $options) * 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 @@ protected function _createAuth($auth, $options) $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) diff --git a/src/Network/Http/Adapter/Stream.php b/src/Http/Client/Adapter/Stream.php similarity index 97% rename from src/Network/Http/Adapter/Stream.php rename to src/Http/Client/Adapter/Stream.php index d51c791ac86..1b2ddce0873 100644 --- a/src/Network/Http/Adapter/Stream.php +++ b/src/Http/Client/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 */ diff --git a/src/Network/Http/Auth/Basic.php b/src/Http/Client/Auth/Basic.php similarity index 98% rename from src/Network/Http/Auth/Basic.php rename to src/Http/Client/Auth/Basic.php index 0f60a12a2f0..e7dd5285ed9 100644 --- a/src/Network/Http/Auth/Basic.php +++ b/src/Http/Client/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; diff --git a/src/Network/Http/Auth/Digest.php b/src/Http/Client/Auth/Digest.php similarity index 97% rename from src/Network/Http/Auth/Digest.php rename to src/Http/Client/Auth/Digest.php index c7bf4194f08..b17c83a7e08 100644 --- a/src/Network/Http/Auth/Digest.php +++ b/src/Http/Client/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 diff --git a/src/Network/Http/Auth/Oauth.php b/src/Http/Client/Auth/Oauth.php similarity index 99% rename from src/Network/Http/Auth/Oauth.php rename to src/Http/Client/Auth/Oauth.php index fe66783620f..9211a5e12e1 100644 --- a/src/Network/Http/Auth/Oauth.php +++ b/src/Http/Client/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 diff --git a/src/Network/Http/CookieCollection.php b/src/Http/Client/CookieCollection.php similarity index 98% rename from src/Network/Http/CookieCollection.php rename to src/Http/Client/CookieCollection.php index e1de171060e..de646263ef6 100644 --- a/src/Network/Http/CookieCollection.php +++ b/src/Http/Client/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. diff --git a/src/Network/Http/FormData.php b/src/Http/Client/FormData.php similarity index 96% rename from src/Network/Http/FormData.php rename to src/Http/Client/FormData.php index 73f40a21173..c13aa28ebf1 100644 --- a/src/Network/Http/FormData.php +++ b/src/Http/Client/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 @@ * * Used by Http\Client to upload POST/PUT data * and files. - * */ class FormData implements Countable { @@ -75,11 +74,11 @@ public function boundary() * * @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 @@ public function add($name, $value = null) 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 @@ public function addMany(array $data) * * @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) { diff --git a/src/Network/Http/FormData/Part.php b/src/Http/Client/FormDataPart.php similarity index 98% rename from src/Network/Http/FormData/Part.php rename to src/Http/Client/FormDataPart.php index cd25d389535..ba510b0681b 100644 --- a/src/Network/Http/FormData/Part.php +++ b/src/Http/Client/FormDataPart.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 @@ * * Added to Cake\Network\Http\FormData when sending * data to a remote server. + * + * @internal */ -class Part +class FormDataPart { /** diff --git a/src/Network/Http/Message.php b/src/Http/Client/Message.php similarity index 99% rename from src/Network/Http/Message.php rename to src/Http/Client/Message.php index ee5c93a97af..1854302cade 100644 --- a/src/Network/Http/Message.php +++ b/src/Http/Client/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 diff --git a/src/Network/Http/Request.php b/src/Http/Client/Request.php similarity index 99% rename from src/Network/Http/Request.php rename to src/Http/Client/Request.php index 78dfd724229..13423f66883 100644 --- a/src/Network/Http/Request.php +++ b/src/Http/Client/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 @@ * * Used by Cake\Network\Http\Client to contain request information * for making requests. + * */ class Request extends Message { diff --git a/src/Network/Http/Response.php b/src/Http/Client/Response.php similarity index 99% rename from src/Network/Http/Response.php rename to src/Http/Client/Response.php index c1369aaa16f..f0210cfc4fe 100644 --- a/src/Network/Http/Response.php +++ b/src/Http/Client/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;