NAME
Protocol::Yadis - Asynchronous Yadis implementation
SYNOPSIS
my $y = Protocol::Yadis->new(
http_req_cb => sub {
my ($url, $method, $headers, $body, $cb) = @_;
...
$cb->($url, $status, $headers, $body);
}
);
$y->discover(
$url => sub {
my ($self, $document) = @_;
if ($document) {
my $services = $document->services;
...
}
else {
die 'error';
}
}
);
DESCRIPTION
This is an asynchronous lightweight but full Yadis implementation.
ATTRIBUTES
http_req_cb
my $y = Protocol::Yadis->new(
http_req_cb => sub {
my ($url, $method, $headers, $body, $cb) = @_;
...
$cb->($url, $status, $headers, $body);
}
);
This is a required callback that is used to download documents from the network. Don't forget, that redirects can occur. This callback must handle them properly. That is why after finishing downloading, callback must be called with the final $url.
Arguments that are passed to the request callback
url url where to start Yadis discovery
method request method
headers request headers
body request body
cb callback that must be called after download was completed
Arguments that must be passed to the response callback
url url from where the document was downloaded
status response status
headers response headers
body response body
head_first
Do HEAD request first. Disabled by default.
METHODS
new
Creates a new Protocol::Yadis instance.
discover
$y->discover(
$url => sub {
my ($self, $document) = @_;
if ($document) {
my $services = $document->services;
...
}
else {
die 'error';
}
}
);
Discover Yadis document at the url provided. Callback is called when discovery was finished. If no document was passed there was an error during discovery.
If a Yadis document was discovered you get Protocol::Yadis::Document instance containing all the services.
error
Returns last error.
AUTHOR
Viacheslav Tykhanovskyi, vti@cpan.org
.
COPYRIGHT
Copyright (C) 2009, Viacheslav Tykhanovskyi.
This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10.