|
1 | 1 | # Changelog |
2 | 2 |
|
3 | | -## 0.6.0 (2016-03-09) |
| 3 | +## 0.7.0 (2017-05-29) |
| 4 | + |
| 5 | +* Feature / BC break: Use PSR-7 (http-message) standard and |
| 6 | + `Request-In-Response-Out`-style request handler callback. |
| 7 | + Pass standard PSR-7 `ServerRequestInterface` and expect any standard |
| 8 | + PSR-7 `ResponseInterface` in return for the request handler callback. |
| 9 | + (#146 and #152 and #170 by @legionth) |
| 10 | + |
| 11 | + ```php |
| 12 | + // old |
| 13 | + $app = function (Request $request, Response $response) { |
| 14 | + $response->writeHead(200, array('Content-Type' => 'text/plain')); |
| 15 | + $response->end("Hello world!\n"); |
| 16 | + }; |
| 17 | + |
| 18 | + // new |
| 19 | + $app = function (ServerRequestInterface $request) { |
| 20 | + return new Response( |
| 21 | + 200, |
| 22 | + array('Content-Type' => 'text/plain'), |
| 23 | + "Hello world!\n" |
| 24 | + ); |
| 25 | + }; |
| 26 | + ``` |
| 27 | + |
| 28 | + A `Content-Length` header will automatically be included if the size can be |
| 29 | + determined from the response body. |
| 30 | + (#164 by @maciejmrozinski) |
| 31 | + |
| 32 | + The request handler callback will automatically make sure that responses to |
| 33 | + HEAD requests and certain status codes, such as `204` (No Content), never |
| 34 | + contain a response body. |
| 35 | + (#156 by @clue) |
| 36 | + |
| 37 | + The intermediary `100 Continue` response will automatically be sent if |
| 38 | + demanded by a HTTP/1.1 client. |
| 39 | + (#144 by @legionth) |
| 40 | + |
| 41 | + The request handler callback can now return a standard `Promise` if |
| 42 | + processing the request needs some time, such as when querying a database. |
| 43 | + Similarly, the request handler may return a streaming response if the |
| 44 | + response body comes from a `ReadableStreamInterface` or its size is |
| 45 | + unknown in advance. |
| 46 | + |
| 47 | + ```php |
| 48 | + // old |
| 49 | + $app = function (Request $request, Response $response) use ($db) { |
| 50 | + $db->query()->then(function ($result) use ($response) { |
| 51 | + $response->writeHead(200, array('Content-Type' => 'text/plain')); |
| 52 | + $response->end($result); |
| 53 | + }); |
| 54 | + }; |
| 55 | + |
| 56 | + // new |
| 57 | + $app = function (ServerRequestInterface $request) use ($db) { |
| 58 | + return $db->query()->then(function ($result) { |
| 59 | + return new Response( |
| 60 | + 200, |
| 61 | + array('Content-Type' => 'text/plain'), |
| 62 | + $result |
| 63 | + ); |
| 64 | + }); |
| 65 | + }; |
| 66 | + ``` |
| 67 | + |
| 68 | + Pending promies and response streams will automatically be canceled once the |
| 69 | + client connection closes. |
| 70 | + (#187 and #188 by @clue) |
| 71 | + |
| 72 | + The `ServerRequestInterface` contains the full effective request URI, |
| 73 | + server-side parameters, query parameters and parsed cookies values as |
| 74 | + defined in PSR-7. |
| 75 | + (#167 by @clue and #174, #175 and #180 by @legionth) |
| 76 | + |
| 77 | + ```php |
| 78 | + $app = function (ServerRequestInterface $request) { |
| 79 | + return new Response( |
| 80 | + 200, |
| 81 | + array('Content-Type' => 'text/plain'), |
| 82 | + $request->getUri()->getScheme() |
| 83 | + ); |
| 84 | + }; |
| 85 | + ``` |
| 86 | + |
| 87 | + Advanced: Support duplex stream response for `Upgrade` requests such as |
| 88 | + `Upgrade: WebSocket` or custom protocols and `CONNECT` requests |
| 89 | + (#189 and #190 by @clue) |
| 90 | + |
| 91 | + > Note that the request body will currently not be buffered and parsed by |
| 92 | + default, which depending on your particilar use-case, may limit |
| 93 | + interoperability with the PSR-7 (http-message) ecosystem. |
| 94 | + The provided streaming request body interfaces allow you to perform |
| 95 | + buffering and parsing as needed in the request handler callback. |
| 96 | + See also the README and examples for more details. |
| 97 | + |
| 98 | +* Feature / BC break: Replace `request` listener with callback function and |
| 99 | + use `listen()` method to support multiple listening sockets |
| 100 | + (#97 by @legionth and #193 by @clue) |
| 101 | + |
| 102 | + ```php |
| 103 | + // old |
| 104 | + $server = new Server($socket); |
| 105 | + $server->on('request', $app); |
| 106 | + |
| 107 | + // new |
| 108 | + $server = new Server($app); |
| 109 | + $server->listen($socket); |
| 110 | + ``` |
| 111 | + |
| 112 | +* Feature: Support the more advanced HTTP requests, such as |
| 113 | + `OPTIONS * HTTP/1.1` (`OPTIONS` method in asterisk-form), |
| 114 | + `GET http://example.com/path HTTP/1.1` (plain proxy requests in absolute-form), |
| 115 | + `CONNECT example.com:443 HTTP/1.1` (`CONNECT` proxy requests in authority-form) |
| 116 | + and sanitize `Host` header value across all requests. |
| 117 | + (#157, #158, #161, #165, #169 and #173 by @clue) |
| 118 | + |
| 119 | +* Feature: Forward compatibility with Socket v1.0, v0.8, v0.7 and v0.6 and |
| 120 | + forward compatibility with Stream v1.0 and v0.7 |
| 121 | + (#154, #163, #183, #184 and #191 by @clue) |
| 122 | + |
| 123 | +* Feature: Simplify examples to ease getting started and |
| 124 | + add benchmarking example |
| 125 | + (#151 and #162 by @clue) |
| 126 | + |
| 127 | +* Improve test suite by adding tests for case insensitive chunked transfer |
| 128 | + encoding and ignoring HHVM test failures until Travis tests work again. |
| 129 | + (#150 by @legionth and #185 by @clue) |
| 130 | + |
| 131 | +## 0.6.0 (2017-03-09) |
4 | 132 |
|
5 | 133 | * Feature / BC break: The `Request` and `Response` objects now follow strict |
6 | 134 | stream semantics and their respective methods and events. |
|
0 commit comments