File: Agent.pm

package info (click to toggle)
libwww-opensearch-perl 0.17-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 228 kB
  • sloc: perl: 1,663; xml: 31; makefile: 2
file content (68 lines) | stat: -rw-r--r-- 1,197 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package WWW::OpenSearch::Agent;

use strict;
use warnings;

use base qw( LWP::UserAgent );

use WWW::OpenSearch;
use WWW::OpenSearch::Response;

=head1 NAME

WWW::OpenSearch::Agent - An agent for doing OpenSearch requests

=head1 SYNOPSIS

=head1 DESCRIPTION

=head1 CONSTRUCTOR

=head2 new( [%options] )

=head1 METHODS

=head2 request( $request | $url, \%params )

=head2 search( )

An alias for request()

=head1 AUTHOR

=over 4

=item * Brian Cassidy E<lt>bricas@cpan.orgE<gt>

=back

=head1 COPYRIGHT AND LICENSE

Copyright 2005-2013 by Tatsuhiko Miyagawa and Brian Cassidy

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself. 

=cut

sub new {
    my ( $class, @rest ) = @_;
    return $class->SUPER::new(
        agent => join( '/', __PACKAGE__, $WWW::OpenSearch::VERSION ),
        @rest,
    );
}

*search = \&request;

sub request {
    my $self     = shift;
    my $request  = shift;
    my $response = $self->SUPER::request( $request, @_ );

    # allow regular HTTP::Requests to flow through
    return $response unless $request->isa( 'WWW::OpenSearch::Request' );
    return WWW::OpenSearch::Response->new( $response );
}

1;