| 1 | package Net::RDAP::Server::Request; | ||
| 2 | # ABSTRACT: An RDAP request object. | ||
| 3 | 1 | ▶ | use base qw(HTTP::Request); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | |||
| 6 | |||
| 7 | |||
| 8 | 0 | ▶ | sub from_cgi { |
|
Subroutine
from_cgi: not called CC=2 SCAR=17.9
Pod
documented
| |||
| 9 | 0 | my ($package, $cgi) = @_; | |
| 10 | |||
| 11 | 0 | my $url = URI->new(sprintf( | |
| 12 | '%s://%s:%s%s', | ||
| 13 | $cgi->protocol, | ||
| 14 | $cgi->virtual_host, | ||
| 15 | $cgi->server_port, | ||
| 16 | $cgi->request_uri, | ||
| 17 | ))->canonical; | ||
| 18 | |||
| 19 | 0 | my $request = $package->new($cgi->request_method, $url); | |
| 20 | |||
| 21 | 0 | foreach my $name (map { lc } $cgi->http) { | |
| 22 | 0 | my $value = $cgi->http($name); | |
| 23 | 0 | $name =~ s/^http_//i; | |
| 24 | 0 | $name =~ s/_/-/g; | |
| 25 | 0 | $request->header($name => $value); | |
| 26 | } | ||
| 27 | |||
| 28 | 0 | $request->{_cgi} = $cgi; | |
| 29 | |||
| 30 | 0 | return $request; | |
| 31 | } | ||
| 32 | |||
| 33 | |||
| 34 | 0 | ▶ | sub cgi { shift->{_cgi} } |
|
Subroutine
cgi: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 35 | |||
| 36 | |||
| 37 | 0 | ▶ | sub type { |
|
Subroutine
type: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 38 | 0 | my $self = shift; | |
| 39 | |||
| 40 | 0 | return [ grep { length > 0 } $self->uri->path_segments ]->[0]; | |
| 41 | } | ||
| 42 | |||
| 43 | |||
| 44 | 0 | ▶ | sub object { |
|
Subroutine
object: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 45 | 0 | my $self = shift; | |
| 46 | |||
| 47 | # get the segments from the path... | ||
| 48 | 0 | my @segments = grep { length > 0 } $self->uri->path_segments; | |
| 49 | |||
| 50 | # remove the leading value (which is the type) | ||
| 51 | 0 | shift(@segments); | |
| 52 | |||
| 53 | # join the remaining segments (because CIDR prefixes will contain a slash) | ||
| 54 | 0 | return join('/', @segments); | |
| 55 | } | ||
| 56 | |||
| 57 | 1 | 1; | |
| 58 | |||
| 59 | __END__ | ||