Вячеслав Тихановский > Protocol-Yadis-0.990102 > Protocol::Yadis

Download:
Protocol-Yadis-0.990102.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.990102   Source   Latest Release: Protocol-Yadis-1.00

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, $error);
        }
    );

    $y->discover(
        $url => sub {
            my ($self, $document, $error) = @_;

            if ($document) {
                my $services = $document->services;

                ...
            }
            elsif ($error) {
                die "Error: $error";
            }
            else {
                die "Nothing found";
            }
        }
    );

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, $error);
        }
    );

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

Arguments that must be passed to the response callback

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, $error) = @_;

            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. Error is passed as the third parameter.

If a Yadis document was discovered you get Protocol::Yadis::Document instance containing all the services.

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.

syntax highlighting: