Changeset View
Changeset View
Standalone View
Standalone View
src/parser/http/PhutilHTTPResponseParser.php
Context not available. | |||||
if ($this->state == 'headers') { | if ($this->state == 'headers') { | ||||
$matches = null; | $matches = null; | ||||
$ok = preg_match( | $ok = @preg_match( | ||||
"/(\r?\n\r?\n)/", | "/(\r?\n\r?\n)/", | ||||
$this->buffer, | $this->buffer, | ||||
$matches, | $matches, | ||||
Context not available. | |||||
} | } | ||||
$headers_len = $matches[1][1]; | $headers_len = $matches[1][1]; | ||||
$boundary_len = strlen($matches[1][0]); | $boundary_len = @strlen($matches[1][0]); | ||||
$raw_headers = substr($this->buffer, 0, $headers_len); | $raw_headers = @substr($this->buffer, 0, $headers_len); | ||||
$this->buffer = substr($this->buffer, $headers_len + $boundary_len); | $this->buffer = @substr($this->buffer, $headers_len + $boundary_len); | ||||
$header_lines = phutil_split_lines($raw_headers); | $header_lines = phutil_split_lines($raw_headers); | ||||
$first_line = array_shift($header_lines); | $first_line = array_shift($header_lines); | ||||
$response_valid = true; | $response_valid = true; | ||||
$matches = null; | $matches = null; | ||||
$ok = preg_match( | $ok = @preg_match( | ||||
'(^HTTP/\S+\s+(\d+)(?:\s+(.*))?$)i', | '(^HTTP/\S+\s+(\d+)(?:\s+(.*))?$)i', | ||||
$first_line, | $first_line, | ||||
$matches); | $matches); | ||||
Context not available. | |||||
$header_list = array(); | $header_list = array(); | ||||
$saw_location = false; | $saw_location = false; | ||||
foreach ($header_lines as $header_line) { | foreach ($header_lines as $header_line) { | ||||
$pos = strpos($header_line, ':'); | $pos = @strpos($header_line, ':'); | ||||
if ($pos === false) { | if ($pos === false) { | ||||
$response_valid = false; | $response_valid = false; | ||||
break; | break; | ||||
} | } | ||||
$name = substr($header_line, 0, $pos); | $name = @substr($header_line, 0, $pos); | ||||
$value = ltrim(substr($header_line, $pos + 1), ' '); | $value = ltrim(@substr($header_line, $pos + 1), ' '); | ||||
if (phutil_utf8_strtolower($name) == 'location') { | if (phutil_utf8_strtolower($name) == 'location') { | ||||
$saw_location = true; | $saw_location = true; | ||||
Context not available. | |||||
} | } | ||||
if ($this->state == 'body') { | if ($this->state == 'body') { | ||||
if (strlen($this->buffer)) { | if (@strlen($this->buffer)) { | ||||
$bytes = $this->buffer; | $bytes = $this->buffer; | ||||
$this->buffer = ''; | $this->buffer = ''; | ||||
Context not available. | |||||
$sink = $this->getProgressSink(); | $sink = $this->getProgressSink(); | ||||
if ($sink) { | if ($sink) { | ||||
$sink->didMakeProgress(strlen($bytes)); | $sink->didMakeProgress(@strlen($bytes)); | ||||
} | } | ||||
} | } | ||||
break; | break; | ||||
Context not available. |
Content licensed under Creative Commons Attribution-ShareAlike 4.0 (CC-BY-SA) unless otherwise noted; code licensed under Apache 2.0 or other open source licenses. · CC BY-SA 4.0 · Apache 2.0