Home | Wiki | OI 1.x Docs | OI 2.x Docs |
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( ... ) }, ); # ...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' );
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.
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:
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.
Default: none
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.
Default: none
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.
Default: none
The simple request properties set are:
referer - Set to what you'd like to be the referring page.
Default: none
user_agent - Set to the user agent for this request.
Default: none
server_name - Set to the server hostname.
Default: return value from Sys::Hostname
remote_host - Set to the host making the request.
Default: none
None known.
Add settable auth_* properties
Add settable theme_* properties?
OpenInteract2::Response::Standalone
Copyright (c) 2001-2003 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>
Generated from the OpenInteract 1.99_03 source.