--- trunk/Estraier.pm 2006/01/08 16:49:53 69 +++ trunk/Estraier.pm 2006/01/17 00:03:45 81 @@ -4,7 +4,7 @@ use strict; use warnings; -our $VERSION = '0.03_1'; +our $VERSION = '0.04_1'; =head1 NAME @@ -157,12 +157,12 @@ } elsif ($line =~ m/^$/) { $in_text = 1; next; - } elsif ($line =~ m/^(.+)=(.+)$/) { + } elsif ($line =~ m/^(.+)=(.*)$/) { $self->{attrs}->{ $1 } = $2; next; } - warn "draft ignored: $line\n"; + warn "draft ignored: '$line'\n"; } } @@ -754,6 +754,34 @@ my $node = new Search::HyperEstraier::Node( 'http://localhost:1978/node/test' ); +or in more verbose form + + my $node = new Search::HyperEstraier::Node( + url => 'http://localhost:1978/node/test', + debug => 1, + croak_on_error => 1 + ); + +with following arguments: + +=over 4 + +=item url + +URL to node + +=item debug + +dumps a B of debugging output + +=item croak_on_error + +very helpful during development. It will croak on all errors instead of +silently returning C<-1> (which is convention of Hyper Estraier API in other +languages). + +=back + =cut sub new { @@ -776,7 +804,8 @@ } else { my $args = {@_}; - $self->{debug} = $args->{debug}; + %$self = ( %$self, @_ ); + warn "## Node debug on\n" if ($self->{debug}); } @@ -1418,7 +1447,7 @@ $req->headers->header( 'Host' => $url->host . ":" . $url->port ); $req->headers->header( 'Connection', 'close' ); - $req->headers->header( 'Authorization', 'Basic ' . $self->{auth} ); + $req->headers->header( 'Authorization', 'Basic ' . $self->{auth} ) if ($self->{auth}); $req->content_type( $content_type ); warn $req->headers->as_string,"\n" if ($self->{debug}); @@ -1432,10 +1461,16 @@ warn "## response status: ",$res->status_line,"\n" if ($self->{debug}); - return -1 if (! $res->is_success); - ($self->{status}, $self->{status_message}) = split(/\s+/, $res->status_line, 2); + if (! $res->is_success) { + if ($self->{croak_on_error}) { + croak("can't get $url: ",$res->status_line); + } else { + return -1; + } + } + $$resbody .= $res->content; warn "## response body:\n$$resbody\n" if ($resbody && $self->{debug}); @@ -1535,7 +1570,7 @@ $reqbody .= '&credit=' . $credit if ($credit > 0); $self->shuttle_url( $self->{url} . '/_set_link', - 'text/plain', + 'application/x-www-form-urlencoded', $reqbody, undef ) == 200;