Let us start with this quote from the HTTP specification document
<URL:http://www.w3.org/pub/WWW/Protocols/>:
=over 3
=item
The HTTP protocol is based on a request/response paradigm. A client
establishes a connection with a server and sends a request to the
server in the form of a request method, URI, and protocol version,
followed by a MIME-like message containing request modifiers, client
information, and possible body content. The server responds with a
status line, including the message's protocol version and a success or
error code, followed by a MIME-like message containing server
information, entity meta-information, and possible body content.
=back
What this means to libwww-perl is that communication always take place
through these steps: First a I<request> object is created and
configured. This object is then passed to a server and we get a
I<response> object in return that we can examine. A request is always
independent of any previous requests, i.e. the service is stateless.
The same simple model is used for any kind of service we want to
access.
For example, if we want to fetch a document from a remote file server,
then we send it a request that contains a name for that document and
the response will contain the document itself. If we access a search
engine, then the content of the request will contain the query
parameters and the response will contain the query result. If we want
to send a mail message to somebody then we send a request object which
contains our message to the mail server and the response object will
contain an acknowledgment that tells us that the message has been
accepted and will be forwarded to the recipient(s).
It is as simple as that!
=head2 The Request Object
The libwww-perl request object has the class name C<HTTP::Request>.
The fact that the class name uses C<HTTP::> as a
prefix only implies that we use the HTTP model of communication. It
does not limit the kind of services we can try to pass this I<request>
to. For instance, we will send C<HTTP::Request>s both to ftp and
gopher servers, as well as to the local file system.
The main attributes of the request objects are:
=over 3
=item *
The B<method> is a short string that tells what kind of
request this is. The most common methods are B<GET>, B<PUT>,
B<POST> and B<HEAD>.
=item *
The B<uri> is a string denoting the protocol, server and
the name of the "document" we want to access. The B<uri> might
also encode various other parameters.
=item *
The B<headers> contain additional information about the
request and can also used to describe the content. The headers
are a set of keyword/value pairs.
=item *
The B<content> is an arbitrary amount of data.
=back
=head2 The Response Object
The libwww-perl response object has the class name C<HTTP::Response>.
The main attributes of objects of this class are:
=over 3
=item *
The B<code> is a numerical value that indicates the overall
outcome of the request.
=item *
The B<message> is a short, human readable string that
corresponds to the I<code>.
=item *
The B<headers> contain additional information about the
response and describe the content.
=item *
=2= |