This class provides methods required to support a simple rest client for various HTTP interactions. It has been designed to be as closest as possible to HTTP::Request and LWP::UserAgent object methods.
The following is an example of its usage.
sub stepGetContent {
my ($pluginObject) = @_;
# retrieving context object
my $context = $pluginObject->getContext();
# creating new FlowPDF::Client::REST object
my $rest = $context->newRESTClient();
# creatung new HTTP::Request object using FlowPDF APIs
my $request = $rest->newRequest(GET => 'http://electric-cloud.com');
# performing request and getting HTTP::Response object.
my $response = $rest->doRequest($request);
# printing response content
print "Content: ", $response->decoded_content();
}
new($parameters)
Class Constructor. Creates new FlowPDF::Client::REST object.
To use FlowPDF::Client::REST with proxy provide a proxy parameters to constructor. They are:
-
url
Address of the proxy to be used as http proxy.
-
username
username for proxy authorization.
-
password
password for proxy authorization.
-
debug
Switch to enable debug. If set to True FlowPDF::Proxy will be enabled for debug as well.
newRequest(@parameters)
Creates new HTTP::Request object.
This wrapper has been created to implement augmenations to components during request object creation.
For example, if FlowPDF::Client::Rest has been created with proxy support, it will return HTTP::Request object with applied proxy fields.
This method has the same interface and usage as HTTP::Request::new();
doRequest($httpRequest)
Performs HTTP request, using HTTP::Request object as parameter, leveraging the LWP::UserAgent::request() method.