.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.43)
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sp \" Vertical space (when we can't use .PP)
.if t .sp .5v
.if n .sp
..
.de Vb \" Begin verbatim text
.ft CW
.nf
.ne \\$1
..
.de Ve \" End verbatim text
.ft R
.fi
..
.\" Set up some character translations and predefined strings.  \*(-- will
.\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left
.\" double quote, and \*(R" will give a right double quote.  \*(C+ will
.\" give a nicer C++.  Capital omega is used to do unbreakable dashes and
.\" therefore won't be available.  \*(C` and \*(C' expand to `' in nroff,
.\" nothing in troff, for use with C<>.
.tr \(*W-
.ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p'
.ie n \{\
.    ds -- \(*W-
.    ds PI pi
.    if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch
.    if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\"  diablo 12 pitch
.    ds L" ""
.    ds R" ""
.    ds C` ""
.    ds C' ""
'br\}
.el\{\
.    ds -- \|\(em\|
.    ds PI \(*p
.    ds L" ``
.    ds R" ''
.    ds C`
.    ds C'
'br\}
.\"
.\" Escape single quotes in literal strings from groff's Unicode transform.
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\"
.\" If the F register is >0, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.\"
.\" Avoid warning from groff about undefined register 'F'.
.de IX
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
.    if \nF \{\
.        de IX
.        tm Index:\\$1\t\\n%\t"\\$2"
..
.        if !\nF==2 \{\
.            nr % 0
.            nr F 2
.        \}
.    \}
.\}
.rr rF
.\"
.\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
.\" Fear.  Run.  Save yourself.  No user-serviceable parts.
.    \" fudge factors for nroff and troff
.if n \{\
.    ds #H 0
.    ds #V .8m
.    ds #F .3m
.    ds #[ \f1
.    ds #] \fP
.\}
.if t \{\
.    ds #H ((1u-(\\\\n(.fu%2u))*.13m)
.    ds #V .6m
.    ds #F 0
.    ds #[ \&
.    ds #] \&
.\}
.    \" simple accents for nroff and troff
.if n \{\
.    ds ' \&
.    ds ` \&
.    ds ^ \&
.    ds , \&
.    ds ~ ~
.    ds /
.\}
.if t \{\
.    ds ' \\k:\h'-(\\n(.wu*8/10-\*(#H)'\'\h"|\\n:u"
.    ds ` \\k:\h'-(\\n(.wu*8/10-\*(#H)'\`\h'|\\n:u'
.    ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'^\h'|\\n:u'
.    ds , \\k:\h'-(\\n(.wu*8/10)',\h'|\\n:u'
.    ds ~ \\k:\h'-(\\n(.wu-\*(#H-.1m)'~\h'|\\n:u'
.    ds / \\k:\h'-(\\n(.wu*8/10-\*(#H)'\z\(sl\h'|\\n:u'
.\}
.    \" troff and (daisy-wheel) nroff accents
.ds : \\k:\h'-(\\n(.wu*8/10-\*(#H+.1m+\*(#F)'\v'-\*(#V'\z.\h'.2m+\*(#F'.\h'|\\n:u'\v'\*(#V'
.ds 8 \h'\*(#H'\(*b\h'-\*(#H'
.ds o \\k:\h'-(\\n(.wu+\w'\(de'u-\*(#H)/2u'\v'-.3n'\*(#[\z\(de\v'.3n'\h'|\\n:u'\*(#]
.ds d- \h'\*(#H'\(pd\h'-\w'~'u'\v'-.25m'\f2\(hy\fP\v'.25m'\h'-\*(#H'
.ds D- D\\k:\h'-\w'D'u'\v'-.11m'\z\(hy\v'.11m'\h'|\\n:u'
.ds th \*(#[\v'.3m'\s+1I\s-1\v'-.3m'\h'-(\w'I'u*2/3)'\s-1o\s+1\*(#]
.ds Th \*(#[\s+2I\s-2\h'-\w'I'u*3/5'\v'-.3m'o\v'.3m'\*(#]
.ds ae a\h'-(\w'a'u*4/10)'e
.ds Ae A\h'-(\w'A'u*4/10)'E
.    \" corrections for vroff
.if v .ds ~ \\k:\h'-(\\n(.wu*9/10-\*(#H)'\s-2\u~\d\s+2\h'|\\n:u'
.if v .ds ^ \\k:\h'-(\\n(.wu*10/11-\*(#H)'\v'-.4m'^\v'.4m'\h'|\\n:u'
.    \" for low resolution devices (crt and lpr)
.if \n(.H>23 .if \n(.V>19 \
\{\
.    ds : e
.    ds 8 ss
.    ds o a
.    ds d- d\h'-1'\(ga
.    ds D- D\h'-1'\(hy
.    ds th \o'bp'
.    ds Th \o'LP'
.    ds ae ae
.    ds Ae AE
.\}
.rm #[ #] #H #V #F C
.\" ========================================================================
.\"
.IX Title "HTTP::Tiny 3pm"
.TH HTTP::Tiny 3pm "2023-09-04" "perl v5.36.0" "Perl Programmers Reference Guide"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.if n .ad l
.nh
.SH "NAME"
HTTP::Tiny \- A small, simple, correct HTTP/1.1 client
.SH "VERSION"
.IX Header "VERSION"
version 0.080
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&    use HTTP::Tiny;
\&
\&    my $response = HTTP::Tiny\->new\->get(\*(Aqhttp://example.com/\*(Aq);
\&
\&    die "Failed!\en" unless $response\->{success};
\&
\&    print "$response\->{status} $response\->{reason}\en";
\&
\&    while (my ($k, $v) = each %{$response\->{headers}}) {
\&        for (ref $v eq \*(AqARRAY\*(Aq ? @$v : $v) {
\&            print "$k: $_\en";
\&        }
\&    }
\&
\&    print $response\->{content} if length $response\->{content};
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This is a very simple \s-1HTTP/1.1\s0 client, designed for doing simple
requests without the overhead of a large framework like LWP::UserAgent.
.PP
It is more correct and more complete than HTTP::Lite.  It supports
proxies and redirection.  It also correctly resumes after \s-1EINTR.\s0
.PP
If IO::Socket::IP 0.25 or later is installed, HTTP::Tiny will use it instead
of IO::Socket::INET for transparent support for both IPv4 and IPv6.
.PP
Cookie support requires HTTP::CookieJar or an equivalent class.
.SH "METHODS"
.IX Header "METHODS"
.SS "new"
.IX Subsection "new"
.Vb 1
\&    $http = HTTP::Tiny\->new( %attributes );
.Ve
.PP
This constructor returns a new HTTP::Tiny object.  Valid attributes include:
.IP "\(bu" 4
\&\f(CW\*(C`agent\*(C'\fR X A user-agent string (defaults to 'HTTP\-Tiny/$VERSION'). If \f(CW\*(C`agent\*(C'\fR X ends in a space character, the default user-agent string is appended.
.IP "\(bu" 4
\&\f(CW\*(C`cookie_jar\*(C'\fR X An instance of HTTP::CookieJar X or equivalent class that supports the \f(CW\*(C`add\*(C'\fR and \f(CW\*(C`cookie_header\*(C'\fR methods
.IP "\(bu" 4
\&\f(CW\*(C`default_headers\*(C'\fR X A hashref of default headers to apply to requests
.IP "\(bu" 4
\&\f(CW\*(C`local_address\*(C'\fR X The local \s-1IP\s0 address to bind to
.IP "\(bu" 4
\&\f(CW\*(C`keep_alive\*(C'\fR X Whether to reuse the last connection (if for the same scheme, host and port) (defaults to 1)
.IP "\(bu" 4
\&\f(CW\*(C`max_redirect\*(C'\fR X Maximum number of redirects allowed (defaults to 5)
.IP "\(bu" 4
\&\f(CW\*(C`max_size\*(C'\fR X Maximum response size in bytes (only when not using a data callback).  If defined, requests with responses larger than this will return a 599 status code.
.IP "\(bu" 4
\&\f(CW\*(C`http_proxy\*(C'\fR X \s-1URL\s0 of a proxy server to use for \s-1HTTP\s0 connections (default is \f(CW$ENV{http_proxy}\fR X if set)
.IP "\(bu" 4
\&\f(CW\*(C`https_proxy\*(C'\fR X \s-1URL\s0 of a proxy server to use for \s-1HTTPS\s0 connections (default is \f(CW$ENV{https_proxy}\fR X if set)
.IP "\(bu" 4
\&\f(CW\*(C`proxy\*(C'\fR X \s-1URL\s0 of a generic proxy server for both \s-1HTTP\s0 and \s-1HTTPS\s0 connections (default is \f(CW$ENV{all_proxy}\fR X if set)
.IP "\(bu" 4
\&\f(CW\*(C`no_proxy\*(C'\fR X List of domain suffixes that should not be proxied.  Must be a comma-separated string or an array reference. (default is \f(CW$ENV{no_proxy}\fR X)
.IP "\(bu" 4
\&\f(CW\*(C`timeout\*(C'\fR X Request timeout in seconds (default is 60) If a socket open, read or write takes longer than the timeout, the request response status code will be 599.
.IP "\(bu" 4
\&\f(CW\*(C`verify_SSL\*(C'\fR X A boolean that indicates whether to validate the \s-1SSL\s0 certificate of an \f(CW\*(C`https\*(C'\fR X connection (default is false)
.IP "\(bu" 4
\&\f(CW\*(C`SSL_options\*(C'\fR X A hashref of \f(CW\*(C`SSL_*\*(C'\fR X options to pass through to IO::Socket::SSL
.PP
An accessor/mutator method exists for each attribute.
.PP
Passing an explicit \f(CW\*(C`undef\*(C'\fR for \f(CW\*(C`proxy\*(C'\fR, \f(CW\*(C`http_proxy\*(C'\fR or \f(CW\*(C`https_proxy\*(C'\fR will
prevent getting the corresponding proxies from the environment.
.PP
Errors during request execution will result in a pseudo-HTTP status code of 599
and a reason of \*(L"Internal Exception\*(R". The content field in the response will
contain the text of the error.
.PP
The \f(CW\*(C`keep_alive\*(C'\fR parameter enables a persistent connection, but only to a
single destination scheme, host and port.  If any connection-relevant
attributes are modified via accessor, or if the process \s-1ID\s0 or thread \s-1ID\s0 change,
the persistent connection will be dropped.  If you want persistent connections
across multiple destinations, use multiple HTTP::Tiny objects.
.PP
See \*(L"\s-1SSL SUPPORT\*(R"\s0 for more on the \f(CW\*(C`verify_SSL\*(C'\fR and \f(CW\*(C`SSL_options\*(C'\fR attributes.
.SS "get|head|put|post|patch|delete"
.IX Subsection "get|head|put|post|patch|delete"
.Vb 3
\&    $response = $http\->get($url);
\&    $response = $http\->get($url, \e%options);
\&    $response = $http\->head($url);
.Ve
.PP
These methods are shorthand for calling \f(CW\*(C`request()\*(C'\fR for the given method.  The
\&\s-1URL\s0 must have unsafe characters escaped and international domain names encoded.
See \f(CW\*(C`request()\*(C'\fR for valid options and a description of the response.
.PP
The \f(CW\*(C`success\*(C'\fR field of the response will be true if the status code is 2XX.
.SS "post_form"
.IX Subsection "post_form"
.Vb 2
\&    $response = $http\->post_form($url, $form_data);
\&    $response = $http\->post_form($url, $form_data, \e%options);
.Ve
.PP
This method executes a \f(CW\*(C`POST\*(C'\fR request and sends the key/value pairs from a
form data hash or array reference to the given \s-1URL\s0 with a \f(CW\*(C`content\-type\*(C'\fR of
\&\f(CW\*(C`application/x\-www\-form\-urlencoded\*(C'\fR.  If data is provided as an array
reference, the order is preserved; if provided as a hash reference, the terms
are sorted on key and value for consistency.  See documentation for the
\&\f(CW\*(C`www_form_urlencode\*(C'\fR method for details on the encoding.
.PP
The \s-1URL\s0 must have unsafe characters escaped and international domain names
encoded.  See \f(CW\*(C`request()\*(C'\fR for valid options and a description of the response.
Any \f(CW\*(C`content\-type\*(C'\fR header or content in the options hashref will be ignored.
.PP
The \f(CW\*(C`success\*(C'\fR field of the response will be true if the status code is 2XX.
.SS "mirror"
.IX Subsection "mirror"
.Vb 4
\&    $response = $http\->mirror($url, $file, \e%options)
\&    if ( $response\->{success} ) {
\&        print "$file is up to date\en";
\&    }
.Ve
.PP
Executes a \f(CW\*(C`GET\*(C'\fR request for the \s-1URL\s0 and saves the response body to the file
name provided.  The \s-1URL\s0 must have unsafe characters escaped and international
domain names encoded.  If the file already exists, the request will include an
\&\f(CW\*(C`If\-Modified\-Since\*(C'\fR header with the modification timestamp of the file.  You
may specify a different \f(CW\*(C`If\-Modified\-Since\*(C'\fR header yourself in the \f(CW\*(C`$options\->{headers}\*(C'\fR hash.
.PP
The \f(CW\*(C`success\*(C'\fR field of the response will be true if the status code is 2XX
or if the status code is 304 (unmodified).
.PP
If the file was modified and the server response includes a properly
formatted \f(CW\*(C`Last\-Modified\*(C'\fR header, the file modification time will
be updated accordingly.
.SS "request"
.IX Subsection "request"
.Vb 2
\&    $response = $http\->request($method, $url);
\&    $response = $http\->request($method, $url, \e%options);
.Ve
.PP
Executes an \s-1HTTP\s0 request of the given method type ('\s-1GET\s0', '\s-1HEAD\s0', '\s-1POST\s0',
\&'\s-1PUT\s0', etc.) on the given \s-1URL.\s0  The \s-1URL\s0 must have unsafe characters escaped and
international domain names encoded.
.PP
\&\fB\s-1NOTE\s0\fR: Method names are \fBcase-sensitive\fR per the \s-1HTTP/1.1\s0 specification.
Don't use \f(CW\*(C`get\*(C'\fR when you really want \f(CW\*(C`GET\*(C'\fR.  See \s-1LIMITATIONS\s0 for
how this applies to redirection.
.PP
If the \s-1URL\s0 includes a \*(L"user:password\*(R" stanza, they will be used for Basic-style
authorization headers.  (Authorization headers will not be included in a
redirected request.) For example:
.PP
.Vb 1
\&    $http\->request(\*(AqGET\*(Aq, \*(Aqhttp://Aladdin:open sesame@example.com/\*(Aq);
.Ve
.PP
If the \*(L"user:password\*(R" stanza contains reserved characters, they must
be percent-escaped:
.PP
.Vb 1
\&    $http\->request(\*(AqGET\*(Aq, \*(Aqhttp://john%40example.com:password@example.com/\*(Aq);
.Ve
.PP
A hashref of options may be appended to modify the request.
.PP
Valid options are:
.IP "\(bu" 4
\&\f(CW\*(C`headers\*(C'\fR X A hashref containing headers to include with the request.  If the value for a header is an array reference, the header will be output multiple times with each value in the array.  These headers over-write any default headers.
.IP "\(bu" 4
\&\f(CW\*(C`content\*(C'\fR X A scalar to include as the body of the request \s-1OR\s0 a code reference that will be called iteratively to produce the body of the request
.IP "\(bu" 4
\&\f(CW\*(C`trailer_callback\*(C'\fR X A code reference that will be called if it exists to provide a hashref of trailing headers (only used with chunked transfer-encoding)
.IP "\(bu" 4
\&\f(CW\*(C`data_callback\*(C'\fR X A code reference that will be called for each chunks of the response body received.
.IP "\(bu" 4
\&\f(CW\*(C`peer\*(C'\fR X Override host resolution and force all connections to go only to a specific peer address, regardless of the \s-1URL\s0 of the request.  This will include any redirections!  This options should be used with extreme caution (e.g. debugging or very special circumstances). It can be given as either a scalar or a code reference that will receive the hostname and whose response will be taken as the address.
.PP
The \f(CW\*(C`Host\*(C'\fR header is generated from the \s-1URL\s0 in accordance with \s-1RFC 2616.\s0  It
is a fatal error to specify \f(CW\*(C`Host\*(C'\fR in the \f(CW\*(C`headers\*(C'\fR option.  Other headers
may be ignored or overwritten if necessary for transport compliance.
.PP
If the \f(CW\*(C`content\*(C'\fR option is a code reference, it will be called iteratively
to provide the content body of the request.  It should return the empty
string or undef when the iterator is exhausted.
.PP
If the \f(CW\*(C`content\*(C'\fR option is the empty string, no \f(CW\*(C`content\-type\*(C'\fR or
\&\f(CW\*(C`content\-length\*(C'\fR headers will be generated.
.PP
If the \f(CW\*(C`data_callback\*(C'\fR option is provided, it will be called iteratively until
the entire response body is received.  The first argument will be a string
containing a chunk of the response body, the second argument will be the
in-progress response hash reference, as described below.  (This allows
customizing the action of the callback based on the \f(CW\*(C`status\*(C'\fR or \f(CW\*(C`headers\*(C'\fR
received prior to the content body.)
.PP
The \f(CW\*(C`request\*(C'\fR method returns a hashref containing the response.  The hashref
will have the following keys:
.IP "\(bu" 4
\&\f(CW\*(C`success\*(C'\fR X Boolean indicating whether the operation returned a 2XX status code
.IP "\(bu" 4
\&\f(CW\*(C`url\*(C'\fR X \s-1URL\s0 that provided the response. This is the \s-1URL\s0 of the request unless there were redirections, in which case it is the last \s-1URL\s0 queried in a redirection chain
.IP "\(bu" 4
\&\f(CW\*(C`status\*(C'\fR X The \s-1HTTP\s0 status code of the response
.IP "\(bu" 4
\&\f(CW\*(C`reason\*(C'\fR X The response phrase returned by the server
.IP "\(bu" 4
\&\f(CW\*(C`content\*(C'\fR X The body of the response.  If the response does not have any content or if a data callback is provided to consume the response body, this will be the empty string
.IP "\(bu" 4
\&\f(CW\*(C`headers\*(C'\fR X A hashref of header fields.  All header field names will be normalized to be lower case. If a header is repeated, the value will be an arrayref; it will otherwise be a scalar string containing the value
.IP "\(bu" 4
\&\f(CW\*(C`protocol\*(C'\fR \- If this field exists, it is the protocol of the response such as \s-1HTTP/1.0\s0 or \s-1HTTP/1.1\s0
.IP "\(bu" 4
\&\f(CW\*(C`redirects\*(C'\fR If this field exists, it is an arrayref of response hash references from redirects in the same order that redirections occurred.  If it does not exist, then no redirections occurred.
.PP
On an error during the execution of the request, the \f(CW\*(C`status\*(C'\fR field will
contain 599, and the \f(CW\*(C`content\*(C'\fR field will contain the text of the error.
.SS "www_form_urlencode"
.IX Subsection "www_form_urlencode"
.Vb 2
\&    $params = $http\->www_form_urlencode( $data );
\&    $response = $http\->get("http://example.com/query?$params");
.Ve
.PP
This method converts the key/value pairs from a data hash or array reference
into a \f(CW\*(C`x\-www\-form\-urlencoded\*(C'\fR string.  The keys and values from the data
reference will be \s-1UTF\-8\s0 encoded and escaped per \s-1RFC 3986.\s0  If a value is an
array reference, the key will be repeated with each of the values of the array
reference.  If data is provided as a hash reference, the key/value pairs in the
resulting string will be sorted by key and value for consistent ordering.
.SS "can_ssl"
.IX Subsection "can_ssl"
.Vb 3
\&    $ok         = HTTP::Tiny\->can_ssl;
\&    ($ok, $why) = HTTP::Tiny\->can_ssl;
\&    ($ok, $why) = $http\->can_ssl;
.Ve
.PP
Indicates if \s-1SSL\s0 support is available.  When called as a class object, it
checks for the correct version of Net::SSLeay and IO::Socket::SSL.
When called as an object methods, if \f(CW\*(C`SSL_verify\*(C'\fR is true or if \f(CW\*(C`SSL_verify_mode\*(C'\fR
is set in \f(CW\*(C`SSL_options\*(C'\fR, it checks that a \s-1CA\s0 file is available.
.PP
In scalar context, returns a boolean indicating if \s-1SSL\s0 is available.
In list context, returns the boolean and a (possibly multi-line) string of
errors indicating why \s-1SSL\s0 isn't available.
.SS "connected"
.IX Subsection "connected"
.Vb 2
\&    $host = $http\->connected;
\&    ($host, $port) = $http\->connected;
.Ve
.PP
Indicates if a connection to a peer is being kept alive, per the \f(CW\*(C`keep_alive\*(C'\fR
option.
.PP
In scalar context, returns the peer host and port, joined with a colon, or
\&\f(CW\*(C`undef\*(C'\fR (if no peer is connected).
In list context, returns the peer host and port or an empty list (if no peer
is connected).
.PP
\&\fBNote\fR: This method cannot reliably be used to discover whether the remote
host has closed its end of the socket.
.SH "SSL SUPPORT"
.IX Header "SSL SUPPORT"
Direct \f(CW\*(C`https\*(C'\fR connections are supported only if IO::Socket::SSL 1.56 or
greater and Net::SSLeay 1.49 or greater are installed. An error will occur
if new enough versions of these modules are not installed or if the \s-1SSL\s0
encryption fails. You can also use \f(CW\*(C`HTTP::Tiny::can_ssl()\*(C'\fR utility function
that returns boolean to see if the required modules are installed.
.PP
An \f(CW\*(C`https\*(C'\fR connection may be made via an \f(CW\*(C`http\*(C'\fR proxy that supports the \s-1CONNECT\s0
command (i.e. \s-1RFC 2817\s0).  You may not proxy \f(CW\*(C`https\*(C'\fR via a proxy that itself
requires \f(CW\*(C`https\*(C'\fR to communicate.
.PP
\&\s-1SSL\s0 provides two distinct capabilities:
.IP "\(bu" 4
Encrypted communication channel
.IP "\(bu" 4
Verification of server identity
.PP
\&\fBBy default, HTTP::Tiny does not verify server identity\fR.
.PP
Server identity verification is controversial and potentially tricky because it
depends on a (usually paid) third-party Certificate Authority (\s-1CA\s0) trust model
to validate a certificate as legitimate.  This discriminates against servers
with self-signed certificates or certificates signed by free, community-driven
\&\s-1CA\s0's such as CAcert.org <http://cacert.org>.
.PP
By default, HTTP::Tiny does not make any assumptions about your trust model,
threat level or risk tolerance.  It just aims to give you an encrypted channel
when you need one.
.PP
Setting the \f(CW\*(C`verify_SSL\*(C'\fR attribute to a true value will make HTTP::Tiny verify
that an \s-1SSL\s0 connection has a valid \s-1SSL\s0 certificate corresponding to the host
name of the connection and that the \s-1SSL\s0 certificate has been verified by a \s-1CA.\s0
Assuming you trust the \s-1CA,\s0 this will protect against a man-in-the-middle
attack <http://en.wikipedia.org/wiki/Man-in-the-middle_attack>.  If you are
concerned about security, you should enable this option.
.PP
Certificate verification requires a file containing trusted \s-1CA\s0 certificates.
.PP
If the environment variable \f(CW\*(C`SSL_CERT_FILE\*(C'\fR is present, HTTP::Tiny
will try to find a \s-1CA\s0 certificate file in that location.
.PP
If the Mozilla::CA module is installed, HTTP::Tiny will use the \s-1CA\s0 file
included with it as a source of trusted \s-1CA\s0's.  (This means you trust Mozilla,
the author of Mozilla::CA, the \s-1CPAN\s0 mirror where you got Mozilla::CA, the
toolchain used to install it, and your operating system security, right?)
.PP
If that module is not available, then HTTP::Tiny will search several
system-specific default locations for a \s-1CA\s0 certificate file:
.IP "\(bu" 4
/etc/ssl/certs/ca\-certificates.crt
.IP "\(bu" 4
/etc/pki/tls/certs/ca\-bundle.crt
.IP "\(bu" 4
/etc/ssl/ca\-bundle.pem
.PP
An error will be occur if \f(CW\*(C`verify_SSL\*(C'\fR is true and no \s-1CA\s0 certificate file
is available.
.PP
If you desire complete control over \s-1SSL\s0 connections, the \f(CW\*(C`SSL_options\*(C'\fR attribute
lets you provide a hash reference that will be passed through to
\&\f(CW\*(C`IO::Socket::SSL::start_SSL()\*(C'\fR, overriding any options set by HTTP::Tiny. For
example, to provide your own trusted \s-1CA\s0 file:
.PP
.Vb 3
\&    SSL_options => {
\&        SSL_ca_file => $file_path,
\&    }
.Ve
.PP
The \f(CW\*(C`SSL_options\*(C'\fR attribute could also be used for such things as providing a
client certificate for authentication to a server or controlling the choice of
cipher used for the \s-1SSL\s0 connection. See IO::Socket::SSL documentation for
details.
.SH "PROXY SUPPORT"
.IX Header "PROXY SUPPORT"
HTTP::Tiny can proxy both \f(CW\*(C`http\*(C'\fR and \f(CW\*(C`https\*(C'\fR requests.  Only Basic proxy
authorization is supported and it must be provided as part of the proxy \s-1URL:\s0
\&\f(CW\*(C`http://user:pass@proxy.example.com/\*(C'\fR.
.PP
HTTP::Tiny supports the following proxy environment variables:
.IP "\(bu" 4
http_proxy or \s-1HTTP_PROXY\s0
.IP "\(bu" 4
https_proxy or \s-1HTTPS_PROXY\s0
.IP "\(bu" 4
all_proxy or \s-1ALL_PROXY\s0
.PP
If the \f(CW\*(C`REQUEST_METHOD\*(C'\fR environment variable is set, then this might be a \s-1CGI\s0
process and \f(CW\*(C`HTTP_PROXY\*(C'\fR would be set from the \f(CW\*(C`Proxy:\*(C'\fR header, which is a
security risk.  If \f(CW\*(C`REQUEST_METHOD\*(C'\fR is set, \f(CW\*(C`HTTP_PROXY\*(C'\fR (the upper case
variant only) is ignored, but \f(CW\*(C`CGI_HTTP_PROXY\*(C'\fR is considered instead.
.PP
Tunnelling \f(CW\*(C`https\*(C'\fR over an \f(CW\*(C`http\*(C'\fR proxy using the \s-1CONNECT\s0 method is
supported.  If your proxy uses \f(CW\*(C`https\*(C'\fR itself, you can not tunnel \f(CW\*(C`https\*(C'\fR
over it.
.PP
Be warned that proxying an \f(CW\*(C`https\*(C'\fR connection opens you to the risk of a
man-in-the-middle attack by the proxy server.
.PP
The \f(CW\*(C`no_proxy\*(C'\fR environment variable is supported in the format of a
comma-separated list of domain extensions proxy should not be used for.
.PP
Proxy arguments passed to \f(CW\*(C`new\*(C'\fR will override their corresponding
environment variables.
.SH "LIMITATIONS"
.IX Header "LIMITATIONS"
HTTP::Tiny is \fIconditionally compliant\fR with the
\&\s-1HTTP/1.1\s0 specifications <http://www.w3.org/Protocols/>:
.IP "\(bu" 4
\&\*(L"Message Syntax and Routing\*(R" [\s-1RFC7230\s0]
.IP "\(bu" 4
\&\*(L"Semantics and Content\*(R" [\s-1RFC7231\s0]
.IP "\(bu" 4
\&\*(L"Conditional Requests\*(R" [\s-1RFC7232\s0]
.IP "\(bu" 4
\&\*(L"Range Requests\*(R" [\s-1RFC7233\s0]
.IP "\(bu" 4
\&\*(L"Caching\*(R" [\s-1RFC7234\s0]
.IP "\(bu" 4
\&\*(L"Authentication\*(R" [\s-1RFC7235\s0]
.PP
It attempts to meet all \*(L"\s-1MUST\*(R"\s0 requirements of the specification, but does not
implement all \*(L"\s-1SHOULD\*(R"\s0 requirements.  (Note: it was developed against the
earlier \s-1RFC 2616\s0 specification and may not yet meet the revised \s-1RFC 7230\-7235\s0
spec.) Additionally, HTTP::Tiny supports the \f(CW\*(C`PATCH\*(C'\fR method of \s-1RFC 5789.\s0
.PP
Some particular limitations of note include:
.IP "\(bu" 4
HTTP::Tiny focuses on correct transport.  Users are responsible for ensuring
that user-defined headers and content are compliant with the \s-1HTTP/1.1\s0
specification.
.IP "\(bu" 4
Users must ensure that URLs are properly escaped for unsafe characters and that
international domain names are properly encoded to \s-1ASCII.\s0 See URI::Escape,
URI::_punycode and Net::IDN::Encode.
.IP "\(bu" 4
Redirection is very strict against the specification.  Redirection is only
automatic for response codes 301, 302, 307 and 308 if the request method is
\&'\s-1GET\s0' or '\s-1HEAD\s0'.  Response code 303 is always converted into a '\s-1GET\s0'
redirection, as mandated by the specification.  There is no automatic support
for status 305 (\*(L"Use proxy\*(R") redirections.
.IP "\(bu" 4
There is no provision for delaying a request body using an \f(CW\*(C`Expect\*(C'\fR header.
Unexpected \f(CW\*(C`1XX\*(C'\fR responses are silently ignored as per the specification.
.IP "\(bu" 4
Only 'chunked' \f(CW\*(C`Transfer\-Encoding\*(C'\fR is supported.
.IP "\(bu" 4
There is no support for a Request-URI of '*' for the '\s-1OPTIONS\s0' request.
.IP "\(bu" 4
Headers mentioned in the RFCs and some other, well-known headers are
generated with their canonical case.  Other headers are sent in the
case provided by the user.  Except for control headers (which are sent first),
headers are sent in arbitrary order.
.PP
Despite the limitations listed above, HTTP::Tiny is considered
feature-complete.  New feature requests should be directed to
HTTP::Tiny::UA.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
.IP "\(bu" 4
HTTP::Tiny::UA \- Higher level \s-1UA\s0 features for HTTP::Tiny
.IP "\(bu" 4
HTTP::Thin \- HTTP::Tiny wrapper with HTTP::Request/HTTP::Response compatibility
.IP "\(bu" 4
HTTP::Tiny::Mech \- Wrap WWW::Mechanize instance in HTTP::Tiny compatible interface
.IP "\(bu" 4
IO::Socket::IP \- Required for IPv6 support
.IP "\(bu" 4
IO::Socket::SSL \- Required for \s-1SSL\s0 support
.IP "\(bu" 4
LWP::UserAgent \- If HTTP::Tiny isn't enough for you, this is the \*(L"standard\*(R" way to do things
.IP "\(bu" 4
Mozilla::CA \- Required if you want to validate \s-1SSL\s0 certificates
.IP "\(bu" 4
Net::SSLeay \- Required for \s-1SSL\s0 support
.SH "SUPPORT"
.IX Header "SUPPORT"
.SS "Bugs / Feature Requests"
.IX Subsection "Bugs / Feature Requests"
Please report any bugs or feature requests through the issue tracker
at <https://github.com/chansen/p5\-http\-tiny/issues>.
You will be notified automatically of any progress on your issue.
.SS "Source Code"
.IX Subsection "Source Code"
This is open source software.  The code repository is available for
public review and contribution under the terms of the license.
.PP
<https://github.com/chansen/p5\-http\-tiny>
.PP
.Vb 1
\&  git clone https://github.com/chansen/p5\-http\-tiny.git
.Ve
.SH "AUTHORS"
.IX Header "AUTHORS"
.IP "\(bu" 4
Christian Hansen <chansen@cpan.org>
.IP "\(bu" 4
David Golden <dagolden@cpan.org>
.SH "CONTRIBUTORS"
.IX Header "CONTRIBUTORS"
.IP "\(bu" 4
Alan Gardner <gardner@pythian.com>
.IP "\(bu" 4
Alessandro Ghedini <al3xbio@gmail.com>
.IP "\(bu" 4
A. Sinan Unur <nanis@cpan.org>
.IP "\(bu" 4
Brad Gilbert <bgills@cpan.org>
.IP "\(bu" 4
brian m. carlson <sandals@crustytoothpaste.net>
.IP "\(bu" 4
Chris Nehren <apeiron@cpan.org>
.IP "\(bu" 4
Chris Weyl <cweyl@alumni.drew.edu>
.IP "\(bu" 4
Claes Jakobsson <claes@surfar.nu>
.IP "\(bu" 4
Clinton Gormley <clint@traveljury.com>
.IP "\(bu" 4
Craig A. Berry <craigberry@mac.com>
.IP "\(bu" 4
Craig Berry <cberry@cpan.org>
.IP "\(bu" 4
David Golden <xdg@xdg.me>
.IP "\(bu" 4
David Mitchell <davem@iabyn.com>
.IP "\(bu" 4
Dean Pearce <pearce@pythian.com>
.IP "\(bu" 4
Edward Zborowski <ed@rubensteintech.com>
.IP "\(bu" 4
Felipe Gasper <felipe@felipegasper.com>
.IP "\(bu" 4
Greg Kennedy <kennedy.greg@gmail.com>
.IP "\(bu" 4
James E Keenan <jkeenan@cpan.org>
.IP "\(bu" 4
James Raspass <jraspass@gmail.com>
.IP "\(bu" 4
Jeremy Mates <jmates@cpan.org>
.IP "\(bu" 4
Jess Robinson <castaway@desert\-island.me.uk>
.IP "\(bu" 4
Karen Etheridge <ether@cpan.org>
.IP "\(bu" 4
Lukas Eklund <leklund@gmail.com>
.IP "\(bu" 4
Martin J. Evans <mjegh@ntlworld.com>
.IP "\(bu" 4
Martin-Louis Bright <mlbright@gmail.com>
.IP "\(bu" 4
Matthew Horsfall <wolfsage@gmail.com>
.IP "\(bu" 4
Michael R. Davis <mrdvt92@users.noreply.github.com>
.IP "\(bu" 4
Mike Doherty <doherty@cpan.org>
.IP "\(bu" 4
Nicolas Rochelemagne <rochelemagne@cpanel.net>
.IP "\(bu" 4
Olaf Alders <olaf@wundersolutions.com>
.IP "\(bu" 4
Olivier Mengue\*' <dolmen@cpan.org>
.IP "\(bu" 4
Petr Pi\*'saX <ppisar@redhat.com>
.IP "\(bu" 4
sanjay-cpu <snjkmr32@gmail.com>
.IP "\(bu" 4
Serguei Trouchelle <stro@cpan.org>
.IP "\(bu" 4
Shoichi Kaji <skaji@cpan.org>
.IP "\(bu" 4
SkyMarshal <skymarshal1729@gmail.com>
.IP "\(bu" 4
So\*:ren Kornetzki <soeren.kornetzki@delti.com>
.IP "\(bu" 4
Steve Grazzini <steve.grazzini@grantstreet.com>
.IP "\(bu" 4
Syohei \s-1YOSHIDA\s0 <syohex@gmail.com>
.IP "\(bu" 4
Tatsuhiko Miyagawa <miyagawa@bulknews.net>
.IP "\(bu" 4
Tom Hukins <tom@eborcom.com>
.IP "\(bu" 4
Tony Cook <tony@develop\-help.com>
.IP "\(bu" 4
Xavier Guimard <yadd@debian.org>
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2021 by Christian Hansen.
.PP
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
