HttpClient
Overview
A wrapper for Apache HttpClient
for executing requests like GET, POST, PUT, and more, with support for cookies, proxies, and timeouts.
Features
The client facilitates various HTTP requests (e.g., GET, POST, DELETE) and supports configuration options like cookies, proxy servers, and timeouts. It enables both synchronous and asynchronous communication, offering flexibility for different use cases.
For configuration details, see the Http client configuration section.
Methods Summarized
void
releases all resources that this client has, should be called after usage.
Creates a new delete request (a request to delete a resource on server).
Creates a new get request (retrieves whatever information is stored on specified url).
Creates a new head request (similar to get request, must not contain body content).
Creates a new options request (a request for information about communication options).
Creates a new patch request (used for granular updates).
Create a new post request ( Origin server should accept/process the submitted data.
Creates a new put request (similar to post request, contains information to be submitted).
Creates a new trace request (debug request, server will just echo back).
Get a cookie by name.
Get all cookies from this client.
void
Set proxy credentials.
void
Set proxy server.
Add cookie to the this client.
Add cookie to the this client.
Add cookie to the this client.
Add cookie to the this client.
Add cookie to the this client.
void
Sets a timeout in milliseconds for retrieving of data (when 0 there is no timeout).
Methods Detailed
close()
releases all resources that this client has, should be called after usage.
Returns: void
createDeleteRequest(url)
Creates a new delete request (a request to delete a resource on server).
Parameters
String url ;
Returns: DeleteRequest
Sample
createGetRequest(url)
Creates a new get request (retrieves whatever information is stored on specified url). If this url is a https ssl encrypted url which certificates are not in the java certificate store. (Like a self signed certificate or a none existing root certificate) Then for a smart client a dialog will be given, to give the user the ability to accept this certificate for the next time. For a Web or Headless client the system administrator does have to add that certificate (chain) to the java install on the server. See https://wiki.servoy.com/display/tutorials/Import+a+%28Root%29+certificate+in+the+java+cacerts+file
Parameters
String url ;
Returns: GetRequest
Sample
createHeadRequest(url)
Creates a new head request (similar to get request, must not contain body content).
Parameters
String url ;
Returns: HeadRequest
Sample
createOptionsRequest(url)
Creates a new options request (a request for information about communication options).
Parameters
String url ;
Returns: OptionsRequest
Sample
createPatchRequest(url)
Creates a new patch request (used for granular updates).
Parameters
String url ;
Returns: PatchRequest
Sample
createPostRequest(url)
Create a new post request ( Origin server should accept/process the submitted data.) If this url is a https ssl encrypted url which certificates are not in the java certificate store. (Like a self signed certificate or a none existing root certificate) Then for a smart client a dialog will be given, to give the user the ability to accept this certificate for the next time. For a Web or Headless client the system administrator does have to add that certificate (chain) to the java install on the server. See https://wiki.servoy.com/display/tutorials/Import+a+%28Root%29+certificate+in+the+java+cacerts+file
Parameters
String url ;
Returns: PostRequest
Sample
createPutRequest(url)
Creates a new put request (similar to post request, contains information to be submitted).
Parameters
String url ;
Returns: PutRequest
Sample
createTraceRequest(url)
Creates a new trace request (debug request, server will just echo back).
Parameters
String url ;
Returns: TraceRequest
Sample
getCookie(cookieName)
Get a cookie by name.
Parameters
String cookieName ;
Returns: Cookie
Sample
getCookies()
Get all cookies from this client.
Returns: Array
Sample
setClientProxyCredentials(userName, password)
Set proxy credentials.
Parameters
Returns: void
Sample
setClientProxyServer(hostname, port)
Set proxy server.
Parameters
String hostname - proxy host // null value will clear proxyHost settings;
Number port - proxy port //null value will clear proxyHost settings;
Returns: void
Sample
setCookie(cookieName, cookieValue)
Add cookie to the this client.
Parameters
Returns: Boolean
Sample
setCookie(cookieName, cookieValue, domain)
Add cookie to the this client.
Parameters
String cookieName the name of the cookie
String cookieValue the value of the cookie
String domain the domain
Returns: Boolean
Sample
setCookie(cookieName, cookieValue, domain, path)
Add cookie to the this client.
Parameters
String cookieName the name of the cookie
String cookieValue the value of the cookie
String domain the domain
String path the path
Returns: Boolean
Sample
setCookie(cookieName, cookieValue, domain, path, maxAge)
Add cookie to the this client.
Parameters
String cookieName the name of the cookie
String cookieValue the value of the cookie
String domain the domain
String path the path
Number maxAge maximum age of cookie
Returns: Boolean
Sample
setCookie(cookieName, cookieValue, domain, path, maxAge, secure)
Add cookie to the this client.
Parameters
String cookieName the name of the cookie
String cookieValue the value of the cookie
String domain the domain
String path the path
Number maxAge maximum age of cookie
Boolean secure true if it is a secure cookie, false otherwise
Returns: Boolean
Sample
setTimeout(msTimeout)
Sets a timeout in milliseconds for retrieving of data (when 0 there is no timeout).
Parameters
Object msTimeout ;
Returns: void
Sample
Last updated