Section: User Contributed Perl Documentation (3pm)
package LWP::Protocol::foo; require LWP::Protocol; @ISA=qw(LWP::Protocol);
This class is used a the base class for all protocol implementations supported by the LWP library.When creating an instance of this class using
"LWP::Protocol::create($url)", and you get an initialized subclass appropriate for that access method. In other words, the LWP::Protocol::create() function calls the constructor for one of its subclasses.
All derived LWP::Protocol classes need to override the request() method which is used to service a request. The overridden method can make use of the collect() function to collect together chunks of data as it is received.
The following methods and functions are provided:
$response = $protocol->request($request, $proxy, undef); $response = $protocol->request($request, $proxy, '/tmp/sss'); $response = $protocol->request($request, $proxy, \&callback, 1024);
Dispatches a request over the protocol, and returns a response object. This method needs to be overridden in subclasses. Refer to LWP::UserAgent for description of the arguments.
$argis undefined, then the content is stored within the
$argis a simple scalar, then
$argis interpreted as a file name and the content is written to this file. If
$argis a reference to a routine, then content is passed to this routine.
$collectoris a routine that will be called and which is responsible for returning pieces (as ref to scalar) of the content to process. The
$collectorsignals EOF by returning a reference to an empty string. The return value from collect() is the
$responseobject reference. Note: We will only use the callback or file argument if
$response->is_success(). This avoids sending content data for redirects and authentication responses to the callback which would be confusing.
$content. This will invoke collect() with a collector callback that returns a reference to
$contentthe first time and an empty string the next.:
Copyright 1995-2001 Gisle Aas.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Tutoriais de Tecnologia Web