@@ -25,7 +25,7 @@ $loop = React\EventLoop\Factory::create();
2525$socket = new React\Socket\Server(8080, $loop);
2626
2727$http = new React\Http\Server($socket);
28- $http->on('request', function ($request, $response) {
28+ $http->on('request', function (Request $request, Response $response) {
2929 $response->writeHead(200, array('Content-Type' => 'text/plain'));
3030 $response->end("Hello World!\n");
3131});
@@ -39,7 +39,30 @@ See also the [examples](examples).
3939
4040### Server
4141
42- See the above usage example and the class outline for details.
42+ The ` Server ` class is responsible for handling incoming connections and then
43+ emit a ` request ` event for each incoming HTTP request.
44+
45+ It attaches itself to an instance of ` React\Socket\ServerInterface ` which
46+ emits underlying streaming connections in order to then parse incoming data
47+ as HTTP:
48+
49+ ``` php
50+ $socket = new React\Socket\Server(8080, $loop);
51+
52+ $http = new React\Http\Server($socket);
53+ ```
54+
55+ For each incoming connection, it emits a ` request ` event with the respective
56+ [ ` Request ` ] ( #request ) and [ ` Response ` ] ( #response ) objects:
57+
58+ ``` php
59+ $http->on('request', function (Request $request, Response $response) {
60+ $response->writeHead(200, array('Content-Type' => 'text/plain'));
61+ $response->end("Hello World!\n");
62+ });
63+ ```
64+
65+ See also [ ` Request ` ] ( #request ) and [ ` Response ` ] ( #response ) for more details.
4366
4467### Request
4568
@@ -48,6 +71,9 @@ and contains meta data which was parsed from the request headers.
4871
4972It implements the ` ReadableStreamInterface ` .
5073
74+ The constructor is internal, you SHOULD NOT call this yourself.
75+ The ` Server ` is responsible for emitting ` Request ` and ` Response ` objects.
76+
5177See the above usage example and the class outline for details.
5278
5379#### getMethod()
@@ -116,6 +142,9 @@ The `Response` class is responsible for streaming the outgoing response body.
116142
117143It implements the ` WritableStreamInterface ` .
118144
145+ The constructor is internal, you SHOULD NOT call this yourself.
146+ The ` Server ` is responsible for emitting ` Request ` and ` Response ` objects.
147+
119148See the above usage example and the class outline for details.
120149
121150#### writeContinue()
0 commit comments