ePages 7.17.0 - DE_EPAGES/WebInterface/API/FakeRequest.pm

Package DE_EPAGES::WebInterface::API::FakeRequest

Similates a web request to the application server without actually transmitting it over a TCP/IP connection. This object instanciates a fake application server and processes the HTTP request locally.

Example
my $FakeRequest = DE_EPAGES::WebInterface::API::FakeRequest->new;
local $FakeRequest->{'UserAgent'} = 'iPad';
local $FakeRequest->{'AcceptCookies'} = 'iPad';
my $Request = HTTP::Request->new( 'GET', '/epages/DemoShop.sf' );
$Request->header( 'Host' => 'www.meinshop.de' );
my $Response = $FakeRequest->request( $Request );
if( !$Response->is_success ) {
    die $Response->status_line;
}
else {
    print $Response->content;
}

Functions

get
new
post
request

get

Simulates a GET request.

Syntax
$Response = $FakeRequest->get( $URL );
$Response = $FakeRequest->get( $URL, $aHeaders );
Example
$Response = $FakeRequest->get( 'http://www.meinshop.de/epages/DemoShop.sf' );
Input
$URL (string)
request URL
$aHeaders (ref.array)
(optional) additional HTTP headers (key1, value1, key2, value2,...)
Return
$Response (object)
HTTP::Response

new

Creates a FakeRequest object.

Syntax
$FakeRequest = DE_EPAGES::WebInterface::API::FakeRequest->new( %Options );
Input
%Options (hash)
options
  • UserAgent - user agent - string
  • AcceptCookes - true if cookies are accepted - boolean
  • Cookies - cookies structure ( $Key => $hOptions ) - ref.hash
Return
$FakeRequest (DE_EPAGES::WebInterface::API::FakeRequest)
Object to similate HTTP requests against the ePages
application server. The interface is inspired from LWP::UserAgent.
$FakeRequest (DE_EPAGES::WebInterface::API::FakeRequest)
new FakeRequest object

post

Simulates a POST request.

Syntax
$Response = $FakeRequest->post( $URL, $Content );
$Response = $FakeRequest->post( $URL, $Content, $ContentType );
$Response = $FakeRequest->post( $URL, $Content, $ContentType, $aHeaders );
Input
$URL (string)
request URL
$Content (string)
request content
$ContentType (string)
(optional) content type (default: application/x-www-form-urlencoded)
$aHeaders (ref.array)
(optional) additional HTTP headers (key1, value1, key2, value2,...)
Return
$Response (object)
HTTP::Response

request

Simulates a request.

Syntax
$Response = $FakeRequest->request( $Request );
Input
$Request (object)
HTTP::Request
Return
$Response (object)
HTTP::Response

Package DE_EPAGES::WebInterface::API::FakeRequest::AppServer

Package DE_EPAGES::WebInterface::API::FakeRequest::MessageCenter