From 0d63455d4f162808d2a9d185369607ffcb44bd9a Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 28 Dec 2012 00:18:48 -0500 Subject: [PATCH] Start extracting a base Message class. --- lib/Cake/Network/Http/Message.php | 62 ++++++++++++++++++++++++++++++ lib/Cake/Network/Http/Request.php | 23 +---------- lib/Cake/Network/Http/Response.php | 35 ++--------------- 3 files changed, 67 insertions(+), 53 deletions(-) create mode 100644 lib/Cake/Network/Http/Message.php diff --git a/lib/Cake/Network/Http/Message.php b/lib/Cake/Network/Http/Message.php new file mode 100644 index 00000000000..cde267f216c --- /dev/null +++ b/lib/Cake/Network/Http/Message.php @@ -0,0 +1,62 @@ +_headers; } -/** - * Normalize header names to Camel-Case form. - * - * @param string $name The header name to normalize. - * @return string Normalized header name. - */ - protected function _normalizeHeader($name) { - $parts = explode('-', $name); - $parts = array_map('strtolower', $parts); - $parts = array_map('ucfirst', $parts); - return implode('-', $parts); - } - /** * Get/set the content or body for the request. * diff --git a/lib/Cake/Network/Http/Response.php b/lib/Cake/Network/Http/Response.php index 72d41df13f8..9997cdf8bf4 100644 --- a/lib/Cake/Network/Http/Response.php +++ b/lib/Cake/Network/Http/Response.php @@ -13,6 +13,8 @@ */ namespace Cake\Network\Http; +use Cake\Network\Http\Message; + /** * Implements methods for HTTP responses. * @@ -57,11 +59,7 @@ * * `$content = $response['code'];` */ -class Response implements \ArrayAccess { - - const STATUS_OK = 200; - const STATUS_CREATED = 201; - const STATUS_ACCEPTED = 202; +class Response extends Message implements \ArrayAccess { /** * The status code of the response. @@ -70,20 +68,6 @@ class Response implements \ArrayAccess { */ protected $_code; -/** - * The array of headers in the response. - * - * @var array - */ - protected $_headers; - -/** - * The array of cookies in the response. - * - * @var array - */ - protected $_cookies; - /** * The response body * @@ -181,19 +165,6 @@ protected function _parseCookie($value) { $this->_cookies[$name] = $cookie; } -/** - * Normalize header names to Camel-Case form. - * - * @param string $name The header name to normalize. - * @return string Normalized header name. - */ - protected function _normalizeHeader($name) { - $parts = explode('-', trim($name)); - $parts = array_map('strtolower', $parts); - $parts = array_map('ucfirst', $parts); - return implode('-', $parts); - } - /** * Check if the response was OK *