Detailed reference of prototypes, properties and methods available in the
Javascript environment of your Helma web applications.

Fields and methods of the helma.Http class.
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Http.js')
helma Http()
Creates a new instance of helma.Http
methods

- setProxy(proxyString)

- getProxy()

- setCredentials(username, password)

- setContent(stringOrObject)

- setMethod(m)

- getMethod()

- setHeader(name, value)

- getHeader(name)

- setCookie(name, value)

- getCookie(name)

- setCookies(cookies)

- getCookies()

- setTimeout(timeout)

- setReadTimeout(timeout)

- getTimeout()

- getReadTimeout()

- setFollowRedirects(value)

- getFollowRedirects()

- setUserAgent(agent)

- getUserAgent()

- setBinaryMode(mode)

- getBinaryMode()

- setMaxResponseSize(Size)

- getMaxResponseSize()

- setResponseHandler(Response)

- getResponseHandler()

- getUrl(url, opt)

- setProxy(proxyString)

- getProxy()

helma Http.Cookie(name, value)
Creates a new instance of helma.Http.Cookie
parameters

String | name | The name of the cookie
String | value | The value of the cookie

methods

- getFieldValue()

properties

- String name

- String value

- Date expires

- String path

- String domain

String helma.Http.Cookie. name
The name of the Cookie
String helma.Http.Cookie. value
The value of the Cookie
Date helma.Http.Cookie. expires
An optional date defining the lifetime of this cookie
String helma.Http.Cookie. path
An optional path where this cookie is valid
String helma.Http.Cookie. domain
An optional domain where this cookie is valid
java.text.SimpleDateFormat helma. Http.Cookie.DATEFORMAT
An instance of java.text.SimpleDateFormat used for both parsing an "expires" string into a date and vice versa
RegExp helma. Http.Cookie.PATTERN
A regular expression used for parsing cookie strings
Methods
helma.Http. setProxy(proxyString)
Sets the proxy host and port for later use. The argument must be in `host:port` format (eg. "proxy.example.com:3128").
parameters

String | proxyString | The proxy to use for this request

see

helma.Http.getProxy

helma.Http. getProxy()
Returns the proxy in `host:port` format
returns

| The proxy defined for this request

see

helma.Http.setProxy

helma.Http. setCredentials(username, password)
Sets the credentials for basic http authentication
parameters

String | username | The username
String | password | The password

helma.Http. setContent(stringOrObject)
Sets the content to send to the remote server within this request.
parameters

String, Object | 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. If a property is an array, then for each value the propertyname and value pair is added. If the name of an array property ends with "_array" then the _array part is removed.

helma.Http. setMethod(m)
Sets the request method to use.
parameters

String | m | The method to use (`GET`, `POST` ...)

see

helma.Http.getMethod

helma.Http. getMethod()
Returns the currently defined request method.
returns

| The method used

see

helma.Http.setMethod

helma.Http. setHeader(name, value)
Sets a single HTTP request header field
parameters

String | name | The name of the header field
String | value | The value of the header field

see

helma.Http.getHeader

helma.Http. getHeader(name)
Returns the value of the request header field with the given name
parameters

String | name | The name of the request header field

returns

| The value of the request header field

see

helma.Http.setHeader

helma.Http. setCookie(name, value)
Adds a cookie with the name and value passed as arguments to the list of cookies to send to the remote server.
parameters

String | name | The name of the cookie
String | value | The value of the cookie

see

helma.Http.getCookie
helma.Http.getCookies

helma.Http. getCookie(name)
Returns the value of the cookie with the given name
parameters

String | name | The name of the cookie

returns

| The value of the cookie

see

helma.Http.setCookie

helma.Http. setCookies(cookies)
Adds the cookies passed as argument to the list of cookies to send to the remote server.
parameters

Array | cookies | An array containing objects with the properties "name" (the name of the cookie) and "value" (the value of the cookie) set.

helma.Http. getCookies()
Returns all cookies set for this client
returns

| An object containing all cookies, where the property name is the name of the cookie, and the value is the cookie value

see

helma.Http.setCookie

helma.Http. setTimeout(timeout)
Sets the connection timeout to the amount of milliseconds passed as argument
parameters

Number | timeout | The connection timeout in milliseconds

see

helma.Http.getTimeout

helma.Http. setReadTimeout(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.
parameters

Number | timeout | The read timeout in milliseconds

see

helma.Http.getReadTimeout

helma.Http. getTimeout()
Returns the connection timeout
returns

| The connection timeout in milliseconds

see

helma.Http.setTimeout

helma.Http. getReadTimeout()
Returns the read timeout (the maximum time a request may take after the connection has been successfully established).
returns

| The read timeout in milliseconds

see

helma.Http.setReadTimeout

helma.Http. setFollowRedirects(value)
Enables or disables following redirects
parameters

Boolean | value | If false this client won't follow redirects (the default is to follow them)

see

helma.Http.getFollowRedirects

helma.Http. getFollowRedirects()
Returns true if the client follows redirects
returns

| True if the client follows redirects, false otherwise.

see

helma.Http.setFollowRedirects

helma.Http. setUserAgent(agent)
Sets the HTTP "User-Agent" header field to the string passed as argument
parameters

String | agent | The string to use as value of the "User-Agent" header field (defaults to "Helma Http Client")

see

helma.Http.getUserAgent

helma.Http. getUserAgent()
Returns the value of the HTTP "User-Agent" header field
returns

| The value of the field

see

helma.Http.setUserAgent

helma.Http. setBinaryMode(mode)
Switches content text encoding on or off. Depending on this the content received from the remote server will be either a string or a byte array.
parameters

Boolean | mode | If true binary mode is activated

see

helma.Http.getBinaryMode

helma.Http. getBinaryMode()
Returns the currently defined binary mode of this client
returns

| The binary mode of this client

see

helma.Http.setBinaryMode

helma.Http. setMaxResponseSize(Size)
Sets the max allowed size for the response stream
parameters

Integer | Size | in Byte

helma.Http. getMaxResponseSize()
Returns the currently set max response size
returns

| The max responsesize

see

helma.Http.setMaxResponseSize

helma.Http. setResponseHandler(Response)
Overloads the default response handler. Use this do implement your own response handling, like storing the response directly to the harddisk The handler function gets two parameter, first is the java.net.URLConnection and second is the result object. Note that custom response handler functions should check the HTTP status code before reading the response. The status code for successful requests is 200. Response bodies for requests with status codes less than 400 can be read from the connection's input stream, while response bodies with 4xx or 5xx status codes must be read using the error stream.
parameters

function | Response | handler function

helma.Http. getResponseHandler()
Get the response handler. This is the function used to read the HTTP response body.
returns

| The response handler function

helma.Http. getUrl(url, opt)
Executes a http request
parameters

String | url | The url to request
Date, String | 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.

returns

A result object containing the following properties:

- `url`: (String) The Url of the request
- `location`: (String) The value of the location header field
- `code`: (Number) The HTTP response code
- `message`: (String) An optional HTTP response message
- `length`: (Number) The content length of the response
- `type`: (String) The mimetype of the response
- `charset`: (String) The character set of the response
- `encoding`: (String) An optional encoding to use with the response
- `lastModified`: (String) The value of the lastModified response header field
- `eTag`: (String) The eTag as received from the remote server
- `cookie`: (helma.Http.Cookie) An object containing the cookie parameters, if the remote server has set the "Set-Cookie" header field
- `headers`: (java.util.Map) A map object containing the headers, access them using get("headername")
- `content`: (String|ByteArray) The response received from the server. Can be either a string or a byte array (see #setBinaryMode)

helma. Http.evalUrl(url)
Evaluates the url passed as argument.
parameters

String | url | The url or uri string to evaluate

returns

| If the argument is a valid url, this method returns a new instance of java.net.URL, otherwise it returns null.

helma.Http. setProxy(proxyString)
Sets the global http proxy setting. If no proxy definition is passed to this method, any existing proxy setting is cleared. Internally this method sets the system properties `http.proxySet`, `http.proxyHost` and `http.proxyPort`. Keep in mind that this is valid for the whole Java Virtual Machine, therefor using this method can potentially influence other running Helma applications too!
parameters

String | proxyString | A proxy definition in `host:port` format (eg. "proxy.example.com:3128");

helma.Http. getProxy()
Returns the proxy setting of the Java Virtual Machine the Helma application server is running in. If no proxy is set, this method returns boolean false.
returns

| The global proxy setting in `host:port` format (eg. "proxy.example.com:3128"), or boolean false.

helma. Http.isAuthorized(name, pwd)
Static helper method to check if a request issued agains a Helma application is authorized or not.
parameters

String | name | The username to check req.username against
String | pwd | The password to check req.password against

returns

| True if the request is authorized, false otherwise. In the latter case the current response is reset and the response code is set to "401" ("Authentication required").

helma. Http.Cookie.parse(cookieStr)
Parses the cookie string passed as argument into an instance of helma.Http
parameters

String | cookieStr | The cookie string as received from the remote server

returns

| An instance of helma.Http.Cookie containing the cookie parameters

helma.Http.Cookie. getFieldValue()
Returns this cookie in a format useable to set the HTTP header field "Cookie"
returns

| This cookie formatted as HTTP header field value

Tue, 25 Nov 2008 16:50:13 GMT.

### core framework

- global
- app (application)
- req (request)
- res (response)
- session
- path
- root
- HopObject
- User
- File
- FtpClient
- Image
- Mail
- Remote
- Xml
- DatabaseObject
- MimePart
- Skin
- Object

### optional modules

- Array extensions
- Date extensions
- Number extensions
- Object extensions
- String extensions
- HopObject extensions
- global macros
- macro filters
- JSON methods
- helma.Aspects
- helma.Chart
- helma.Color
- helma.Database
- helma.File
- helma.Ftp
- helma.Group
- helma.Html
- helma.Http
- helma.Image
- helma.Mail
- helma.Search
- helma.Skin
- helma.Ssh
- helma.Url
- helma.Zip
- jala.BitTorrent
- jala.Captcha
- jala.Date
- jala.db
- jala.DnsClient
- jala.Form
- jala.History
- jala HopObject extensions
- jala.HtmlDocument
- jala.I18n
- jala.ImageFilter
- jala.IndexManager
- jala.ListRenderer
- jala.Mp3
- jala.PodcastWriter
- jala.RemoteContent
- jala.Rss20Writer
- jala.Utilities
- jala.XmlRpcRequest
- jala.XmlWriter

### java libraries

- browse docjar