our
(
$VERSION
);
$VERSION
=
'0.17'
;
sub
grand_search_init {
my
(
$self
,
$pages
,
@found
) =
@_
;
@found
=
$self
->SUPER::grand_search_init(
$pages
,
@found
);
return
@found
if
@found
;
print
STDERR
"Searching on remote pod server ...\n"
;
my
$filename
;
if
(
$filename
= get_lwp(
$self
,
$pages
->[0])) {
push
@found
,
$filename
;
return
@found
;
}
elsif
(
$filename
= get_soap(
$self
,
$pages
->[0])) {
push
@found
,
$filename
;
return
@found
;
}
else
{
return
@found
;
}
}
sub
get_lwp {
my
(
$self
,
$mod
) =
@_
;
my
$ua
= LWP::UserAgent->new;
$ua
->agent(
"Pod/Perldocs 0.16 "
);
push
@{
$ua
->requests_redirectable },
'POST'
;
my
$req
= HTTP::Request->new(
POST
=>
$pod_server
);
$req
->content_type(
'application/x-www-form-urlencoded'
);
$req
->content(
"mod=$mod"
);
my
$res
=
$ua
->request(
$req
);
if
(
$res
->is_success) {
my
(
$fh
,
$filename
) =
$self
->new_tempfile();
print
$fh
$res
->content;
return
$filename
;
}
else
{
print
STDERR
"Remote server returned status code: "
.
$res
->status_line .
"\n"
;
return
;
}
}
sub
get_soap {
my
(
$self
,
$mod
) =
@_
;
my
$soap
= make_soap() or
return
;
my
$result
=
$soap
->get_doc(
$mod
);
defined
$result
&&
defined
$result
->result or
do
{
print
STDERR
"No matches found there either.\n"
;
return
;
};
my
$lines
=
$result
->result();
unless
(
$lines
and
ref
(
$lines
) eq
'ARRAY'
) {
print
STDERR
"Documentation not found there either.\n"
;
return
;
}
my
(
$fh
,
$filename
) =
$self
->new_tempfile();
print
$fh
@$lines
;
return
$filename
;
}
sub
make_soap {
print
STDERR
"SOAP::Lite is unavailable to make remote call\n"
;
return
undef
;
}
return
SOAP::Lite
->uri(
$soap_uri
)
->proxy(
$soap_proxy
,
options
=> {
compress_threshold
=> 10000})
->on_fault(
sub
{
my
(
$soap
,
$res
) =
@_
;
print
STDERR
"SOAP Fault: "
,
(
ref
$res
?
$res
->faultstring
:
$soap
->transport->status),
"\n"
;
return
undef
;
});
}
1;