1
0
Fork 0

Better debuggability of content-length mismatch

pull/5039/merge
Jordi Boggiano 2017-04-19 13:24:07 +02:00
parent 8491a21d41
commit 1fe5064560
1 changed files with 6 additions and 1 deletions

View File

@ -286,7 +286,12 @@ class RemoteFilesystem
$contentLength = !empty($http_response_header[0]) ? $this->findHeaderValue($http_response_header, 'content-length') : null;
if ($contentLength && Platform::strlen($result) < $contentLength) {
// alas, this is not possible via the stream callback because STREAM_NOTIFY_COMPLETED is documented, but not implemented anywhere in PHP
throw new TransportException('Content-Length mismatch');
$e = new TransportException('Content-Length mismatch, received '.Platform::strlen($result).' bytes out of the expected '.$contentLength);
$e->setHeaders($http_response_header);
$e->setStatusCode($this->findStatusCode($http_response_header));
$e->setResponse($result);
throw $e;
}
if (PHP_VERSION_ID < 50600 && !empty($options['ssl']['peer_fingerprint'])) {