OpenSwoole 26.11.1 adds the HTTP QUERY method, supports CURLOPT_PROTOCOLS_STR in the coroutine curl hook, updates the bundled HTTP parser to llhttp 9.4.4, and fixes bugs in the HTTP, HTTP/2 and WebSocket servers. We recommend that all users of OpenSwoole 26.x upgrade.
You can upgrade to OpenSwoole v26.11.1 now:
pecl install openswoole-26.11.1
Or install it with PIE:
pie install openswoole/ext-openswoole
Or use Docker images:
docker pull openswoole/openswoole:26.11-php8.6-alpine
Find more OpenSwoole docker images at OpenSwoole Docker images at Docker Hub
The HTTP server supports the QUERY method from RFC 10008, a safe and idempotent method that carries the query in the request body. Form bodies sent with QUERY are parsed into $request->post the same way as for POST, PUT, PATCH and DELETE (#414):
use OpenSwoole\Http\Server;
$server = new Server('0.0.0.0', 9501);
$server->on('Request', function (OpenSwoole\Http\Request $request, OpenSwoole\Http\Response $response) {
if ($request->getMethod() === 'QUERY') {
$response->end(json_encode($request->post));
return;
}
$response->end('OK');
});
$server->start();
The coroutine HTTP client can send it with $client->setMethod('QUERY').
curl_setopt() accepts CURLOPT_PROTOCOLS_STR and CURLOPT_REDIR_PROTOCOLS_STR with SWOOLE_HOOK_NATIVE_CURL (libcurl 7.85 or later), the string options that replace the deprecated CURLOPT_PROTOCOLS and CURLOPT_REDIR_PROTOCOLS (#412):
use OpenSwoole\Runtime;
Runtime::enableCoroutine(Runtime::HOOK_ALL);
co::run(function () {
$ch = curl_init('https://openswoole.com/');
curl_setopt($ch, CURLOPT_PROTOCOLS_STR, 'https');
curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS_STR, 'https');
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_exec($ch);
});
When open_basedir is set, a value that contains file or all is refused with a warning, as in native PHP.
openswoole.so, so it cannot collide with the libnghttp2 that other extensions loadPHP 8.6.0 is now released, and the PHP 8.6 Docker images are built on PHP 8.6.0 instead of the release candidate. The PHP 8.6 Alpine images are built without linux/arm/v6 until the official PHP 8.6 Alpine image is available for that platform.
The HTTP parser is stricter: requests with a space between a header name and the colon, folded header lines, or raw bytes above 0x7F in the request target get 400 Bad Request. Encode such bytes in the URL with percent-encoding instead. The coroutine HTTP client applies the same rules to responses.
The WebSocket server follows RFC 6455 more closely: frames from a client must be masked, and unknown opcodes or a new message sent before a fragmented one is finished close the connection. Ping, pong and close frames accept payloads up to the 125 bytes the RFC allows. A coroutine HTTP client with websocket_mask set to false can no longer send to an OpenSwoole WebSocket server.
The HTTP/2 server rejects frames on a stream the client has closed, removes the padding of DATA frames, checks WINDOW_UPDATE increments, and with send_yield waits for the stream window before sending. The HTTP/2 server and client reject header blocks with invalid Huffman padding, as RFC 7541 requires.
SOCKS5 proxy target hosts, usernames and passwords longer than 255 bytes are refused, and a refused CONNECT reply fails the connection.
SWOOLE_PROCESS modeRequest::create()->parse() with a multipart bodyResponse::create() with a Coroutine\SocketContent-Length: 0 that do not end with a zero length chunkssl_client_cert_filemax_connectionsend_yield responses not ending when a send fails or the client resets the stream or closes the connectionGOAWAY frames carrying the error code in the flagsDATA frames not counting against the connection windowbuffer_high_watermark and buffer_low_watermark being reset when the server starts$row argument of the PostgreSQL statement fetch methods being ignoredLock becoming unusable in other processes after a child process exits, or after destroy() is called in another processTable losing rows with concurrent writers after a child process exitsLock::lockwait() requiring an argumentopen_redis_protocol parser with null bulk strings, integer elements, empty arrays and bulk lengths below -1Coroutine\Client::peek() with a length of 0 or lesscurl_setopt_array() not stopping at a refused option in the coroutine curl hookThanks to Martin Fris for the llhttp upgrade, the QUERY method and the curl protocol options.
If you need to install OpenSwoole or look at other update methods, checkout the installation documentation and how to update Open Swoole. The changes that can affect existing applications are listed in the upgrade guide.
Install the core library, which fixes socket_last_error() and socket_clear_error() with the sockets hook:
composer require openswoole/core:26.11.1
Join 4,000+ others and never miss out on new tips, tutorials, and more.