mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 08:17:12 +02:00
Fix issue processwire/processwire-issues#624 where WireHttp was producing error on the occasion when HTTP code present without text (which seems to be rare as far as I can tell).
This commit is contained in:
@@ -905,15 +905,15 @@ class WireHttp extends Wire {
|
||||
protected function setResponseHeader(array $responseHeader) {
|
||||
|
||||
$this->responseHeader = $responseHeader;
|
||||
$httpText = '';
|
||||
$httpCode = 0;
|
||||
|
||||
if(!empty($responseHeader[0])) {
|
||||
list($http, $httpCode, $httpText) = explode(' ', trim($responseHeader[0]), 3);
|
||||
if($http) {} // ignore
|
||||
list(/*HTTP*/, $httpCode) = explode(' ', trim($responseHeader[0]), 2);
|
||||
$httpCode = trim($httpCode);
|
||||
if(strpos($httpCode, ' ')) list($httpCode, $httpText) = explode(' ', $httpCode, 2);
|
||||
$httpCode = (int) $httpCode;
|
||||
$httpText = preg_replace('/[^-_.;() a-zA-Z0-9]/', ' ', $httpText);
|
||||
} else {
|
||||
$httpCode = 0;
|
||||
$httpText = '';
|
||||
if(strlen($httpText)) $httpText = preg_replace('/[^-_.;() a-zA-Z0-9]/', ' ', $httpText);
|
||||
}
|
||||
|
||||
$this->httpCode = (int) $httpCode;
|
||||
|
Reference in New Issue
Block a user