NAME

cs::Tk::FetchURL - fetch a URL asynchronously


SYNOPSIS

use cs::Tk::FetchURL;


DESCRIPTION

This module implements a module for dealing with URLs.


OBJECT CREATION

new(widget,url,notify,how,info)

Create a new cs::Tk::FetchURL object to retrieve a URL from the web proxy.

widget is a Tk widget (we use Tk's scheduler>.

url is an absolute URL text string or a cs::URL object.

notify is a subroutine reference to call when various parts of the HTTP transaction take place. It is passed two arguments: this cs::Tk::FetchURL object and a state string, one of RESPONSE, HEADER, FINAL or ABORT indicating that the HTTP response, HTTP header and complete HTTP object are available respectively. ABORT is passed if the transfer is terminated abnormally via the Abort method below.

how specifies when notify is called: FINAL means only when the entire object has been fetched, STEPPED means to call notify on each of the RESPONSE, HEADER and FINAL stages. If omitted, how defaults to FINAL.

info is an optional arbitrary value for passing any needed state to notify; it is stored as the INFO field of the object.


OBJECT METHODS

Abort(ok)

Cancel the transfer associated with this object. ok is an optional happiness flag; it defaults to false. If false, notify will be called with the state string ABORT.

SetPathname(pathname)

Specify where to store the data component of the object. Must be called before the Request method.

Request(headers,method,version)

Initiate the fetch from the proxy. headers is an optional cs::RFC822 object containing headers to accompany the request. method is an optional specification of the request type, one of GET or POST. version is an optional HTTP version level to claim, defaulting to 1.0.

Response()

Return an array containing the RCODE and RTEXT of the HTTP response, or an empty array if the response is not yet available. Of use to the notify routine.

ResponseHeaders()

Return an cs::RFC822 object with the response headers, or undef if the response is not yet available. Of use to the notify routine.

ResponseSinkPath()

Return the pathname of the temporary file into which the retrieved object body has been placed. Of use to the notify routine.


CAVEATS

This is an asynchronous interface. Unless you return control to Tk::MainLoop nothing will happen as the I/O is all done by callbacks.


ENVIRONMENT

WEBPROXY specified the location of the web proxy in the form proxyhost:port. port must be numeric.


SEE ALSO

Tk, the cs::URL manpage, the cs::HTTP manpage, the cs::RFC822 manpage


AUTHOR

Cameron Simpson <cs@zip.com.au>