Releases: amphp/http-server
2.0.0 RC2
Note: This is a pre-release, there might be breaking changes in the final stable version.
- HTTP/2 protocol is now declared as "2" instead of "2.0" in requests and responses (see https://http2.github.io/faq/#is-it-http20-or-http2).
- Added
Request::getAttributes()to retrieve an array of all request attributes andRequest::removeAttribute()to remove an attribute.
2.0.0 RC1
This is the first release candidate of amphp/http-client v2.0.
Note: This is a pre-release, there might be breaking changes in the final stable version.
This release provides compatibility with amphp/socket v1.0. Please see the amphp/socket release notes for more information on changes in that library. Some minor compatibility breaks were required.
Summary of changes from v1.x to v2.0
- Upgrade callbacks (those set with
Response::upgrade()) now receive an instance ofAmp\Socket\EncryptableSocket, an interface extendingAmp\Socket\Socket, as the parameter to the callback function. Upgrade callback are now run as a coroutine if a generater is returned. Coroutine (or promise returned from the callback) failures are logged to the server log. Driver\Clientreturns an instance ofAmp\Socket\SocketAddressfromgetLocalAddress()andgetRemoteAddress(). The methodsgetLocalPort()andgetRemotePort()have been removed. The IP address and port are available on the instance ofSocketAddressreturned.Driver\Client::getCryptoContext()has been replaced withgetTlsInfo(), which now returns an instance ofAmp\Socket\TlsInfofor encrypted clients ornullfor plaintext clients.Driver\Client::isUnix()has been removed. Instead usegetLocalAddress()and check for the return ofSocketAddress::getPort()to be null.
Trailers
The Trailers object has been refactored to contain a list of header declared trailer fields (which may be empty) and a promise for an Amp\Http\Message object containing the future trailer values. Trailers in requests have been moved from the request body to the Request object. Request::getTrailers() returns a Trailers object having two methods:
getFields(): Returns an array of declared trailer fields (this list may be empty, but still receive trailers).awaitMessage(): Returns a promise that is resolved with aAmp\Http\Messageinstance once all trailers have been received.
Trailers are now supported in responses. A new Response constructor parameter or Response::setTrailers(Trailers $trailers) may be used to set a Trailers object for the response. The promise provided to the Trailers constructor should be resolved with an array of header values indexed by the header field name, similar to header field array provided to the Response constructor or Response::setHeaders().
Other backward compatibility breaks unlikely to affect application code
Driver\Http1DriverandDriver\Http2Driverconstructors now require an instance ofPsr\Log\LoggerInterfaceas the final parameter.Promiseparameter forTrailersobject removed fromRequestBodyconstructor.voidreturns added tostart(),onClose(), andclose()methods inDriver\Clientinterface.voidreturn added toTimeReference::onTimeUpdate().- HTTP/2 pseudo headers (header fields starting with a colon (:) such as
:methodor:status) cannot be used inRequestandResponse. Accordingly, these header fields are no longer included in requests generated by the server. The values of these headers are used to populate request properties and should be accessed by getters inRequest.
Upgrading from v1.x
We believe only minor changes will be necessary for applications to upgrade from v1.x to v2.0. As trailers and upgrade responses are uncommon for applications, the most likely concern for upgraders is the shift to SocketAddress in Client::getLocalAddress() and Client::getRemoteAddress(), as well as the changes made in amphp/socket v1.0.
1.1.2
1.1.1
- Fixed cases where the HTTP/2 driver was not in conformance with the specification. Conformance is now checked automatically on each Travis build with h2spec. These fixes include (but are not limited to) the following:
- Requests with unknown or duplicate pseudo-headers are now rejected.
- Bodies not matching a given
content-lengthheader now fail with aClientException. - Fix a bug in handling window updates resulting in a negative stream window.
- Receiving any non-continuation frame between continuation frames rejects the request.
- Requests with multiple
content-lengthheaders are now rejected (HTTP/1.x and HTTP/2). - Multiple
transfer-encodingheaders are now combined before being examined by the parser (generally resulting in a rejected request) (HTTP/1.x).
1.1.0
- Added
redirectTo()andMovedResourceHandlerfor easier redirects. - Added
ClientFactoryto allow switching the client implementation. - Increased default HTTP/2 stream limits.
- Improved body buffer handling.
- Rethrow exceptions from
onClosecallbacks and execute them as coroutines. - Fixed connection timeout handling closing connections prematurely.
1.0.1
1.0.0
0.8.3
0.8.2
- Fixed an issue when an HTTP/2 response is written immediately (#258).
- Performance recommendations are now logged as warnings when starting the server depending the mode set in options (debug or production), the value of the zend.assertions ini setting, and if the xdebug extension is loaded (related to #256).
Request::setBody()andResponse::setBody()now additionally accepts any value that can be cast to a string (such as integers, floats, and objects with a__toString()method) as the body content (#254).
0.8.1
- Fixed an issue where latency was increased dramatically on some systems compared to v0.7.x (#252).
- Fixed the
content-lengthheader being removed byCompressionMiddlewareif the body was not long enough to be compressed. ExceptionMiddlewarenow writes the exception to the log to mimic the default behavior if it were not used.