DO NOT EDIT THE CONTENT OF THIS PAGE DIRECTLY, UNLESS YOU KNOW WHAT YOU'RE DOING.		THE STRUCTURE OF THE CONTENT IS VITAL IN BEING ABLE TO EXTRACT CHANGES FROM THE PAGE AND MERGE THEM BACK INTO SERVOY SOURCE


Return Types
Cookie
Poster

Method Summery
void
#createHttpClient(http_clientname)
Create a named http client (like a web browser with session binding) usable todo multiple request/posts in same server session.
void
#deleteHttpClient(http_clientname)
Delete a named http client.
Cookie
#getHttpClientCookie(clientName, cookieName)
Get cookie object from the specified client.
Cookie[]
#getHttpClientCookies(clientName)
Returns a Cookie array with all the cookies set on the specified client.
String
#getLastPageCharset()
Get the charset of the last page received with getPageData(.
byte[]
#getMediaData(url, [http_clientname])
Get media (binary data) such as images in a variable.
String
#getPageData(url, [http_clientname], [username], [password])
Get all page html in a variable (authentication only works with http client usage).
Poster
#getPoster(url, [http_clientname])
Get poster object to do http (file) posts.
Boolean
#put(clientName, url, fileName, filePath, [username], [password])
Put a file at the specified URL.
void
#setClientProxyUserNamePassword(username, password)
Set the proxy username and password.
Boolean
#setHttpClientCookie(clientName, cookieName, cookieValue, [domain], [path], [maxAge], [secure])
Add cookie to the specified client.

Method Details
createHttpClient
void
createHttpClient
(http_clientname)
Create a named http client (like a web browser with session binding) usable todo multiple request/posts in same server session.
Parameters
http_clientname
Returns
void
Sample
plugins.http.createHttpClient('mybrowser');
var pageData = plugins.http.getPageData('http://www.cnn.com','mybrowser','username','mypassword');

deleteHttpClient
void
deleteHttpClient
(http_clientname)
Delete a named http client.
Parameters
http_clientname
Returns
void
Sample
plugins.http.deleteHttpClient('mybrowser');

getHttpClientCookie
Cookie
getHttpClientCookie
(clientName, cookieName)
Get cookie object from the specified client.
Parameters
clientName
cookieName
Returns
Cookie
Sample
var cookie = plugins.http.getHttpClientCookie('clientName', 'JSESSIONID');
if (cookie != null)
{
	// do something
}
else
	plugins.http.setHttpClientCookie('clientName', 'JSESSIONID', 'abc', 'localhost', '/', -1, false)

getHttpClientCookies
Cookie[]
getHttpClientCookies
(clientName)
Returns a Cookie array with all the cookies set on the specified client.
Parameters
clientName
Returns
Cookie[]
Sample
var cookies = plugins.http.getHttpClientCookies('clientName')

getLastPageCharset
String
getLastPageCharset
()
Get the charset of the last page received with getPageData(...)
Returns
String
Sample
var a = plugins.http.getPageData('http://www.google.com.hk');
var charset = plugins.http.getLastPageCharset();
var success = plugins.file.writeTXTFile('someFilePath', a, charset);
if (!success) plugins.dialogs.showWarningDialog('Warning', 'Could not write file', 'OK');

getMediaData
byte[]
getMediaData
(url, [http_clientname])
Get media (binary data) such as images in a variable. It also supports gzip-ed content.
Parameters
url
[http_clientname]
Returns
byte[]
Sample
var image_byte_array = plugins.http.getMediaData('http://www.cnn.com/cnn.gif');
var image_byte_array2 = plugins.http.getMediaData('http://www.cnn.com/cnn.gif', 'clientName');

getPageData
String
getPageData
(url, [http_clientname], [username], [password])
Get all page html in a variable (authentication only works with http client usage). If name is provided a http client will be created/used.
Parameters
url
[http_clientname]
[username]
[password]
Returns
String
Sample
// get data using a default connection
var pageData = plugins.http.getPageData('http://www.cnn.com');
// create an http client and use it to get the data
var pageData = plugins.http.getPageData('http://www.cnn.com','myclient');

getPoster
Poster
getPoster
(url, [http_clientname])
Get poster object to do http (file) posts. If posting files, it will post multipart!
Parameters
url
[http_clientname]
Returns
Poster
Sample
var poster = plugins.http.getPoster('http://www.abc.com/apply_form.jsp');
var didAddParam = poster.addParameter('myParamName','myValue');
var didAddFile = poster.addFile('myFileParamName','manual.doc','c:/temp/manual_01a.doc');
var httpCode = poster.doPost('username','mypassword'); //httpCode 200 is ok
//var httpCode = poster.doPost('username','mypassword'); //use if authentication is needed
var pageData = poster.getPageData()

put
Boolean
put
(clientName, url, fileName, filePath, [username], [password])
Put a file at the specified URL.
Parameters
clientName
url
fileName
filePath
[username]
[password]
Returns
Boolean
Sample
var fileAdded = plugins.http.put('clientName', 'http://www.abc.com/put_stuff.jsp', 'manual.doc', 'c:/temp/manual_01a.doc', 'user', 'password')

setClientProxyUserNamePassword
void
setClientProxyUserNamePassword
(username, password)
Set the proxy username and password. Used for named http clients ( else use implicit java data).
Parameters
username
password
Returns
void
Sample
plugins.http.setClientProxyUserNamePassword('my_proxy_username','my_proxy_password');

setHttpClientCookie
Boolean
setHttpClientCookie
(clientName, cookieName, cookieValue, [domain], [path], [maxAge], [secure])
Add cookie to the specified client.
Parameters
clientName
cookieName
cookieValue
[domain]
[path]
[maxAge]
[secure]
Returns
Boolean
Sample
var cookieSet = plugins.http.setHttpClientCookie('clientName', 'JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
	//do something
}