<?php
Swoole\Http\Response->goaway(int $error_code, string $debug_data)
HTTP2 error_code
SW_HTTP2_ERROR_NO_ERROR = 0,
SW_HTTP2_ERROR_PROTOCOL_ERROR = 1,
SW_HTTP2_ERROR_INTERNAL_ERROR = 2,
SW_HTTP2_ERROR_FLOW_CONTROL_ERROR = 3,
SW_HTTP2_ERROR_SETTINGS_TIMEOUT = 4,
SW_HTTP2_ERROR_STREAM_CLOSED = 5,
SW_HTTP2_ERROR_FRAME_SIZE_ERROR = 6,
SW_HTTP2_ERROR_REFUSED_STREAM = 7,
SW_HTTP2_ERROR_CANCEL = 8,
SW_HTTP2_ERROR_COMPRESSION_ERROR = 9,
SW_HTTP2_ERROR_CONNECT_ERROR = 10,
SW_HTTP2_ERROR_ENHANCE_YOUR_CALM = 11,
SW_HTTP2_ERROR_INADEQUATE_SECURITY = 12
HTTP2 debug message in the GOAWAY packet
This method is only avaiable to HTTP2 servers.
Send HTTP2 GOAWAY
packet to the HTTP2 client, then disconnect the connection gracefully after processing all existing requests.
This method must be called before the
$response->end
method.
<?php
$http = new Swoole\HTTP\Server('127.0.0.1', 9090, SWOOLE_BASE);
$http->set([
'worker_num' => 1,
'log_file' => '/dev/null',
'open_http2_protocol' => true
]);
$http->on('request', function (Swoole\HTTP\Request $request, Swoole\HTTP\Response $response) {
$response->goaway(SWOOLE_HTTP2_ERROR_NO_ERROR, 'NO_ERROR');
$response->end($request->rawcontent());
});
$http->start();