Package =TWiki::NetObject that brokers access to network resources.On this page:
ObjectMethod finish ()Break circular references. | ||||||||
Changed: | ||||||||
< < | getExternalResource( $url ) -> $response | |||||||
> > | @hea | |||||||
Get whatever is at the other end of a URL (using an HTTP GET request). Will
only work for encrypted protocols such as https if the LWP CPAN module is
installed.
Note that the $url may have an optional user and password, as specified by | ||||||||
Changed: | ||||||||
< < | the relevant RFC. Any proxy set in configure is honoured. | |||||||
> > | the relevant RFC. Any proxy set in configure is honored. | |||||||
Added: | ||||||||
> > | Optional headers may be supplied of form 'name1', 'value1', 'name2', 'value2'. Do not add a User-Agent header, it will be added. | |||||||
The $response is an object that is known to implement the following subset of
the methods of LWP::Response . It may in fact be an LWP::Response object,
but it may also not be if LWP is not available, so callers may only assume
the following subset of methods is available:
is_error() will return
true, code() will return a valid HTTP status code
as specified in RFC 2616 and RFC 2518, and message() will return the
message that was received from
the server. In the event of a client-side error (e.g. an unparseable URL)
then is_error() will return true and message() will return an explanatory
message. code() will return 400 (BAD REQUEST).
Note: Callers can easily check the availability of other HTTP::Response methods
as follows:
my $response = TWiki::Func::getExternalResource($url); if (!$response->is_error() && $response->isa('HTTP::Response')) { | ||||||||
Changed: | ||||||||
< < | ... other methods of HTTP::Response may be called | |||||||
> > | $text = $response->content(); | |||||||
Added: | ||||||||
> > | # ... other methods of HTTP::Response may be called | |||||||
} else { | ||||||||
Changed: | ||||||||
< < | ... only the methods listed above may be called | |||||||
> > | # ... only the methods listed above may be called | |||||||
}
setMailHandler( \&fn )
ObjectMethod sendEmail ($text,$retries) -> $error
|