home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>mirror - Procedural LWP interface</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> mirror - Procedural LWP interface</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <LI><A HREF="#see also">SEE ALSO</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>get, head, getprint, getstore, mirror - Procedural LWP interface</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <PRE>
- perl -MLWP::Simple -e 'getprint "<A HREF="http://www.sn.no"">http://www.sn.no"</A>;'</PRE>
- <PRE>
- use LWP::Simple;
- $content = get("<A HREF="http://www.sn.no/"">http://www.sn.no/"</A>;)
- if (mirror("<A HREF="http://www.sn.no/"">http://www.sn.no/"</A>;, "foo") == RC_NOT_MODIFIED) {
- ...
- }</PRE>
- <PRE>
- if (is_success(getprint("<A HREF="http://www.sn.no/"">http://www.sn.no/"</A>;))) {
- ...
- }</PRE>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>This interface is intended for those who want a simplified view of the
- libwww-perl library. It should also be suitable for one-liners. If
- you need more control or access to the header fields in the requests
- sent and responses received you should use the full object oriented
- interface provided by the <CODE>LWP::UserAgent</CODE> module.</P>
- <P>The following functions are provided (and exported) by this module:</P>
- <DL>
- <DT><STRONG><A NAME="item_get"><CODE>get($url)</CODE></A></STRONG><BR>
- <DD>
- The <A HREF="#item_get"><CODE>get()</CODE></A> function will fetch the document identified by the given URL
- and return it. It returns <A HREF="../../../lib/Pod/perlfunc.html#item_undef"><CODE>undef</CODE></A> if it fails. The $url argument can
- be either a simple string or a reference to a URI object.
- <P>You will not be able to examine the response code or response headers
- (like 'Content-Type') when you are accessing the web using this
- function. If you need that information you should use the full OO
- interface (see <A HREF="../../../site/lib/LWP/UserAgent.html">the LWP::UserAgent manpage</A>).</P>
- <P></P>
- <DT><STRONG><A NAME="item_head"><CODE>head($url)</CODE></A></STRONG><BR>
- <DD>
- Get document headers. Returns the following 5 values if successful:
- ($content_type, $document_length, $modified_time, $expires, $server)
- <P>Returns an empty list if it fails. In scalar context returns TRUE if
- successful.</P>
- <P></P>
- <DT><STRONG><A NAME="item_getprint"><CODE>getprint($url)</CODE></A></STRONG><BR>
- <DD>
- Get and print a document identified by a URL. The document is printed
- to STDOUT as data is received from the network. If the request fails,
- then the status code and message are printed on STDERR. The return
- value is the HTTP response code.
- <P></P>
- <DT><STRONG><A NAME="item_getstore">getstore($url, $file)</A></STRONG><BR>
- <DD>
- Gets a document identified by a URL and stores it in the file. The
- return value is the HTTP response code.
- <P></P>
- <DT><STRONG><A NAME="item_mirror">mirror($url, $file)</A></STRONG><BR>
- <DD>
- Get and store a document identified by a URL, using
- <EM>If-modified-since</EM>, and checking the <EM>Content-Length</EM>. Returns
- the HTTP response code.
- <P></P></DL>
- <P>This module also exports the HTTP::Status constants and procedures.
- These can be used when you check the response code from getprint(),
- <A HREF="#item_getstore"><CODE>getstore()</CODE></A> and mirror(). The constants are:</P>
- <PRE>
- RC_CONTINUE
- RC_SWITCHING_PROTOCOLS
- RC_OK
- RC_CREATED
- RC_ACCEPTED
- RC_NON_AUTHORITATIVE_INFORMATION
- RC_NO_CONTENT
- RC_RESET_CONTENT
- RC_PARTIAL_CONTENT
- RC_MULTIPLE_CHOICES
- RC_MOVED_PERMANENTLY
- RC_MOVED_TEMPORARILY
- RC_SEE_OTHER
- RC_NOT_MODIFIED
- RC_USE_PROXY
- RC_BAD_REQUEST
- RC_UNAUTHORIZED
- RC_PAYMENT_REQUIRED
- RC_FORBIDDEN
- RC_NOT_FOUND
- RC_METHOD_NOT_ALLOWED
- RC_NOT_ACCEPTABLE
- RC_PROXY_AUTHENTICATION_REQUIRED
- RC_REQUEST_TIMEOUT
- RC_CONFLICT
- RC_GONE
- RC_LENGTH_REQUIRED
- RC_PRECONDITION_FAILED
- RC_REQUEST_ENTITY_TOO_LARGE
- RC_REQUEST_URI_TOO_LARGE
- RC_UNSUPPORTED_MEDIA_TYPE
- RC_INTERNAL_SERVER_ERROR
- RC_NOT_IMPLEMENTED
- RC_BAD_GATEWAY
- RC_SERVICE_UNAVAILABLE
- RC_GATEWAY_TIMEOUT
- RC_HTTP_VERSION_NOT_SUPPORTED</PRE>
- <P>The HTTP::Status classification functions are:</P>
- <DL>
- <DT><STRONG><A NAME="item_is_success"><CODE>is_success($rc)</CODE></A></STRONG><BR>
- <DD>
- True if response code indicated a successful request.
- <P></P>
- <DT><STRONG><A NAME="item_is_error"><CODE>is_error($rc)</CODE></A></STRONG><BR>
- <DD>
- True if response code indicated that an error occured.
- <P></P></DL>
- <P>The module will also export the LWP::UserAgent object as <CODE>$ua</CODE> if you
- ask for it explicitly.</P>
- <P>The user agent created by this module will identify itself as
- ``LWP::Simple/#.##'' (where ``#.##'' is the libwww-perl version number)
- and will initialize its proxy defaults from the environment (by
- calling $ua->env_proxy).</P>
- <P>
- <HR>
- <H1><A NAME="see also">SEE ALSO</A></H1>
- <P><A HREF="../../../site/lib/LWP.html">the LWP manpage</A>, <A HREF="../../../site/lib/LWP/UserAgent.html">the LWP::UserAgent manpage</A>, <A HREF="../../../site/lib/HTTP/Status.html">the HTTP::Status manpage</A>, <EM>lwp-request</EM>,
- <EM>lwp-mirror</EM></P>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> mirror - Procedural LWP interface</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-