OpenInteract2::Request::Standalone - Manually create a request object
# Set the request implementation to use OpenInteract2::Request->set_implementation_type( 'standalone' ); # Create all the request infomration offline... my %req_params = ( url => '/path/to/my/doc.html', referer => 'http://www.foo.bar/path/to/my/index.html', user_agent => 'OI2 Standalone Requester', server_name => 'www.foo.bar', remote_host => '192.168.1.1', param => { eyes => 'two', soda => [ 'rc', 'mr. pibb' ] }, cookie => [ 'lastSeen=1051797475;firstLogin=1051797075', OpenInteract2::Cookie->new( ... ), ], upload => { sendfile => OpenInteract2::Upload->new( ... ), screenshot => OpenInteract2::Upload->new( ... ) }, languages => [ 'en-UK', 'en-US', 'de', 'fr' ], ); # ...and create a new object with it my $req = OpenInteract2::Request->new( \%req_params ); # ...or just create an empty object with the bare minimum of # infomration and set properties as needed my $req = OpenInteract2::Request->new( { url => '/path/to/my/doc.html' } ); $req->referer( 'http://www.foo.bar/path/to/my/index.html' ); $req->param( eyes => 'two' ); $req->param( soda => [ 'rc', 'mr. pibb' ] ); $req->cookie( lastSeen => '1051797475' ); $req->language_header( 'en, de;q=.96, fr;q=.92' );
This object is mainly used for testing, but you can also use it as glue to some other operating environment. The only thing this module does is take the properties passed into the new() call (and passed by OpenInteract2::Request via init()) and set them into the object.
new()
init()
init( \%properties )
Set all the properties from \%properties in the object. Since almost all the properties are simple key/value pairs this is straightforward. There are a few more complicated ones:
\%properties
url - Required. This is the full URL path (without the protocol, host and port information) and will get parsed into the url_absolute, url_relative and url_initial request properties.
Default: none
param - This must be a hashref of key/value pairs. You can represent multi-valued parameters by setting the value within the hashref to an arrayref. Setting the value of this property to a simple scalar or arrayref, or setting any of the parameter values to a hashref, is grounds for an exception to be thrown.
cookie - You can pass in one or more cookie strings (what the browser passes in its Cookie header) and/or one or more CGI::Cookie objects. If the values set aren't simple scalars or cookie objects an exception is thrown.
Cookie
upload - You can pass in one or more OpenInteract2::Upload objects associated with fields in a hashref. Setting the property value to anything other than a hashref, or setting the value associated with an upload field to anything other than an upload object, will cause an exception.
The simple request properties set are:
referer - Set to what you'd like to be the referring page.
user_agent - Set to the user agent for this request.
server_name - Set to the server hostname.
Default: return value from Sys::Hostname
remote_host - Set to the host making the request.
None known.
Add settable auth_* properties
Add settable theme_* properties?
OpenInteract2::Response::Standalone
Copyright (c) 2001-2004 Chris Winters. All rights reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Chris Winters <chris@cwinters.com>
To install OpenInteract2::URL, copy and paste the appropriate command in to your terminal.
cpanm
cpanm OpenInteract2::URL
CPAN shell
perl -MCPAN -e shell install OpenInteract2::URL
For more information on module installation, please visit the detailed CPAN module installation guide.