Create a named http client (like a web browser with session binding) usable todo multiple request/posts in same server session. |
|
Parameters http_clientname |
|
Sample
plugins.http.createHttpClient('mybrowser');
var pageData = plugins.http.getPageData('http://www.cnn.com','mybrowser','username','mypassword');
|
|
|
|
|
Delete a named http client. |
|
Parameters http_clientname |
|
Sample
plugins.http.deleteHttpClient('mybrowser');
|
|
|
|
|
Get cookie object from the specified client. |
|
Parameters clientName
cookieName |
|
Sample
var cookie = plugins.http.getHttpClientCookie('clientName', 'JSESSIONID');
if (cookie != null)
{
// do something
}
else
plugins.http.setHttpClientCookie('clientName', 'JSESSIONID', 'abc', 'localhost', '/', -1, false)
|
|
|
|
|
Returns a Cookie array with all the cookies set on the specified client. |
|
Sample
var cookies = plugins.http.getHttpClientCookies('clientName')
|
|
|
|
|
Get the charset of the last page received with getPageData(...) |
|
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');
|
|
|
|
|
Get media (binary data) such as images in a variable. It also supports gzip-ed content. |
|
Parameters url
[http_clientname] |
|
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');
|
|
|
|
|
(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] |
|
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');
|
|
|
|
|
Get poster object to do http (file) posts. If posting files, it will post multipart! |
|
Parameters url
[http_clientname] |
|
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()
|
|
|
|
|
(clientName, url, fileName, filePath, [username], [password]) |
|
|
Put a file at the specified URL. |
|
Parameters clientName
url
fileName
filePath
[username]
[password] |
|
Sample
var fileAdded = plugins.http.put('clientName', 'http://www.abc.com/put_stuff.jsp', 'manual.doc', 'c:/temp/manual_01a.doc', 'user', 'password')
|
|
|
|
|
setClientProxyUserNamePassword |
|
setClientProxyUserNamePassword |
|
|
Set the proxy username and password. Used for named http clients ( else use implicit java data). |
|
Parameters username
password |
|
Sample
plugins.http.setClientProxyUserNamePassword('my_proxy_username','my_proxy_password');
|
|
|
|
|
(clientName, cookieName, cookieValue, [domain], [path], [maxAge], [secure]) |
|
|
Add cookie to the specified client. |
|
Parameters clientName
cookieName
cookieValue
[domain]
[path]
[maxAge]
[secure] |
|
Sample
var cookieSet = plugins.http.setHttpClientCookie('clientName', 'JSESSIONID', 'abc', 'localhost', '/', -1, false)
if (cookieSet)
{
//do something
}
|
|
|
|
|
|