NAME
Net::HTTP2::Client::Connection - Base class for individual HTTP/2 client connection
SYNOPSIS
See:
DESCRIPTION
This implements a non-blocking, non-redirecting HTTP/2 client. It’s a base class; the actual class you’ll use will depend on your event loop interface (see "SYNOPSIS").
If you want a full-featured client (that honors redirections), see Net::HTT2::Client.
CONNECTION LONGEVITY
TCP connections are kept open as long as instances of this class live.
HTTP REDIRECTION
This class’s design would facilitate HTTP redirects only in the case where the target of the redirect is the same server that answers the initial request. (e.g., we could honor Location: https://same.server/some/other/path
or Location: /some/other/path
, but not Location: https://some.other.server/foo
.)
To avoid that inconsistency, this class purposely omits HTTP redirection. See Net::HTTP2::UserAgent for an interface that implements redirection.
METHODS
$obj = CLASS->new( $HOSTNAME_OR_IP, %OPTS )
Instantiates CLASS.
%OPTS will depend on the CLASS, but can always include:
port
- The TCP port to connect to. Defaults to 443.tls_verify
- Eitherpeer
(default) ornone
.
promise($result) = OBJ->request( $METHOD, $PATH_AND_QUERY, %OPTS )
Sends an HTTP/2 request.
Returns a promise (an instance of <Promise::ES6>, unless otherwise noted in the subclass) that resolves to a Net::HTTP2::Response instance.
%OPTS can be:
headers
- Request headers, as in HTTP::Tiny’srequest()
.content
- Request content, as in HTTP::Tiny’srequest()
.on_data
- A code reference that fires as each chunk of the HTTP response arrives. The code reference always receives a Net::HTTP2::PartialResponse instance.
On failure (NOT including valid HTTP responses!), the promise rejects with an instance of an appropriate Net::HTTP2::X::Base class, e.g., Net::HTTP2::X::HTTP2.