Skip to content

Commit 01ae9f7

Browse files
authored
Merge pull request #251 from clue-labs/io
Move `@internal` classes to `React\Http\Io` namespace
2 parents 767e855 + f94fe44 commit 01ae9f7

26 files changed

Lines changed: 140 additions & 63 deletions
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<?php
2-
namespace React\Http;
2+
3+
namespace React\Http\Io;
34

45
use Evenement\EventEmitter;
56
use React\Stream\ReadableStreamInterface;
6-
use React\Stream\WritableStreamInterface;
77
use React\Stream\Util;
8+
use React\Stream\WritableStreamInterface;
89
use Exception;
910

10-
/** @internal */
11+
/**
12+
* [Internal] Decodes "Transfer-Encoding: chunked" from given stream and returns only payload data.
13+
*
14+
* This is used internally to decode incoming requests with this encoding.
15+
*
16+
* @internal
17+
*/
1118
class ChunkedDecoder extends EventEmitter implements ReadableStreamInterface
1219
{
1320
const CRLF = "\r\n";
Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
<?php
22

3-
namespace React\Http;
3+
namespace React\Http\Io;
44

55
use Evenement\EventEmitter;
66
use React\Stream\ReadableStreamInterface;
7-
use React\Stream\WritableStreamInterface;
87
use React\Stream\Util;
8+
use React\Stream\WritableStreamInterface;
99

10-
/** @internal */
10+
/**
11+
* [Internal] Encodes given payload stream with "Transfer-Encoding: chunked" and emits encoded data
12+
*
13+
* This is used internally to encode outgoing requests with this encoding.
14+
*
15+
* @internal
16+
*/
1117
class ChunkedEncoder extends EventEmitter implements ReadableStreamInterface
1218
{
1319
private $input;
Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
<?php
22

3-
namespace React\Http;
3+
namespace React\Http\Io;
44

55
use Evenement\EventEmitter;
66
use React\Stream\ReadableStreamInterface;
7-
use React\Stream\WritableStreamInterface;
87
use React\Stream\Util;
8+
use React\Stream\WritableStreamInterface;
99

10-
/** @internal
11-
* This stream is used to protect the passed stream against closing.
10+
/**
11+
* [Internal] Protects a given stream from actually closing and only pauses it instead.
12+
*
13+
* This is used internally to prevent the underlying connection from closing, so
14+
* that we can still send back a response over the same stream.
15+
*
16+
* @internal
1217
* */
1318
class CloseProtectionStream extends EventEmitter implements ReadableStreamInterface
1419
{
Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,28 @@
11
<?php
2-
namespace React\Http;
32

3+
namespace React\Http\Io;
4+
5+
use Evenement\EventEmitter;
46
use Psr\Http\Message\StreamInterface;
57
use React\Stream\ReadableStreamInterface;
6-
use React\Stream\WritableStreamInterface;
7-
use Evenement\EventEmitter;
88
use React\Stream\Util;
9+
use React\Stream\WritableStreamInterface;
910

1011
/**
12+
* [Internal] Bridge between StreamInterface from PSR-7 and ReadableStreamInterface from ReactPHP
13+
*
14+
* This class is used in the server to stream the body of an incoming response
15+
* from the client. This allows us to stream big amounts of data without having
16+
* to buffer this data. Similarly, this used to stream the body of an outgoing
17+
* request body to the client. The data will be sent directly to the client.
18+
*
19+
* Note that this is an internal class only and nothing you should usually care
20+
* about. See the `StreamInterface` and `ReadableStreamInterface` for more
21+
* details.
22+
*
23+
* @see StreamInterface
24+
* @see ReadableStreamInterface
1125
* @internal
12-
* Uses a StreamInterface from PSR-7 and a ReadableStreamInterface from ReactPHP
13-
* to use PSR-7 objects and use ReactPHP streams
14-
* This is class is used in `HttpServer` to stream the body of a response
15-
* to the client. Because of this you can stream big amount of data without
16-
* necessity of buffering this data. The data will be send directly to the client.
1726
*/
1827
class HttpBodyStream extends EventEmitter implements StreamInterface, ReadableStreamInterface
1928
{
@@ -22,8 +31,8 @@ class HttpBodyStream extends EventEmitter implements StreamInterface, ReadableSt
2231
private $size;
2332

2433
/**
25-
* @param ReadableStreamInterface $input - Stream data from $stream as a body of a PSR-7 object4
26-
* @param int|null $size - size of the data body
34+
* @param ReadableStreamInterface $input Stream data from $stream as a body of a PSR-7 object4
35+
* @param int|null $size size of the data body
2736
*/
2837
public function __construct(ReadableStreamInterface $input, $size)
2938
{
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
11
<?php
22

3-
namespace React\Http;
3+
namespace React\Http\Io;
44

55
use Evenement\EventEmitter;
66
use React\Stream\ReadableStreamInterface;
7-
use React\Stream\WritableStreamInterface;
87
use React\Stream\Util;
8+
use React\Stream\WritableStreamInterface;
99

10-
/** @internal */
10+
/**
11+
* [Internal] Limits the amount of data the given stream can emit
12+
*
13+
* This is used internally to limit the size of the underlying connection stream
14+
* to the size defined by the "Content-Length" header of the incoming request.
15+
*
16+
* @internal
17+
*/
1118
class LengthLimitedStream extends EventEmitter implements ReadableStreamInterface
1219
{
1320
private $stream;
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
<?php
22

3-
namespace React\Http\Middleware;
3+
namespace React\Http\Io;
44

55
use Psr\Http\Message\ServerRequestInterface;
6-
use React\Http\HttpBodyStream;
7-
use React\Http\UploadedFile;
86
use RingCentral\Psr7;
97

108
/**
9+
* [Internal] Parses a string body with "Content-Type: multipart/form-data" into structured data
10+
*
11+
* This is use internally to parse incoming request bodies into structured data
12+
* that resembles PHP's `$_POST` and `$_FILES` superglobals.
13+
*
1114
* @internal
1215
*/
1316
final class MultipartParser
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
<?php
22

3-
namespace React\Http;
3+
namespace React\Http\Io;
44

55
use Evenement\EventEmitter;
6-
use Exception;
76
use RingCentral\Psr7 as g7;
7+
use Exception;
88

99
/**
10+
* [Internal] Parses an incoming request header from an input stream
11+
*
12+
* This is used internally to parse the request header from the connection and
13+
* then process the remaining connection as the request body.
14+
*
1015
* @event headers
1116
* @event error
1217
*
Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
<?php
22

3-
namespace React\Http;
3+
namespace React\Http\Io;
44

55
use Psr\Http\Message\ServerRequestInterface;
66
use RingCentral\Psr7\Request;
77

8-
/** @internal */
8+
/**
9+
* [Internal] Implementation of the PSR-7 `ServerRequestInterface`
10+
*
11+
* This is used internally to represent each incoming request message.
12+
*
13+
* This implementation builds on top of an existing outgoing request message and
14+
* only adds required server methods.
15+
*
16+
* Note that this is an internal class only and nothing you should usually care
17+
* about. See the `ServerRequestInterface` for more details.
18+
*
19+
* @see ServerRequestInterface
20+
* @internal
21+
*/
922
class ServerRequest extends Request implements ServerRequestInterface
1023
{
1124
private $attributes = array();
Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,21 @@
11
<?php
22

3-
namespace React\Http;
3+
namespace React\Http\Io;
44

5-
use InvalidArgumentException;
65
use Psr\Http\Message\StreamInterface;
76
use Psr\Http\Message\UploadedFileInterface;
7+
use InvalidArgumentException;
88
use RuntimeException;
99

1010
/**
11+
* [Internal] Implementation of the PSR-7 `UploadedFileInterface`
12+
*
13+
* This is used internally to represent each incoming file upload.
14+
*
15+
* Note that this is an internal class only and nothing you should usually care
16+
* about. See the `UploadedFileInterface` for more details.
17+
*
18+
* @see UploadedFileInterface
1119
* @internal
1220
*/
1321
final class UploadedFile implements UploadedFileInterface

src/Middleware/RequestBodyParserMiddleware.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace React\Http\Middleware;
44

55
use Psr\Http\Message\ServerRequestInterface;
6+
use React\Http\Io\MultipartParser;
67

78
final class RequestBodyParserMiddleware
89
{

0 commit comments

Comments
 (0)