Skip to content

Commit

Permalink
Replaced trigger_error by throw Exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbasso committed Nov 9, 2010
1 parent 8a4faa1 commit ef2a7d4
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cake/libs/http_socket.php
Expand Up @@ -532,6 +532,7 @@ protected function _decodeBody($body, $encoding = 'chunked') {
*
* @param string $body A string continaing the chunked body to decode.
* @return mixed Array of response headers and body or false.
* @throws Exception
*/
protected function _decodeChunkedBody($body) {
if (!is_string($body)) {
Expand All @@ -544,8 +545,7 @@ protected function _decodeChunkedBody($body) {
while ($chunkLength !== 0) {
if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) {
if (!$this->quirksMode) {
trigger_error(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.'), E_USER_WARNING);
return false;
throw new Exception(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.'));
}
break;
}
Expand Down Expand Up @@ -794,15 +794,15 @@ protected function _parseQuery($query) {
* @param array $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET.
* @param string $versionToken The version token to use, defaults to HTTP/1.1
* @return string Request line
* @throws Exception
*/
protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') {
$asteriskMethods = array('OPTIONS');

if (is_string($request)) {
$isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match);
if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) {
trigger_error(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.'), E_USER_WARNING);
return false;
throw new Exception(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.'));
}
return $request;
} elseif (!is_array($request)) {
Expand All @@ -816,8 +816,7 @@ protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1
$request['uri'] = $this->_buildUri($request['uri'], '/%path?%query');

if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) {
trigger_error(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods)), E_USER_WARNING);
return false;
throw new Exception(sprintf(__('HttpSocket::_buildRequestLine - The "*" asterisk character is only allowed for the following methods: %s. Activate quirks mode to work outside of HTTP/1.1 specs.'), join(',', $asteriskMethods)));
}
return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak;
}
Expand Down

0 comments on commit ef2a7d4

Please sign in to comment.