THRIFT-4656: Fix infinite loop in PHP TCurlClient

Infinite loop happens when response body is empty and HTTP status is
200. This patch fixes it.
This commit is contained in:
Josip Sokcevic 2018-10-30 15:20:26 -07:00 committed by James E. King III
parent dd965c1eb4
commit 30d3125cc2

View File

@ -169,6 +169,24 @@ class TCurlClient extends TTransport
}
}
/**
* Guarantees that the full amount of data is read. Since TCurlClient gets entire payload at
* once, parent readAll cannot be used.
*
* @return string The data, of exact length
* @throws TTransportException if cannot read data
*/
public function readAll($len)
{
$data = $this->read($len);
if (TStringFuncFactory::create()->strlen($data) !== $len) {
throw new TTransportException('TCurlClient could not read '.$len.' bytes');
}
return $data;
}
/**
* Writes some data into the pending buffer
*