NAME

Unblock::HTTP1 - Portable non-blocking HTTP/1 protocol engine

SYNOPSIS

use Uniform::HTTP::Request;
use Unblock::HTTP1::Client;

my $client = Unblock::HTTP1::Client->new;

$client->request(
    Uniform::HTTP::Request->new(
        method    => 'GET',
        target    => '/',
        authority => 'example.com',
    ),
    on_response => sub {
        my ($tx, $response) = @_;
        print $response->status, "\n";
    },
);

$client->input($bytes_from_transport);

while ($client->want_write) {
    my $bytes = $client->output;
    $transport->write($bytes);
}

DESCRIPTION

Unblock::HTTP1 is a portable HTTP/1.0 and HTTP/1.1 protocol engine.

It handles parsing, serialization, message framing, streaming bodies, persistent connections, informational responses, trailers, Upgrade, and CONNECT.

It does not open sockets, perform DNS or TLS, choose an event loop, or manage connection pools.

HTTP messages use Uniform::HTTP::Request and Uniform::HTTP::Response.

The application-facing API follows the common Unblock HTTP vocabulary: Client->new, Server->new, request(), respond(), write(), end(), and send_informational().

Transactions expose state(), error(), is_complete(), is_cancelled(), is_error(), and is_terminal().

See Unblock::HTTP1::Client, Unblock::HTTP1::Server, and Unblock::HTTP1::Transaction.

LICENSE

MIT License.