man-pages/man3/HTTP::Status.3pm.html
2021-03-31 01:06:50 +01:00

281 lines
8.4 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML><HEAD><TITLE>Man page of HTTP::Status</TITLE>
</HEAD><BODY>
<H1>HTTP::Status</H1>
Section: User Contributed Perl Documentation (3pm)<BR>Updated: 2020-02-29<BR><A HREF="#index">Index</A>
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
<A NAME="lbAB">&nbsp;</A>
<H2>NAME</H2>
HTTP::Status - HTTP Status code processing
<A NAME="lbAC">&nbsp;</A>
<H2>VERSION</H2>
version 6.22
<A NAME="lbAD">&nbsp;</A>
<H2>SYNOPSIS</H2>
<PRE>
use HTTP::Status qw(:constants :is status_message);
if ($rc != HTTP_OK) {
print status_message($rc), &quot;\n&quot;;
}
if (is_success($rc)) { ... }
if (is_error($rc)) { ... }
if (is_redirect($rc)) { ... }
</PRE>
<A NAME="lbAE">&nbsp;</A>
<H2>DESCRIPTION</H2>
<I>HTTP::Status</I> is a library of routines for defining and
classifying <FONT SIZE="-1">HTTP</FONT> status codes for libwww-perl. Status codes are
used to encode the overall outcome of an <FONT SIZE="-1">HTTP</FONT> response message. Codes
correspond to those defined in <FONT SIZE="-1">RFC 2616</FONT> and <FONT SIZE="-1">RFC 2518.</FONT>
<A NAME="lbAF">&nbsp;</A>
<H2>CONSTANTS</H2>
The following constant functions can be used as mnemonic status code
names. None of these are exported by default. Use the <TT>&quot;:constants&quot;</TT>
tag to import them all.
<P>
<PRE>
HTTP_CONTINUE (100)
HTTP_SWITCHING_PROTOCOLS (101)
HTTP_PROCESSING (102)
HTTP_EARLY_HINTS (103)
HTTP_OK (200)
HTTP_CREATED (201)
HTTP_ACCEPTED (202)
HTTP_NON_AUTHORITATIVE_INFORMATION (203)
HTTP_NO_CONTENT (204)
HTTP_RESET_CONTENT (205)
HTTP_PARTIAL_CONTENT (206)
HTTP_MULTI_STATUS (207)
HTTP_ALREADY_REPORTED (208)
HTTP_IM_USED (226)
HTTP_MULTIPLE_CHOICES (300)
HTTP_MOVED_PERMANENTLY (301)
HTTP_FOUND (302)
HTTP_SEE_OTHER (303)
HTTP_NOT_MODIFIED (304)
HTTP_USE_PROXY (305)
HTTP_TEMPORARY_REDIRECT (307)
HTTP_PERMANENT_REDIRECT (308)
HTTP_BAD_REQUEST (400)
HTTP_UNAUTHORIZED (401)
HTTP_PAYMENT_REQUIRED (402)
HTTP_FORBIDDEN (403)
HTTP_NOT_FOUND (404)
HTTP_METHOD_NOT_ALLOWED (405)
HTTP_NOT_ACCEPTABLE (406)
HTTP_PROXY_AUTHENTICATION_REQUIRED (407)
HTTP_REQUEST_TIMEOUT (408)
HTTP_CONFLICT (409)
HTTP_GONE (410)
HTTP_LENGTH_REQUIRED (411)
HTTP_PRECONDITION_FAILED (412)
HTTP_REQUEST_ENTITY_TOO_LARGE (413)
HTTP_REQUEST_URI_TOO_LARGE (414)
HTTP_UNSUPPORTED_MEDIA_TYPE (415)
HTTP_REQUEST_RANGE_NOT_SATISFIABLE (416)
HTTP_EXPECTATION_FAILED (417)
HTTP_MISDIRECTED REQUEST (421)
HTTP_UNPROCESSABLE_ENTITY (422)
HTTP_LOCKED (423)
HTTP_FAILED_DEPENDENCY (424)
HTTP_UPGRADE_REQUIRED (426)
HTTP_PRECONDITION_REQUIRED (428)
HTTP_TOO_MANY_REQUESTS (429)
HTTP_REQUEST_HEADER_FIELDS_TOO_LARGE (431)
HTTP_UNAVAILABLE_FOR_LEGAL_REASONS (451)
HTTP_INTERNAL_SERVER_ERROR (500)
HTTP_NOT_IMPLEMENTED (501)
HTTP_BAD_GATEWAY (502)
HTTP_SERVICE_UNAVAILABLE (503)
HTTP_GATEWAY_TIMEOUT (504)
HTTP_HTTP_VERSION_NOT_SUPPORTED (505)
HTTP_VARIANT_ALSO_NEGOTIATES (506)
HTTP_INSUFFICIENT_STORAGE (507)
HTTP_LOOP_DETECTED (508)
HTTP_NOT_EXTENDED (510)
HTTP_NETWORK_AUTHENTICATION_REQUIRED (511)
</PRE>
<A NAME="lbAG">&nbsp;</A>
<H2>FUNCTIONS</H2>
The following additional functions are provided. Most of them are
exported by default. The <TT>&quot;:is&quot;</TT> import tag can be used to import all
the classification functions.
<DL COMPACT>
<DT id="1">status_message( $code )<DD>
The <B>status_message()</B> function will translate status codes to human
readable strings. The string is the same as found in the constant
names above. If the <TT>$code</TT> is not registered in the list of <FONT SIZE="-1">IANA HTTP</FONT> Status
Codes &lt;<A HREF="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml</A>&gt;
then <TT>&quot;undef&quot;</TT> is returned.
<DT id="2">is_info( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> is an <I>Informational</I> status code (1xx). This
class of status code indicates a provisional response which can't have
any content.
<DT id="3">is_success( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> is a <I>Successful</I> status code (2xx).
<DT id="4">is_redirect( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> is a <I>Redirection</I> status code (3xx). This class of
status code indicates that further action needs to be taken by the
user agent in order to fulfill the request.
<DT id="5">is_error( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> is an <I>Error</I> status code (4xx or 5xx). The function
returns <FONT SIZE="-1">TRUE</FONT> for both client and server error status codes.
<DT id="6">is_client_error( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> is a <I>Client Error</I> status code (4xx). This class
of status code is intended for cases in which the client seems to have
erred.
<P>
This function is <B>not</B> exported by default.
<DT id="7">is_server_error( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> is a <I>Server Error</I> status code (5xx). This class
of status codes is intended for cases in which the server is aware
that it has erred or is incapable of performing the request.
<P>
This function is <B>not</B> exported by default.
<DT id="8">is_cacheable_by_default( $code )<DD>
Return <FONT SIZE="-1">TRUE</FONT> if <TT>$code</TT> indicates that a response is cacheable by default, and
it can be reused by a cache with heuristic expiration. All other status codes
are not cacheable by default. See <FONT SIZE="-1">RFC 7231</FONT> - <FONT SIZE="-1">HTTP/1.1</FONT> Semantics and Content,
Section 6.1. Overview of Status Codes &lt;<A HREF="https://tools.ietf.org/html/rfc7231#section-6.1">https://tools.ietf.org/html/rfc7231#section-6.1</A>&gt;.
<P>
This function is <B>not</B> exported by default.
</DL>
<A NAME="lbAH">&nbsp;</A>
<H2>SEE ALSO</H2>
<FONT SIZE="-1">IANA HTTP</FONT> Status Codes &lt;<A HREF="https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml">https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml</A>&gt;
<A NAME="lbAI">&nbsp;</A>
<H2>BUGS</H2>
For legacy reasons all the <TT>&quot;HTTP_&quot;</TT> constants are exported by default
with the prefix <TT>&quot;RC_&quot;</TT>. It's recommended to use explicit imports and
the <TT>&quot;:constants&quot;</TT> tag instead of relying on this.
<A NAME="lbAJ">&nbsp;</A>
<H2>AUTHOR</H2>
Gisle Aas &lt;<A HREF="mailto:gisle@activestate.com">gisle@activestate.com</A>&gt;
<A NAME="lbAK">&nbsp;</A>
<H2>COPYRIGHT AND LICENSE</H2>
This software is copyright (c) 1994-2017 by Gisle Aas.
<P>
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
<P>
<HR>
<A NAME="index">&nbsp;</A><H2>Index</H2>
<DL>
<DT id="9"><A HREF="#lbAB">NAME</A><DD>
<DT id="10"><A HREF="#lbAC">VERSION</A><DD>
<DT id="11"><A HREF="#lbAD">SYNOPSIS</A><DD>
<DT id="12"><A HREF="#lbAE">DESCRIPTION</A><DD>
<DT id="13"><A HREF="#lbAF">CONSTANTS</A><DD>
<DT id="14"><A HREF="#lbAG">FUNCTIONS</A><DD>
<DT id="15"><A HREF="#lbAH">SEE ALSO</A><DD>
<DT id="16"><A HREF="#lbAI">BUGS</A><DD>
<DT id="17"><A HREF="#lbAJ">AUTHOR</A><DD>
<DT id="18"><A HREF="#lbAK">COPYRIGHT AND LICENSE</A><DD>
</DL>
<HR>
This document was created by
<A HREF="/cgi-bin/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 00:05:46 GMT, March 31, 2021
</BODY>
</HTML>