mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Replaced trigger_error by throw Exception.
This commit is contained in:
parent
8a4faa1e69
commit
ef2a7d4608
1 changed files with 5 additions and 6 deletions
|
@ -532,6 +532,7 @@ class HttpSocket extends CakeSocket {
|
||||||
*
|
*
|
||||||
* @param string $body A string continaing the chunked body to decode.
|
* @param string $body A string continaing the chunked body to decode.
|
||||||
* @return mixed Array of response headers and body or false.
|
* @return mixed Array of response headers and body or false.
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function _decodeChunkedBody($body) {
|
protected function _decodeChunkedBody($body) {
|
||||||
if (!is_string($body)) {
|
if (!is_string($body)) {
|
||||||
|
@ -544,8 +545,7 @@ class HttpSocket extends CakeSocket {
|
||||||
while ($chunkLength !== 0) {
|
while ($chunkLength !== 0) {
|
||||||
if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) {
|
if (!preg_match("/^([0-9a-f]+) *(?:;(.+)=(.+))?\r\n/iU", $body, $match)) {
|
||||||
if (!$this->quirksMode) {
|
if (!$this->quirksMode) {
|
||||||
trigger_error(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.'), E_USER_WARNING);
|
throw new Exception(__('HttpSocket::_decodeChunkedBody - Could not parse malformed chunk. Activate quirks mode to do this.'));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -794,6 +794,7 @@ class HttpSocket extends CakeSocket {
|
||||||
* @param array $request Needs to contain a 'uri' key. Should also contain a 'method' key, otherwise defaults to GET.
|
* @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
|
* @param string $versionToken The version token to use, defaults to HTTP/1.1
|
||||||
* @return string Request line
|
* @return string Request line
|
||||||
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') {
|
protected function _buildRequestLine($request = array(), $versionToken = 'HTTP/1.1') {
|
||||||
$asteriskMethods = array('OPTIONS');
|
$asteriskMethods = array('OPTIONS');
|
||||||
|
@ -801,8 +802,7 @@ class HttpSocket extends CakeSocket {
|
||||||
if (is_string($request)) {
|
if (is_string($request)) {
|
||||||
$isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match);
|
$isValid = preg_match("/(.+) (.+) (.+)\r\n/U", $request, $match);
|
||||||
if (!$this->quirksMode && (!$isValid || ($match[2] == '*' && !in_array($match[3], $asteriskMethods)))) {
|
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);
|
throw new Exception(__('HttpSocket::_buildRequestLine - Passed an invalid request line string. Activate quirks mode to do this.'));
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return $request;
|
return $request;
|
||||||
} elseif (!is_array($request)) {
|
} elseif (!is_array($request)) {
|
||||||
|
@ -816,8 +816,7 @@ class HttpSocket extends CakeSocket {
|
||||||
$request['uri'] = $this->_buildUri($request['uri'], '/%path?%query');
|
$request['uri'] = $this->_buildUri($request['uri'], '/%path?%query');
|
||||||
|
|
||||||
if (!$this->quirksMode && $request['uri'] === '*' && !in_array($request['method'], $asteriskMethods)) {
|
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);
|
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 false;
|
|
||||||
}
|
}
|
||||||
return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak;
|
return $request['method'].' '.$request['uri'].' '.$versionToken.$this->lineBreak;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue