MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //usr/local/ssl/local/share/man/man3/HTTP::Tiny.3
.\" Automatically generated by Pod::Man v1.37, Pod::Parser v1.32
.\"
.\" Standard preamble:
.\" ========================================================================
.de Sh \" Subsection heading
.br
.if t .Sp
.ne 5
.PP
\fB\\$1\fR
.PP
..
.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.  | will give a
.\" real vertical bar.  \*(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-|\(bv\*(Tr
.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" ''
'br\}
.\"
.\" If the F register is turned on, we'll generate index entries on stderr for
.\" titles (.TH), headers (.SH), subsections (.Sh), items (.Ip), and index
.\" entries marked with X<> in POD.  Of course, you'll have to process the
.\" output yourself in some meaningful fashion.
.if \nF \{\
.    de IX
.    tm Index:\\$1\t\\n%\t"\\$2"
..
.    nr % 0
.    rr F
.\}
.\"
.\" For nroff, turn off justification.  Always turn off hyphenation; it makes
.\" way too many mistakes in technical documents.
.hy 0
.if n .na
.\"
.\" 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 3"
.TH HTTP::Tiny 3 "2011-07-17" "perl v5.8.8" "User Contributed Perl Documentation"
.SH "NAME"
HTTP::Tiny \- A small, simple, correct HTTP/1.1 client
.SH "VERSION"
.IX Header "VERSION"
version 0.013
.SH "SYNOPSIS"
.IX Header "SYNOPSIS"
.Vb 1
\&    use HTTP::Tiny;
.Ve
.PP
.Vb 1
\&    my $response = HTTP::Tiny->new->get('http://example.com/');
.Ve
.PP
.Vb 1
\&    die "Failed!\en" unless $response->{success};
.Ve
.PP
.Vb 1
\&    print "$response->{status} $response->{reason}\en";
.Ve
.PP
.Vb 5
\&    while (my ($k, $v) = each %{$response->{headers}}) {
\&        for (ref $v eq 'ARRAY' ? @$v : $v) {
\&            print "$k: $_\en";
\&        }
\&    }
.Ve
.PP
.Vb 1
\&    print $response->{content} if length $response->{content};
.Ve
.SH "DESCRIPTION"
.IX Header "DESCRIPTION"
This is a very simple \s-1HTTP/1\s0.1 client, designed primarily for doing simple \s-1GET\s0
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 (currently only non-authenticating ones) and redirection.  It
also correctly resumes after \s-1EINTR\s0.
.SH "METHODS"
.IX Header "METHODS"
.Sh "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
agent
.Sp
A user-agent string (defaults to 'HTTP::Tiny/$VERSION')
.IP "\(bu" 4
default_headers
.Sp
A hashref of default headers to apply to requests
.IP "\(bu" 4
max_redirect
.Sp
Maximum number of redirects allowed (defaults to 5)
.IP "\(bu" 4
max_size
.Sp
Maximum response size (only when not using a data callback).  If defined,
responses larger than this will die with an error message
.IP "\(bu" 4
proxy
.Sp
\&\s-1URL\s0 of a proxy server to use (default is \f(CW$ENV{http_proxy}\fR if set)
.IP "\(bu" 4
timeout
.Sp
Request timeout in seconds (default is 60)
.Sh "get"
.IX Subsection "get"
.Vb 2
\&    $response = $http->get($url);
\&    $response = $http->get($url, \e%options);
.Ve
.PP
Executes a \f(CW\*(C`GET\*(C'\fR request for the given \s-1URL\s0.  The \s-1URL\s0 must have unsafe
characters escaped and international domain names encoded.  Internally, it just
calls \f(CW\*(C`request()\*(C'\fR with '\s-1GET\s0' as the method.  See \f(CW\*(C`request()\*(C'\fR for valid
options and a description of the response.
.Sh "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 includes an
\&\f(CW\*(C`If\-Modified\-Since\*(C'\fR header with the modification timestamp of the file.  You
may specificy 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 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.
.Sh "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.  A hashref of options may be appended to
modify the request.
.PP
Valid options are:
.IP "\(bu" 4
headers
.Sp
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
content
.Sp
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 response
.IP "\(bu" 4
trailer_callback
.Sp
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
data_callback
.Sp
A code reference that will be called for each chunks of the response
body received.
.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`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
success
.Sp
Boolean indicating whether the operation returned a 2XX status code
.IP "\(bu" 4
status
.Sp
The \s-1HTTP\s0 status code of the response
.IP "\(bu" 4
reason
.Sp
The response phrase returned by the server
.IP "\(bu" 4
content
.Sp
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
headers
.Sp
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
.PP
On an exception 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 exception.
.SH "LIMITATIONS"
.IX Header "LIMITATIONS"
HTTP::Tiny is \fIconditionally compliant\fR with the
\&\s-1HTTP/1\s0.1 specification.
It attempts to meet all \*(L"\s-1MUST\s0\*(R" requirements of the specification, but does not
implement all \*(L"\s-1SHOULD\s0\*(R" requirements.
.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\s0.1
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 and 307 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
Persistant connections are not supported.  The \f(CW\*(C`Connection\*(C'\fR header will
always be set to \f(CW\*(C`close\*(C'\fR.
.IP "\(bu" 4
Direct \f(CW\*(C`https\*(C'\fR connections are supported only if IO::Socket::SSL is
installed.  There is no support for \f(CW\*(C`https\*(C'\fR connections via proxy.
Any \s-1SSL\s0 certificate that matches the host is accepted \*(-- \s-1SSL\s0 certificates
are not verified against certificate authorities.
.IP "\(bu" 4
Cookies are not directly supported.  Users that set a \f(CW\*(C`Cookie\*(C'\fR header
should also set \f(CW\*(C`max_redirect\*(C'\fR to zero to ensure cookies are not
inappropriately re\-transmitted.
.IP "\(bu" 4
Only the \f(CW\*(C`http_proxy\*(C'\fR environment variable is supported in the format
\&\f(CW\*(C`http://HOST:PORT/\*(C'\fR.  If a \f(CW\*(C`proxy\*(C'\fR argument is passed to \f(CW\*(C`new\*(C'\fR (including
undef), then the \f(CW\*(C`http_proxy\*(C'\fR environment variable is ignored.
.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.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
.IP "\(bu" 4
LWP::UserAgent
.SH "SUPPORT"
.IX Header "SUPPORT"
.Sh "Bugs / Feature Requests"
.IX Subsection "Bugs / Feature Requests"
Please report any bugs or feature requests by email to \f(CW\*(C`bug\-http\-tiny at rt.cpan.org\*(C'\fR, or through
the web interface at <http://rt.cpan.org/Public/Dist/Display.html?Name=HTTP\-Tiny>. You will be automatically notified of any
progress on the request by the system.
.Sh "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
<http://github.com/dagolden/p5\-http\-tiny>
.PP
.Vb 1
\&  git clone http://github.com/dagolden/p5-http-tiny
.Ve
.SH "AUTHORS"
.IX Header "AUTHORS"
.IP "\(bu" 4
Christian Hansen <chansen@cpan.org>
.IP "\(bu" 4
David Golden <dagolden@cpan.org>
.SH "COPYRIGHT AND LICENSE"
.IX Header "COPYRIGHT AND LICENSE"
This software is copyright (c) 2011 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.