Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/Io/ChunkedDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public function close()
public function handleEnd()
{
if (!$this->closed) {
$this->handleError(new \Exception('Unexpected end event'));
$this->handleError(new Exception('Unexpected end event'));
}
}

/** @internal */
public function handleError(\Exception $e)
public function handleError(Exception $e)
{
$this->emit('error', array($e));
$this->close();
Expand All @@ -102,7 +102,7 @@ public function handleData($data)
if ($positionCrlf === false) {
// Header shouldn't be bigger than 1024 bytes
if (isset($this->buffer[static::MAX_CHUNK_HEADER_SIZE])) {
$this->handleError(new \Exception('Chunk header size inclusive extension bigger than' . static::MAX_CHUNK_HEADER_SIZE. ' bytes'));
$this->handleError(new Exception('Chunk header size inclusive extension bigger than' . static::MAX_CHUNK_HEADER_SIZE. ' bytes'));
}
return;
}
Expand All @@ -124,7 +124,7 @@ public function handleData($data)

$this->chunkSize = hexdec($hexValue);
if (dechex($this->chunkSize) !== $hexValue) {
$this->handleError(new \Exception($hexValue . ' is not a valid hexadecimal number'));
$this->handleError(new Exception($hexValue . ' is not a valid hexadecimal number'));
return;
}

Expand Down Expand Up @@ -159,7 +159,7 @@ public function handleData($data)

if ($positionCrlf !== 0 && $this->chunkSize === $this->transferredSize && strlen($this->buffer) > 2) {
// the first 2 characters are not CLRF, send error event
$this->handleError(new \Exception('Chunk does not end with a CLRF'));
$this->handleError(new Exception('Chunk does not end with a CLRF'));
return;
}

Expand Down
2 changes: 1 addition & 1 deletion src/Io/CloseProtectionStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* */
class CloseProtectionStream extends EventEmitter implements ReadableStreamInterface
{
private $connection;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! Apparently, this should be replaced with $input which is used in the constructor 👍

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

private $input;
private $closed = false;

/**
Expand Down
1 change: 0 additions & 1 deletion src/Io/LengthLimitedStream.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class LengthLimitedStream extends EventEmitter implements ReadableStreamInterfac
{
private $stream;
private $closed = false;
private $encoder;
private $transferredLength = 0;
private $maxLength;

Expand Down
6 changes: 3 additions & 3 deletions src/Io/MultipartParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
}

return new UploadedFile(
Psr7\stream_for(''),
Psr7\stream_for(),
$size,
UPLOAD_ERR_NO_FILE,
$filename,
Expand All @@ -206,7 +206,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
// file exceeds "upload_max_filesize" ini setting
if ($size > $this->uploadMaxFilesize) {
return new UploadedFile(
Psr7\stream_for(''),
Psr7\stream_for(),
$size,
UPLOAD_ERR_INI_SIZE,
$filename,
Expand All @@ -217,7 +217,7 @@ private function parseUploadedFile($filename, $contentType, $contents)
// file exceeds MAX_FILE_SIZE value
if ($this->maxFileSize !== null && $size > $this->maxFileSize) {
return new UploadedFile(
Psr7\stream_for(''),
Psr7\stream_for(),
$size,
UPLOAD_ERR_FORM_SIZE,
$filename,
Expand Down
4 changes: 3 additions & 1 deletion src/Io/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace React\Http\Io;

use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UriInterface;
use RingCentral\Psr7\Request;

/**
Expand Down Expand Up @@ -37,7 +39,7 @@ class ServerRequest extends Request implements ServerRequestInterface
* @param string $protocolVersion HTTP protocol version.
* @param array server-side parameters
*
* @throws InvalidArgumentException for an invalid URI
* @throws \InvalidArgumentException for an invalid URI
*/
public function __construct(
$method,
Expand Down
4 changes: 2 additions & 2 deletions src/StreamingServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public function handleRequest(ConnectionInterface $conn, ServerRequestInterface
$string = $request->getHeaderLine('Content-Length');

$contentLength = (int)$string;
if ((string)$contentLength !== (string)$string) {
if ((string)$contentLength !== $string) {
// Content-Length value is not an integer or not a single integer
$this->emit('error', array(new \InvalidArgumentException('The value of `Content-Length` is not valid')));
return $this->writeError($conn, 400, $request);
Expand Down Expand Up @@ -355,7 +355,7 @@ public function handleResponse(ConnectionInterface $connection, ServerRequestInt
// response to HEAD and 1xx, 204 and 304 responses MUST NOT include a body
// exclude status 101 (Switching Protocols) here for Upgrade request handling below
if ($request->getMethod() === 'HEAD' || $code === 100 || ($code > 101 && $code < 200) || $code === 204 || $code === 304) {
$response = $response->withBody(Psr7Implementation\stream_for(''));
$response = $response->withBody(Psr7Implementation\stream_for());
}

// 101 (Switching Protocols) response uses Connection: upgrade header
Expand Down