| 1 | package Google::OAuth::Headers ; | ||
| 2 | @Google::OAuth::Headers::ISA = qw( Google::OAuth::Request ) ; | ||
| 3 | |||
| 4 | ## use this package for custom header fields: | ||
| 5 | ## Google::OAuth::Headers->new( $token )->add( | ||
| 6 | ## foo => 'bar' | ||
| 7 | ## )->request( GET => $url, ... ) ; | ||
| 8 | |||
| 9 | sub new { | ||
| 10 | my $package = shift ; | ||
| 11 | return bless { headers => [], token => shift @_ }, $package ; | ||
| 12 | } | ||
| 13 | |||
| 14 | sub add { | ||
| 15 | my $self = shift ; | ||
| 16 | push @{ $self->{headers} }, @_ ; | ||
| 17 | return $self ; | ||
| 18 | } | ||
| 19 | |||
| 20 | sub headers { | ||
| 21 | my $self = shift ; | ||
| 22 | my $method = shift ; | ||
| 23 | |||
| 24 | return $self->{token}->headers( $method ), @{ $self->{headers} } ; | ||
| 25 | } | ||
| 26 | |||
| 27 | 1 |