X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=lib%2FWWW%2FOpenSearch%2FRequest.pm;fp=lib%2FWWW%2FOpenSearch%2FRequest.pm;h=7c33255a10252a2ca6c77414ff2d1a0aa64cc4bb;hb=1fc70f0d6badbef9bb483990d761d1446d52cbb2;hp=0000000000000000000000000000000000000000;hpb=ec50391b25e981b1b9bae8e42e03c0fc9c218845;p=libwww-opensearch-perl.git diff --git a/lib/WWW/OpenSearch/Request.pm b/lib/WWW/OpenSearch/Request.pm new file mode 100644 index 0000000..7c33255 --- /dev/null +++ b/lib/WWW/OpenSearch/Request.pm @@ -0,0 +1,85 @@ +package WWW::OpenSearch::Request; + +use strict; +use warnings; + +use base qw( HTTP::Request Class::Accessor::Fast ); + +use HTTP::Request::Common (); + +__PACKAGE__->mk_accessors( qw( opensearch_url opensearch_params ) ); + +=head1 NAME + +WWW::OpenSearch::Request - Encapsulate an opensearch request + +=head1 SYNOPSIS + +=head1 DESCRIPTION + +=head1 CONSTRUCTOR + +=head2 new( $url, \%params ) + +=head1 METHODS + +=head2 clone( ) + +=head1 ACCESSORS + +=over 4 + +=item * opensearch_url + +=item * opensearch_params + +=back + +=head1 AUTHOR + +=over 4 + +=item * Brian Cassidy Ebricas@cpan.orgE + +=back + +=head1 COPYRIGHT AND LICENSE + +Copyright 2007 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, $os_url, $params ) = @_; + + my( $uri, $post ) = $os_url->prepare_query( $params ); + + my $self; + if( lc $os_url->method eq 'post' ) { + $self = HTTP::Request::Common::POST( $uri, $post ); + bless $self, $class; + } + else { + $self = $class->SUPER::new( $os_url->method => $uri ); + } + + $self->opensearch_url( $os_url ); + $self->opensearch_params( $params ); + + return $self; +} + +sub clone { + my $self = shift; + my $clone = bless $self->SUPER::clone, ref( $self ); + + $clone->opensearch_url( $self->opensearch_url ); + $clone->opensearch_params( $self->opensearch_params ); + + return $clone; +} + +1;