| 1 | package Linux::Event::HTTP::_HTTP2::ServerConnection; | ||
| 2 | use v5.36; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use parent 'Linux::Event::IO::Sock::Stream'; | ||
| 7 | |||
| 8 | our $VERSION = '0.003'; | ||
| 9 | |||
| 10 | sub on_data ($self, $bytes) { | ||
| 11 | my $executor = $self->{_http2_executor} | ||
| 12 | or die 'HTTP/2 server connection has no executor'; | ||
| 13 | |||
| 14 | my $ok = eval { | ||
| 15 | $executor->input($bytes); | ||
| 16 | 1; | ||
| 17 | }; | ||
| 18 | if (!$ok) { | ||
| 19 | my $error = "$@"; | ||
| 20 | $error =~ s/\s+\z//; | ||
| 21 | $executor->close if $executor->can('close'); | ||
| 22 | delete $self->{_http2_executor}; | ||
| 23 | $self->close if !$self->is_closed; | ||
| 24 | } | ||
| 25 | return; | ||
| 26 | } | ||
| 27 | |||
| 28 | sub on_close ($self) { | ||
| 29 | if (my $executor = delete $self->{_http2_executor}) { | ||
| 30 | $executor->close; | ||
| 31 | } | ||
| 32 | return; | ||
| 33 | } | ||
| 34 | |||
| 35 | sub transaction ($self) { | ||
| 36 | my $executor = $self->{_http2_executor} or return undef; | ||
| 37 | return $executor->transaction; | ||
| 38 | } | ||
| 39 | |||
| 40 | 1; | ||
| 41 | |||
| 42 | __END__ |