NAME
Unblock::HTTP2::Server - one HTTP/2 server connection
SYNOPSIS
use Uniform::HTTP::Response;
use Unblock::HTTP2::Server;
my $server = Unblock::HTTP2::Server->new(
on_request => sub {
my ($transaction, $request) = @_;
$transaction->respond(
Uniform::HTTP::Response->new(
status => 200,
body => "hello\n",
),
);
},
);
DESCRIPTION
A Server owns one HTTP/2 server session.
It does not create a listening socket, own an accepted socket, perform TLS, or run an event loop.
Feed received HTTP/2 bytes to input(). Drain generated bytes from output() while want_write() is true.
CONSTRUCTOR
new() accepts an initial settings hash, max_concurrent_streams, max_header_list_size, and enable_connect_protocol.
Connection callbacks are:
on_settings($server, $peer_settings, $changed_settings)
on_settings_ack($server, $acked_settings)
on_ping($server, $opaque)
on_ping_ack($server, $opaque)
on_priority($server, $stream_id, $field_value)
on_invalid_frame($server, $frame, $lib_error_code)
REQUEST CALLBACKS
Request callbacks are:
on_request($transaction, $request)
on_body($transaction, $request, $bytes)
on_request_end($transaction, $request)
on_error($transaction, $error, $error_code)
on_request runs when the request headers have been accepted. on_request_end runs after the complete request and any trailers have arrived. $error_code can be undefined when there is no HTTP/2 reset code. $transaction can be undefined for an error that occurs before a Transaction exists.
Use send_informational() for informational responses and respond() for the final response.
CONNECTION CONTROL
The Server exposes the common connection methods:
is_closed
close_reason
transaction_count
transaction_for_stream_id
local_settings
local_setting
peer_settings
peer_setting
update_settings
settings_pending
ping
draining
drain
goaway
local_goaway
peer_goaway
want_read
want_write
input
output
close
The server can also observe RFC 9218 priority updates with on_priority.
SEE ALSO
Unblock::HTTP2, Unblock::HTTP2::Transaction, Uniform::HTTP::Response
LICENSE
MIT License.