urllib
Module providing HTTP Post and Get requests.Requests can be sent synchronously and asynchronously.
exceptions
- NoHTTPRequestObject
Thrown if no request object could be instanciated. - RequestOpenFailed
Thrown if an HTTP request could not be opened. - SendFailed
Thrown if a request could not be sent to the server.
methods
- sendRequest(type, url, user=null, pass=null, data="", headers=[], callback=null)
Sends a request to a server using synchronous or async. connection.
To explain the way the optional arguments work I will give examples:
- simple:
sendRequest("get", "url")
sendRequest("post", "url", "data")
- with headers:
sendRequest("get", "url", [["headername","value"]])
sendRequest("post", "url", "data", [["headername","value"]])
- with user information:
sendRequest("get", "url", "user", "pass")
sendRequest("post", "url", "user", "pass", "data")
- with headers and user information:
sendRequest("get", "url", "user", "pass", [["headername","value"]])
sendRequest("post", "url", "user", "pass", "data", [["headername","value"]])
parameters:- type The type of request(GET, POST, ...).
- url The URL of for the request.
- user The username used for HTTP authentication.
- pass The password used for HTTP authentication.
- data The data to send.
- headers An array with elments of the form [["HeaderName", "HeaderValue"],...].
- callback An AsyncCallback function to be called when the operation is complete.
If specified then an async. connection is used.
return value:
An HTTPRequest object. - simple:
- getURL(url, user, pass, headers=null, callback=null)
Shorthand for a GET request.
It calls sendRequest with "GET" as first argument.
See the sendRequest method for more information.
parameters:- url The URL of for the request.
- user The username used for HTTP authentication.
- pass The password used for HTTP authentication.
- headers An array with elments of the form [["HeaderName", "HeaderValue"],...].
- callback An AsyncCallback function to be called when the operation is complete.
If specified then an async. connection is used.
return value:
An HTTPRequest object. - postURL(url, user, pass, data, headers=null, callback=null)
Shorthand for a POST request.
It calls sendRequest with "POST" as first argument.
See the sendRequest method for more information.
parameters:- url The URL of for the request.
- user The username used for HTTP authentication.
- pass The password used for HTTP authentication.
- data The data to send.
- headers An array with elments of the form [["HeaderName", "HeaderValue"],...].
- callback An AsyncCallback function to be called when the operation is complete.
If specified then an async. connection is used.
return value:
An HTTPRequest object.
interfaces
- AsyncCallback(request)
Called upon completion of a request.
parmerters:
- request HTTPRequest object.
- HTTPRequest
See Mozilla's XMLHTTPRequest or MS's XMLHTTP.
requirements
Synchronous requests only work and have been testet in IE, Mozilla and Motjuvie SVG viewer.All applications supporting the creation of the MS XMLHTTP ActiveX object or provide the same interface as Mozilla for the creation of the XMLHTTPRequest object should also work.
Asynchronous requests work and have been tested with the above applications and with Adobe SVG Viewer's script engine.
All applications which provide a getURL and postURL like Adobe's SVG Viewer should also work.
Security restrictions of the browsers have to be taken into account.
E.g. Mozilla can not make requests to a domain different from the domain the webpage came from.