-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Start extracting a base Message class.
- Loading branch information
Showing
3 changed files
with
67 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
/** | ||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org) | ||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* | ||
* Licensed under The MIT License | ||
* Redistributions of files must retain the above copyright notice. | ||
* | ||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org) | ||
* @link http://cakephp.org CakePHP(tm) Project | ||
* @since CakePHP(tm) v 3.0.0 | ||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php) | ||
*/ | ||
namespace Cake\Network\Http; | ||
|
||
/** | ||
* Base class for other HTTP requests/responses | ||
* | ||
* Defines some common helper methods, constants | ||
* and properties. | ||
*/ | ||
class Message { | ||
|
||
const STATUS_OK = 200; | ||
const STATUS_CREATED = 201; | ||
const STATUS_ACCEPTED = 202; | ||
|
||
const METHOD_GET = 'GET'; | ||
const METHOD_POST = 'POST'; | ||
const METHOD_PUT = 'PUT'; | ||
const METHOD_DELETE = 'DELETE'; | ||
const METHOD_PATCH = 'PATCH'; | ||
|
||
/** | ||
* The array of headers in the response. | ||
* | ||
* @var array | ||
*/ | ||
protected $_headers; | ||
|
||
/** | ||
* The array of cookies in the response. | ||
* | ||
* @var array | ||
*/ | ||
protected $_cookies; | ||
|
||
|
||
/** | ||
* 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); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters