NAME
HTTP::Request::Common - Construct common HTTP::Request objects
SYNOPSIS
use HTTP::Request::Common;
$ua = LWP::UserAgent->new;
$ua->request(GET 'http://www.sn.no/');
$ua->request(POST 'http://somewhere/foo', [foo => bar, bar => foo]);
DESCRIPTION
This module provide functions that return newly created "HTTP::Request" objects. These functions are usually more convenient to use than the standard "HTTP::Request" constructor for the most common requests. The following functions are provided:GET $url
GET $url, Header => Value,...
The GET() function returns an "HTTP::Request" object initialized with the "GET" method and the specified URL. It is roughly equivalent to the following callHTTP::Request->new(
GET => $url,
HTTP::Headers->new(Header => Value,...),
) but is less cluttered. What is different is that a header named "Content" will initialize the content part of the request instead of setting a header field. Note that GET requests should normally not have a content, so this hack makes more sense for the PUT() and POST() functions described below. The get(...) method of "LWP::UserAgent" exists as a shortcut for$ua->request(GET ...).
HEAD $url
HEAD $url, Header => Value,...
Like GET() but the method in the request is "HEAD". The head(...) method of "LWP::UserAgent" exists as a shortcut for$ua->request(HEAD ...).
PUT $url
PUT $url, Header => Value,...
PUT $url, Header => Value,..., Content => $content
Like GET() but the method in the request is "PUT".POST $url
POST $url, Header => Value,...
POST $url, $formref, Header => Value,...
POST $url, Header => Value,..., Content => $formref
This works mostly like GET() with "POST" as the method, but this function also takes a second optional array or hash referenceparameter ($formref). This argument can be used to pass key/value
pairs for the form content. By default we will initialize arequest using the "application/x-www-form-urlencoded" content type.
This means that you can emulate a HTML