Skip to content

Commit

Permalink
update 3.23.11
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangtingwei998 committed Nov 30, 2023
1 parent 6705ce3 commit cc2b1a6
Show file tree
Hide file tree
Showing 24 changed files with 11,417 additions and 10,706 deletions.
27 changes: 14 additions & 13 deletions Obs/Internal/Common/CheckoutStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,43 +21,44 @@
use GuzzleHttp\Psr7\StreamDecoratorTrait;
use Obs\ObsException;

class CheckoutStream implements StreamInterface {
class CheckoutStream implements StreamInterface
{
use StreamDecoratorTrait;

private $expectedLength;
private $readedCount = 0;

public function __construct(StreamInterface $stream, $expectedLength) {
public function __construct(StreamInterface $stream, $expectedLength)
{
$this->stream = $stream;
$this->expectedLength = $expectedLength;
}

public function getContents() {
public function getContents()
{
$contents = $this->stream->getContents();
$length = strlen($contents);
if ($this->expectedLength !== null && floatval($length) !== $this->expectedLength) {
$this -> throwObsException($this->expectedLength, $length);
$this->throwObsException($this->expectedLength, $length);
}
return $contents;
}

public function read($length) {
public function read($length)
{
$string = $this->stream->read($length);
if ($this->expectedLength !== null) {
$this->readedCount += strlen($string);
if ($this->stream->eof()) {
if (floatval($this->readedCount) !== $this->expectedLength) {
$this -> throwObsException($this->expectedLength, $this->readedCount);
}
if ($this->stream->eof() && floatval($this->readedCount) !== $this->expectedLength) {
$this->throwObsException($this->expectedLength, $this->readedCount);
}
}
}
return $string;
}

public function throwObsException($expectedLength, $reaLength) {
public function throwObsException($expectedLength, $reaLength)
{
$obsException = new ObsException('premature end of Content-Length delimiter message body (expected:' . $expectedLength . '; received:' . $reaLength . ')');
$obsException->setExceptionType('server');
throw $obsException;
}
}

4 changes: 2 additions & 2 deletions Obs/Internal/Common/ITransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

namespace Obs\Internal\Common;

interface ITransform {
interface ITransform
{
public function transform($sign, $para);
}

Loading

0 comments on commit cc2b1a6

Please sign in to comment.