754 |
|
|
755 |
my $node = new Search::HyperEstraier::Node( 'http://localhost:1978/node/test' ); |
my $node = new Search::HyperEstraier::Node( 'http://localhost:1978/node/test' ); |
756 |
|
|
757 |
|
or in more verbose form |
758 |
|
|
759 |
|
my $node = new Search::HyperEstraier::Node( |
760 |
|
url => 'http://localhost:1978/node/test', |
761 |
|
debug => 1, |
762 |
|
croak_on_error => 1 |
763 |
|
); |
764 |
|
|
765 |
|
with following arguments: |
766 |
|
|
767 |
|
=over 4 |
768 |
|
|
769 |
|
=item url |
770 |
|
|
771 |
|
URL to node |
772 |
|
|
773 |
|
=item debug |
774 |
|
|
775 |
|
dumps a B<lot> of debugging output |
776 |
|
|
777 |
|
=item croak_on_error |
778 |
|
|
779 |
|
very helpful during development. It will croak on all errors instead of |
780 |
|
silently returning C<-1> (which is convention of Hyper Estraier API in other |
781 |
|
languages). |
782 |
|
|
783 |
|
=back |
784 |
|
|
785 |
=cut |
=cut |
786 |
|
|
787 |
sub new { |
sub new { |
804 |
} else { |
} else { |
805 |
my $args = {@_}; |
my $args = {@_}; |
806 |
|
|
807 |
$self->{debug} = $args->{debug}; |
%$self = ( %$self, @_ ); |
808 |
|
|
809 |
warn "## Node debug on\n" if ($self->{debug}); |
warn "## Node debug on\n" if ($self->{debug}); |
810 |
} |
} |
811 |
|
|
1463 |
|
|
1464 |
($self->{status}, $self->{status_message}) = split(/\s+/, $res->status_line, 2); |
($self->{status}, $self->{status_message}) = split(/\s+/, $res->status_line, 2); |
1465 |
|
|
1466 |
return -1 if (! $res->is_success); |
if (! $res->is_success) { |
1467 |
|
if ($self->{croak_on_error}) { |
1468 |
|
croak("can't get $url: ",$res->status_line); |
1469 |
|
} else { |
1470 |
|
return -1; |
1471 |
|
} |
1472 |
|
} |
1473 |
|
|
1474 |
$$resbody .= $res->content; |
$$resbody .= $res->content; |
1475 |
|
|