| 1 | package HTTP::Body::Builder::UrlEncoded; | ||||||||||
| 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 | 1 | ▶ | use utf8; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use 5.008_005; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | |||||||||||
| 7 | 1 | ▶ | use Carp (); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use URI; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | |||||||||||
| 10 | sub new { | ||||||||||
| 11 | 3 | ▶ | my $class = shift; | ||||||||
|
Subroutine
new: called CC=2 SCAR=7.6
Pod
documented
| |||||||||||
| 12 | 3 | ▶ | my %args = @_==1 ? %{$_[0]} : @_; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | 3 | bless { | |||||||||
| 14 | %args | ||||||||||
| 15 | }, $class; | ||||||||||
| 16 | } | ||||||||||
| 17 | |||||||||||
| 18 | sub add_content { | ||||||||||
| 19 | 2 | ▶ | my ($self, $name, $value) = @_; | ||||||||
|
Subroutine
add_content: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 20 | 2 | push @{$self->{content}}, [$name, $value]; | |||||||||
| 21 | } | ||||||||||
| 22 | |||||||||||
| 23 | sub content_type { | ||||||||||
| 24 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
content_type: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 25 | 0 | return 'application/x-www-form-urlencoded'; | |||||||||
| 26 | } | ||||||||||
| 27 | |||||||||||
| 28 | sub add_file { | ||||||||||
| 29 | 1 | ▶ | Carp::croak "You cannot add file with application/x-www-form-urlencoded."; | ||||||||
|
Subroutine
add_file: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||
| 30 | } | ||||||||||
| 31 | |||||||||||
| 32 | sub as_string { | ||||||||||
| 33 | 2 | ▶ | my ($self) = @_; | ||||||||
|
Subroutine
as_string: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||
| 34 | |||||||||||
| 35 | 2 | my $uri = URI->new('http:'); | |||||||||
| 36 | 2 | $uri->query_form(@{$self->{content}}); | |||||||||
| 37 | 2 | my $content = $uri->query; | |||||||||
| 38 | |||||||||||
| 39 | # HTML/4.01 says that line breaks are represented as "CR LF" pairs (i.e., `%0D%0A') | ||||||||||
| 40 | 2 | ▶ | $content =~ s/(?<!%0D)%0A/%0D%0A/g if defined($content); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 2 | $content; | |||||||||
| 42 | } | ||||||||||
| 43 | |||||||||||
| 44 | 1 | 1; | |||||||||
| 45 | __END__ | ||||||||||