Connects to HTTP resources
var h = new Myna.HttpConnection({
url:"http://www.google.com/search?q=myna+javascript",
method:"GET",
parameters:{
um:"1", //this looks in google groups instead of web search
},
})
try {
h.connect();
Myna.dump(h.getStatusCode(),"Status")
Myna.print(Myna.dump(h.responseHeaders,"headers"))
Myna.print(h.url)
Myna.print(h.getResponseText())
} catch(e){
Myna.print(Myna.formatError(e) + Myna.dump(h))
}| Myna. HttpConnection | Connects to HTTP resources |
| Functions and Properties | |
| Myna. HttpConnection | Constructor function for HttpConnection class |
| responseHeaders | object containing the response headers. |
| connect | connects to HTTP resource specified in constructor |
| getResponseText | returns http response body as text |
| getResponseXml | returns http response body as an E4X XML object |
| getResponseData | returns http response body as a byte array |
| getResponseStream | returns http response body as a stream |
| getStatusCode | returns http response status code |
Myna.HttpConnection = function( options )
Constructor function for HttpConnection class
| options | Object that describes the options for this connection. See below. Options: |
| url | URL to connect to. The query string can be appended. Example: http://www.google.com/search?q=myna+javascript |
| method | Optional default “GET” http method to use, one of GET,POST,PUT,DELETE |
| parameters | Optional default null Object representing parameters to pass to the connection. These are handled diffrently depending on method: |
| headers | Optional default null Object representing headers to send with this request |
| content | Optional default null For POST and PUT types, this is the content to send in the body of the request. Currently, this is expected to be a UTF-8 String. |
| contentType | Optional default “text/plain” content type of posted content |
| username | Optional default null username to send in a “Basic” auth header |
| password | Optional default null password to send in a “Basic” auth header |
| timeout | Optional, default null If specified, this is the amount of time in milliseconds to wait for a connection, or between data chunks. If null then timeouts are disabled. If a timeout occurs then a java.net.SocketTimeoutException or org.apache.commons.httpclient.ConnectTimeoutException is thrown |
Reference to HttpConnection instance
Myna.HttpConnection.prototype.connect=function( timeout )
connects to HTTP resource specified in constructor
returns this connection object
Myna.HttpConnection.prototype.getResponseText=function()
returns http response body as text
Myna.HttpConnection.prototype.getResponseXml=function()
returns http response body as an E4X XML object
Myna.HttpConnection.prototype.getResponseData=function()
returns http response body as a byte array
Constructor function for HttpConnection class
Myna.HttpConnection = function( options )
connects to HTTP resource specified in constructor
Myna.HttpConnection.prototype.connect=function( timeout )
returns http response body as text
Myna.HttpConnection.prototype.getResponseText=function()
returns http response body as an E4X XML object
Myna.HttpConnection.prototype.getResponseXml=function()
returns http response body as a byte array
Myna.HttpConnection.prototype.getResponseData=function()
returns http response body as a stream
Myna.HttpConnection.prototype.getResponseStream=function()
returns http response status code
Myna.HttpConnection.prototype.getStatusCode=function()