| 1 | package ArangoDB2::HTTP; | ||||||||||||||
| 2 | |||||||||||||||
| 3 | 22 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 4 | 22 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 5 | |||||||||||||||
| 6 | 22 | ▶ | use ArangoDB2::HTTP::LWP; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 7 | |||||||||||||||
| 8 | |||||||||||||||
| 9 | |||||||||||||||
| 10 | # new | ||||||||||||||
| 11 | # | ||||||||||||||
| 12 | # create new ArangoDB2::HTTP instance which will always be | ||||||||||||||
| 13 | # one of the sub-classes of ArangoDB2::HTTP which implements | ||||||||||||||
| 14 | # a particular HTTP client | ||||||||||||||
| 15 | sub new | ||||||||||||||
| 16 | 1 | ▶ | { | ||||||||||||
|
Subroutine
new: called CC=5 SCAR=23.4
Pod
documented
| |||||||||||||||
| 17 | 1 | my($self, $arango) = @_; | |||||||||||||
| 18 | |||||||||||||||
| 19 | # see if specific http client is set | ||||||||||||||
| 20 | 1 | ▶ | if (my $http_client = $arango->http_client) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 21 | 0 | ▶ | if ($http_client eq 'lwp') { | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 22 | 0 | return ArangoDB2::HTTP::LWP->new($arango); | |||||||||||||
| 23 | } | ||||||||||||||
| 24 | elsif ($http_client eq 'curl') { | ||||||||||||||
| 25 | 0 | require ArangoDB2::HTTP::Curl; | |||||||||||||
| 26 | 0 | return ArangoDB2::HTTP::Curl->new($arango); | |||||||||||||
| 27 | } | ||||||||||||||
| 28 | } | ||||||||||||||
| 29 | |||||||||||||||
| 30 | # if no client was set then use curl if possible | ||||||||||||||
| 31 | # and if not fall back to LWP | ||||||||||||||
| 32 | 1 | my $curl = eval { require WWW::Curl::Easy }; | |||||||||||||
| 33 | |||||||||||||||
| 34 | 1 | ▶ | if ($curl) { | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 35 | 0 | require ArangoDB2::HTTP::Curl; | |||||||||||||
| 36 | 0 | return ArangoDB2::HTTP::Curl->new($arango); | |||||||||||||
| 37 | } | ||||||||||||||
| 38 | else { | ||||||||||||||
| 39 | # for now use lwp client | ||||||||||||||
| 40 | 1 | return ArangoDB2::HTTP::LWP->new($arango); | |||||||||||||
| 41 | } | ||||||||||||||
| 42 | } | ||||||||||||||
| 43 | |||||||||||||||
| 44 | # arango | ||||||||||||||
| 45 | # | ||||||||||||||
| 46 | # ArangoDB2 instance | ||||||||||||||
| 47 | 1 | ▶ | sub arango { $_[0]->{arango} } | ||||||||||||
|
Subroutine
arango: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 48 | |||||||||||||||
| 49 | # error | ||||||||||||||
| 50 | # | ||||||||||||||
| 51 | # get/set last error (HTTP status) code | ||||||||||||||
| 52 | sub error | ||||||||||||||
| 53 | 0 | ▶ | { | ||||||||||||
|
Subroutine
error: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||
| 54 | 0 | my($self, $error) = @_; | |||||||||||||
| 55 | |||||||||||||||
| 56 | 0 | ▶ | $self->{error} = $error | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 57 | if defined $error; | ||||||||||||||
| 58 | |||||||||||||||
| 59 | 0 | return $self->{error}; | |||||||||||||
| 60 | } | ||||||||||||||
| 61 | |||||||||||||||
| 62 | 22 | 1; | |||||||||||||
| 63 | |||||||||||||||
| 64 | __END__ | ||||||||||||||