Difference: TWikiNetDotPm (3 vs. 4)

Revision 42012-10-07 - TWikiContributor

Line: 10 to 10
 
Changed:
<
<

getExternalResource( $url ) -> $response

>
>

getExternalResource( $url, @headers ) -> $response

  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.

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,
Line: 49 to 52
 
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(); # ... 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
 }
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 1999-2020 by the contributing authors. All material on this collaboration platform is the property of the contributing authors. <br /> Ideas, requests, problems regarding lt;nopgt;TWiki? lt;a href='mailto:twiki-admin@kcl.ac.uk?subject=TWiki%20Feedback%20on%20TWiki.TWikiNetDotPm'gt;Send feedbacklt;/agt; <br /> Note: Please contribute updates to this topic on TWiki.org at <a href="http://twiki.org/cgi-bin/view/TWiki/TWikiNetDotPm" target="twiki.org">TWiki:TWiki.TWikiNetDotPm</a>.