NAME
WWW::Kickstarter::HttpClient - HTTP client connector for WWW::Kickstarter
SYNOPSIS
use WWW::Kickstarter;
my $ks = WWW::Kickstarter->new(
http_client_class => 'WWW::Kickstarter::HttpClient::Lwp', # default
...
);
DESCRIPTION
This module documents the interface that must be provided by HTTP clients to be used by WWW::Kickstarter.
CONSTRUCTOR
new
my $http_client = $http_client_class->new(%opts);
The constructor. An WWW::Kickstarter::Error object is thrown on error.
Options:
agent => "application_name/version "
The string to pass to Kickstarter in the User-Agent HTTP header. If the string ends with a space, the name and version of this library will be appended, as will the name of version of the underling HTTP client.
METHODS
request
my ( $status_code, $status_line, $content_type, $content_encoding, $content ) =
$http_client->request($method, $url, $req_content);
Performs an HTTP request for the URL specified by $url
using the method specified by $method
(either GET
or POST
). For POST
requests, $req_content
will contain the content (of type application/x-www-form-urlencoded
) to send in the request.
An Accept
header with value application/json; charset=utf-8
must be provided.
The following are returned: The HTTP status code received from the server ($status
), the status line including the HTTP status code ($status_line
), the type of the content of the response ($content_type
), the character encoding of the content ($content_encoding
), and the content of the response ($content
).
If a communication failure occurs, appropriate values for $status
and $status_line
should be mocked up, such as 599
and 599 Can't connect to api.kickstarter.com
.
The value returned for $content_type
must be in lower-case letters and devoid of parameters. undef
can be returned for $content_type
, and it need not be lower-case. For example, $content_type
will be text/html
and $content_encoding
can be UTF-8
for Text/HTML; charset=UTF-8
.
VERSION, BUGS, KNOWN ISSUES, DOCUMENTATION, SUPPORT, AUTHOR, COPYRIGHT AND LICENSE
See WWW::Kickstarter