|
Revision 1734
(checked in by miyagawa, 2 years ago)
|
added Test::Spelling and fixed typoes
|
| Line | |
|---|
| 1 |
package Plagger::Plugin::UserAgent::RequestHeader; |
|---|
| 2 |
use strict; |
|---|
| 3 |
use warnings; |
|---|
| 4 |
use base qw( Plagger::Plugin ); |
|---|
| 5 |
|
|---|
| 6 |
sub register { |
|---|
| 7 |
my($self, $context) = @_; |
|---|
| 8 |
$context->register_hook( |
|---|
| 9 |
$self, |
|---|
| 10 |
'useragent.request' => \&add_header, |
|---|
| 11 |
); |
|---|
| 12 |
} |
|---|
| 13 |
|
|---|
| 14 |
sub add_header { |
|---|
| 15 |
my($self, $context, $args) = @_; |
|---|
| 16 |
|
|---|
| 17 |
for my $header (keys %{ $self->conf }) { |
|---|
| 18 |
$args->{ua}->default_header( $header => $self->conf->{$header} ); |
|---|
| 19 |
} |
|---|
| 20 |
} |
|---|
| 21 |
|
|---|
| 22 |
1; |
|---|
| 23 |
|
|---|
| 24 |
__END__ |
|---|
| 25 |
|
|---|
| 26 |
=head1 NAME |
|---|
| 27 |
|
|---|
| 28 |
Plagger::Plugin::UserAgent::RequestHeader - Add arbitrary request header |
|---|
| 29 |
|
|---|
| 30 |
=head1 SYNOPSIS |
|---|
| 31 |
|
|---|
| 32 |
- module: UserAgent::RequestHeader |
|---|
| 33 |
config: |
|---|
| 34 |
Accept-Language: ja, en |
|---|
| 35 |
|
|---|
| 36 |
=head1 DESCRIPTION |
|---|
| 37 |
|
|---|
| 38 |
This plugin hooks Plagger::UserAgent request method to add arbitrary |
|---|
| 39 |
request header when HTTP request is sent. |
|---|
| 40 |
|
|---|
| 41 |
=head1 AUTHOR |
|---|
| 42 |
|
|---|
| 43 |
Tatsuhiko Miyagawa |
|---|
| 44 |
|
|---|
| 45 |
=head1 SEE ALSO |
|---|
| 46 |
|
|---|
| 47 |
L<Plagger>, L<LWP::UserAgent> |
|---|
| 48 |
|
|---|
| 49 |
=cut |
|---|