| 1 | 1 | ▶ | use 5.008001; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | package HTTP::CookieJar::LWP; | ||||||||||||||||||||||||||||
| 6 | # ABSTRACT: LWP adapter for HTTP::CookieJar | ||||||||||||||||||||||||||||
| 7 | 1 | our $VERSION = '0.014'; | |||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use parent 'HTTP::CookieJar'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 44 | ▶ | sub add_cookie_header { | ||||||||||||||||||||||||||
|
Subroutine
add_cookie_header: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | 44 | my ( $self, $request ) = @_; | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 44 | my $url = _get_url( $request, $request->uri ); | |||||||||||||||||||||||||||
| 15 | 44 | ▶ | return unless ( $url->scheme =~ /^https?\z/ ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 41 | my $header = $self->cookie_header($url); | |||||||||||||||||||||||||||
| 18 | 41 | $request->header( Cookie => $header ); | |||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | 41 | return $request; | |||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 40 | ▶ | sub extract_cookies { | ||||||||||||||||||||||||||
|
Subroutine
extract_cookies: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||
| 24 | 40 | my ( $self, $response ) = @_; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 40 | ▶ | my $request = $response->request | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | or return; | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 39 | my $url = _get_url( $request, $request->uri ); | |||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 39 | $self->add( $url, $_ ) for $response->_header("Set-Cookie"); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 39 | return $response; | |||||||||||||||||||||||||||
| 34 | } | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 37 | # helper subroutines | ||||||||||||||||||||||||||||
| 38 | #--------------------------------------------------------------------------# | ||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||
| 40 | 83 | ▶ | sub _get_url { | ||||||||||||||||||||||||||
|
Subroutine
_get_url: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 41 | 83 | my ( $request, $url ) = @_; | |||||||||||||||||||||||||||
| 42 | 83 | my $new_url = $url->clone; | |||||||||||||||||||||||||||
| 43 | 83 | ▶ | if ( my $h = $request->header("Host") ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 44 | 2 | $h =~ s/:\d+$//; # might have a port as well | |||||||||||||||||||||||||||
| 45 | 2 | $new_url->host($h); | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | 83 | return $new_url; | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | sub _url_path { | ||||||||||||||||||||||||||
|
Subroutine
_url_path: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 51 | 0 | my $url = shift; | |||||||||||||||||||||||||||
| 52 | 0 | my $path; | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( $url->can('epath') ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $path = $url->epath; # URI::URL method | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||
| 57 | 0 | $path = $url->path; # URI::_generic method | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | 0 | ▶ | $path = "/" unless length $path; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | $path; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | sub _normalize_path # so that plain string compare can be used | ||||||||||||||||||||||||||||
| 64 | 0 | ▶ | { | ||||||||||||||||||||||||||
|
Subroutine
_normalize_path: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||
| 65 | 0 | my $x; | |||||||||||||||||||||||||||
| 66 | 0 | $_[0] =~ s/%([0-9a-fA-F][0-9a-fA-F])/ | |||||||||||||||||||||||||||
| 67 | 0 | $x = uc($1); | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | $x eq "2F" || $x eq "25" ? "%$x" : | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$x eq "2F" or $x eq 25
MC/DC0%0/2
$x eq "2F" or $x eq 25
$x eq "2F"
$x eq 25
Truth table0%0/3
A or B
A= $x eq "2F"B= $x eq 25
| |||||||||||||||||||||||||||||
| 69 | pack("C", hex($x)); | ||||||||||||||||||||||||||||
| 70 | /eg; | ||||||||||||||||||||||||||||
| 71 | 0 | $_[0] =~ s/([\0-\x20\x7f-\xff])/sprintf("%%%02X",ord($1))/eg; | |||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | 1 | 1; | |||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | # vim: ts=4 sts=4 sw=4 et: | ||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||
| 79 | __END__ | ||||||||||||||||||||||||||||