| line | stmt | bran | cond | sub | pod | time | code | 
| 1 | 17 |  |  | 17 |  | 313 | use 5.010; | 
|  | 17 |  |  |  |  | 71 |  | 
| 2 | 17 |  |  | 17 |  | 116 | use strict; | 
|  | 17 |  |  |  |  | 33 |  | 
|  | 17 |  |  |  |  | 375 |  | 
| 3 | 17 |  |  | 17 |  | 80 | use warnings; | 
|  | 17 |  |  |  |  | 35 |  | 
|  | 17 |  |  |  |  | 443 |  | 
| 4 | 17 |  |  | 17 |  | 94 | use utf8; | 
|  | 17 |  |  |  |  | 41 |  | 
|  | 17 |  |  |  |  | 299 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | package Neo4j::Driver::Result::Text; | 
| 7 |  |  |  |  |  |  | # ABSTRACT: Fallback handler for result errors | 
| 8 |  |  |  |  |  |  | $Neo4j::Driver::Result::Text::VERSION = '0.39'; | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | # This package is not part of the public Neo4j::Driver API. | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  |  | 
| 13 | 17 |  |  | 17 |  | 1150 | use parent 'Neo4j::Driver::Result'; | 
|  | 17 |  |  |  |  | 50 |  | 
|  | 17 |  |  |  |  | 129 |  | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | our @CARP_NOT = qw(Neo4j::Driver::Net::HTTP); | 
| 16 |  |  |  |  |  |  |  | 
| 17 | 17 |  |  | 17 |  | 1726 | use Neo4j::Error; | 
|  | 17 |  |  |  |  | 57 |  | 
|  | 17 |  |  |  |  | 8218 |  | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | #our $ACCEPT_HEADER = "text/*; q=0.1"; | 
| 21 |  |  |  |  |  |  |  | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | sub new { | 
| 24 |  |  |  |  |  |  | # uncoverable pod (private method) | 
| 25 | 11 |  |  | 11 | 0 | 30 | my ($class, $params) = @_; | 
| 26 |  |  |  |  |  |  |  | 
| 27 | 11 |  |  |  |  | 24 | my $header = $params->{http_header}; | 
| 28 | 11 |  |  |  |  | 20 | my $error = 'Neo4j::Error'; | 
| 29 |  |  |  |  |  |  |  | 
| 30 | 11 | 100 | 100 |  |  | 68 | if (! $header->{success} && ! $header->{status}) { | 
|  |  | 100 |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | # Response generated internally by the networking module | 
| 32 | 1 |  |  |  |  | 6 | $error = $error->append_new( Network => sprintf("HTTP error: %s", $params->{http_agent}->http_reason) ); | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  | elsif (! $header->{success}) { | 
| 35 |  |  |  |  |  |  | $error = $error->append_new( Network => { | 
| 36 |  |  |  |  |  |  | code => $header->{status}, | 
| 37 | 4 |  |  |  |  | 22 | as_string => sprintf("HTTP error: %s %s on %s to %s", $header->{status}, $params->{http_agent}->http_reason, $params->{http_method}, $params->{http_path}), | 
| 38 |  |  |  |  |  |  | }); | 
| 39 |  |  |  |  |  |  | } | 
| 40 |  |  |  |  |  |  |  | 
| 41 | 11 |  |  |  |  | 28231 | my ($content_type) = $header->{content_type} =~ m/^\s*([^\s;]*)/; | 
| 42 | 11 | 100 | 66 |  |  | 69 | if (lc $content_type eq 'text/plain') { | 
|  |  | 100 |  |  |  |  |  | 
|  |  | 100 |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | $error = $error->append_new( Internal => { | 
| 44 |  |  |  |  |  |  | as_string => $params->{http_agent}->fetch_all, | 
| 45 | 6 |  |  |  |  | 29 | }); | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | elsif ($content_type =~ m{^text/html\b|^application/xhtml\b}i) { | 
| 48 | 3 |  |  |  |  | 8 | my $raw = $params->{http_agent}->fetch_all; | 
| 49 | 3 |  |  |  |  | 39 | my ($title) = $raw =~ m{([^<]*)}i; | 
| 50 | 3 | 100 |  |  |  | 28 | $error = $error->append_new( Internal => { | 
| 51 |  |  |  |  |  |  | as_string => sprintf("Received HTML content%s from server (Is this a Neo4j server?)", $title ? " \"$title\"" : ""), | 
| 52 |  |  |  |  |  |  | raw => $raw, | 
| 53 |  |  |  |  |  |  | }); | 
| 54 |  |  |  |  |  |  | } | 
| 55 |  |  |  |  |  |  | elsif ($content_type || $header->{status}) { | 
| 56 |  |  |  |  |  |  | $error = $error->append_new( Internal => { | 
| 57 |  |  |  |  |  |  | as_string => sprintf("Received %s content from database server; skipping result parsing", $content_type || "empty"), | 
| 58 |  |  |  |  |  |  | raw => $params->{http_agent}->fetch_all, | 
| 59 | 1 |  | 50 |  |  | 12 | }); | 
| 60 |  |  |  |  |  |  | } | 
| 61 |  |  |  |  |  |  |  | 
| 62 | 11 |  |  |  |  | 23154 | return bless { _error => $error }, $class; | 
| 63 |  |  |  |  |  |  | } | 
| 64 |  |  |  |  |  |  |  | 
| 65 |  |  |  |  |  |  |  | 
| 66 | 11 |  |  | 11 |  | 23 | sub _info { shift } | 
| 67 |  |  |  |  |  |  |  | 
| 68 |  |  |  |  |  |  |  | 
| 69 | 1 |  |  | 1 |  | 24 | sub _results { () }  # no actual results provided here | 
| 70 |  |  |  |  |  |  |  | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | # sub _accept_header { () } | 
| 73 |  |  |  |  |  |  | # | 
| 74 |  |  |  |  |  |  | # | 
| 75 |  |  |  |  |  |  | # sub _acceptable { | 
| 76 |  |  |  |  |  |  | # 	my ($class, $content_type) = @_; | 
| 77 |  |  |  |  |  |  | # | 
| 78 |  |  |  |  |  |  | # 	return $_[1] =~ m|^text/|i; | 
| 79 |  |  |  |  |  |  | # } | 
| 80 |  |  |  |  |  |  |  | 
| 81 |  |  |  |  |  |  |  | 
| 82 |  |  |  |  |  |  | 1; |