Object | +--helma.Http
This class provides functionality to programatically issue
an Http request based on java.net.HttpUrlConnection.
By default the request will use method GET.
Defined in Http.js
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |
| Constructor Summary | |
helma.Http()
Creates a new instance of helma.Http |
|
| Methods Summary | |
Boolean
|
getBinaryMode()
Returns the currently defined binary mode of this client |
String
|
getCookie(<String> name)
Returns the value of the cookie with the given name |
Object
|
getCookies()
Returns all cookies set for this client |
Object
|
getFollowRedirects()
Returns true if the client follows redirects |
String
|
getHeader(<String> name)
Returns the value of the request header field with the given name |
String
|
getMethod()
Returns the currently defined request method. |
String
|
getProxy()
Returns the proxy in host:port format
|
Number
|
getReadTimeout()
Returns the read timeout (the maximum time a request may take after the connection has been successfully established). |
Number
|
getTimeout()
Returns the connection timeout |
Object
|
getUrl(<String> url, <Date|String> opt)
Executes a http request |
String
|
getUserAgent()
Returns the value of the HTTP "User-Agent" header field |
void
|
setBinaryMode(<Boolean> mode)
Switches content text encoding on or off. |
void
|
setContent(<String|Object> stringOrObject)
Sets the content to send to the remote server within this request. |
void
|
setCookie(<String> name, <String> value)
Adds a cookie with the name and value passed as arguments to the list of cookies to send to the remote server. |
void
|
setCredentials(<String> username, <String> password)
Sets the credentials for basic http authentication |
void
|
setFollowRedirects(<Boolean> value)
Enables or disables following redirects |
void
|
setHeader(<String> name, <String> value)
Sets a single HTTP request header field |
void
|
setMethod(<String> m)
Sets the request method to use. |
void
|
setProxy(<String> proxyString)
Sets the proxy host and port for later use. |
Object
|
setReadTimeout(<Number> timeout)
Sets the read timeout (the maximum time a request may take after the connection has been successfully established) to the amount of milliseconds passed as argument. |
void
|
setTimeout(<Number> timeout)
Sets the connection timeout to the amount of milliseconds passed as argument |
void
|
setUserAgent(<String> agent)
Sets the HTTP "User-Agent" header field to the string passed as argument |
<static> java.net.URL
|
evalUrl(<String> url)
Evaluates the url passed as argument. |
<static> Boolean
|
isAuthorized(<String> name, <String> pwd)
Static helper method to check if a request issued agains a Helma application is authorized or not. |
| Constructor Detail |
helma.Http()
| Method Detail |
Boolean getBinaryMode()
String getCookie(<String> name)
name - The name of the cookie
Object getCookies()
Object getFollowRedirects()
String getHeader(<String> name)
name - The name of the request header field
String getMethod()
String getProxy()
host:port formatNumber getReadTimeout()
Number getTimeout()
Object getUrl(<String> url, <Date|String> opt)
url - The url to request
opt - If this argument is a string, it is used as value for the "If-None-Match" request header field. If it is a Date instance it is used as "IfModifiedSince" condition for this request.
url: (String) The Url of the requestlocation: (String) The value of the location header fieldcode: (Number) The HTTP response codemessage: (String) An optional HTTP response messagelength: (Number) The content length of the responsetype: (String) The mimetype of the responseencoding: (String) An optional encoding to use with the responselastModified: (String) The value of the lastModified response header fieldeTag: (String) The eTag as received from the remote servercookie: (helma.Http.Cookie) An object containing the cookie parameters, if the remote server has set the "Set-Cookie" header fieldcontent: (String|ByteArray) The response received from the server. Can be either a string or a byte array (see #setBinaryMode)String getUserAgent()
void setBinaryMode(<Boolean> mode)
mode - If true binary mode is activated
void setContent(<String|Object> stringOrObject)
stringOrObject - The content of the request, which can be either a string or an object. In the latter case all properties and their values are concatenated into a single string.
void setCookie(<String> name, <String> value)
name - The name of the cookie
value - The value of the cookie
void setCredentials(<String> username, <String> password)
username - The username
password - The password
void setFollowRedirects(<Boolean> value)
value - If false this client won't follow redirects (the default is to follow them)
void setHeader(<String> name, <String> value)
name - The name of the header field
value - The value of the header field
void setMethod(<String> m)
m - The method to use (GET, POST ...)
void setProxy(<String> proxyString)
host:port format (eg. "proxy.example.com:3128").proxyString - The proxy to use for this request
Object setReadTimeout(<Number> timeout)
timeout - The read timeout in milliseconds
void setTimeout(<Number> timeout)
timeout - The connection timeout in milliseconds
void setUserAgent(<String> agent)
agent - The string to use as value of the "User-Agent" header field (defaults to "Helma Http Client")
<static> java.net.URL evalUrl(<String> url)
url - The url or uri string to evaluate
<static> Boolean isAuthorized(<String> name, <String> pwd)
name - The username to check req.username against
pwd - The password to check req.password against
| SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods |