This plugin provides a high-level interface for accessing
World-Wide Web resources. The name is somewhat misleading because the
plugin can access http, ftp, and gopher URLs. To use the plugin, a KP
must first lookup a connector for an HTTPAPI.Factory object and use it
to create a new HTTPAPI.Requester.
This module defines the following object types:
- The Factory generates new Requester objects. The plugin
registers this object with the name 'http'.
- The Requester loads Web resources.
Instances of the Factory object have the following method:
- Factory() : HTTPAPI.Requester
- Returns a new Requester object that can be used to load
URLs. A FactoryFailed exception may be raised if a system error occurs.
Instances of the Requester object have the following methods:
- Get(url : string) : FileAPI.File
- Requests the resource addressed by url. Returns the
resource as a file-like objects or raises a FileAPI.FileIOError
exception if the request resource could not be loaded.
- GetWithInfo(url : string) : list of list of string, FileAPI.File
- Requests the resource address by url. Returns the
headers from the HTTP response and the resource body. The headers are
represented as a list of key-value pairs, where the pairs are lists
with two elements. (For ftp and gopher responses, the list of headers
will be empty.)
In an error occurs, a FileAPI.FileIOError will be raised.
- ASYNCHRONOUS Close()
- Destroys the Requester object. If you don't call this
method, the system will not be able to reclaim the resources used by
This module defines the following exceptions:
- The Factory could not create a new HTTP Requester because
of a system error.
IF the KP fails to Close() the Requester
instance it has created, it will cause the child process to hang
around forever, since ILU doesn't do garbage collection.
HTTP error codes returned by the server are translated into
FileAPI.FileIOError exceptions. The problem with this is that the KP
has to parse the error message string to get the numeric error code.
Moreover, the headers that came along with the error code are lost.
All this makes using the GetWithInfo interface less pleasant than
using urllib.urlopen() directly.
The KP may be denied access by the plugin for a particular URL
based on the HTTP Plugin's access.conf