Removed code duplication.

This commit is contained in:
Daniele Alessandri
2010-04-03 14:01:53 +02:00
parent 45ed2a9f96
commit aafddece15
+10 -10
View File
@@ -322,24 +322,24 @@ class ResponseBulkHandler implements IResponseHandler {
if ($dataLength > 0) {
$value = $connection->readBytes($dataLength);
if ($connection->readBytes(2) !== ResponseReader::NEWLINE) {
Utilities\Shared::onCommunicationException(new MalformedServerResponse(
$connection, 'Did not receive a new-line at the end of a bulk response'
));
}
self::discardNewLine($connection);
return $value;
}
else if ($dataLength == 0) {
if ($connection->readBytes(2) !== ResponseReader::NEWLINE) {
Utilities\Shared::onCommunicationException(new MalformedServerResponse(
$connection, 'Did not receive a new-line at the end of a bulk response'
));
}
self::discardNewLine($connection);
return '';
}
return null;
}
private static function discardNewLine(Connection $connection) {
if ($connection->readBytes(2) !== ResponseReader::NEWLINE) {
Utilities\Shared::onCommunicationException(new MalformedServerResponse(
$connection, 'Did not receive a new-line at the end of a bulk response'
));
}
}
}
class ResponseMultiBulkHandler implements IResponseHandler {