public interface AQWebClient
The AQWebClient interface supports automatic management of cookies, including allowing the server to set cookies and automatically return them to the server when required. There are several conflicting standards for handling Cookies: the Netscape Cookie draft, RFC2109, RFC2965 and a large number of vendor specific implementations that are compliant with neither specification. To deal with this, AQWebClient provides policy driven cookie management. The following cookie specifications are supported:
setBrowserCookiePolicy()
setRFC2109CookiePolicy()
setRFC2965CookiePolicy()
setNetscapeCookiePolicy()
setIgnoreCookiePolicy()
An object implementing this interface is available via aqua.net.newWebClient() alias.
To send a request to an HTTP server, application needs to create an AQWebRequest
object first,
as shown below:
var client = aqua.net.newWebClient(); var url = "http://www.aquafold.com/download/"; var request = client.newWebRequest(url);
Once request object is created and properly configured, it can be submitted to the web server via one the following methods:
Please seeAQWebRequest
for more information about configuration of a request object.
An response object, AQWebResponse
, is returned to the application if request
is successfully processed. Application then can use supported APIs to retrieve information
from the returned response object. Please see AQWebResponse
for more information.
Modifier and Type | Method and Description |
---|---|
void |
clearCookies()
Clears all cookies.
|
void |
closeConnection()
Closes all of server connections tracked by this client and releases all of allocated system resources.
|
int |
getConnectionTimeout()
Returns the timeout, in milliseconds, used to establish a connection between this object and an HTTP server.
|
int |
getMethodRetryCount()
Returns the number of times a request will be retried due to network error.
|
int |
getSocketTimeout()
Returns the socket timeout in milliseconds which is the timeout for waiting for data.
|
AQWebRequest |
newWebRequest(String url)
Creates a new web request.
|
void |
setBrowserCookiePolicy()
Uses Browser Compatibility policy for cookie management.
|
void |
setConnectionTimeout(int timeout)
Sets the timeout, in milliseconds, used to establish a connection between this object and an HTTP server.
|
void |
setIgnoreCookiePolicy()
Indicates to neither accept nor send cookies.
|
void |
setMethodRetryCount(int count)
Sets the number of times a request will be retried due to network error.
|
void |
setNetscapeCookiePolicy()
Uses Netscape Draft policy for cookie management.
|
void |
setProxySettings(String host,
int port,
String realm,
Object username,
Object password,
String userAgent)
Sets the proxy server via which requests and responses to be sent and received.
|
void |
setRFC2109CookiePolicy()
Uses RFC2109 policy for cookie management.
|
void |
setRFC2965CookiePolicy()
Uses RFC2965 policy for cookie management.
|
void |
setSocketTimeout(int timeout)
Sets the socket timeout in milliseconds which is the timeout for waiting for data.
|
AQWebResponse |
submitGetRequest(AQWebRequest request)
Sends an HTTP Get request to a server per the URL
defined in the specified
request . |
AQWebResponse |
submitPostRequest(AQWebRequest request)
Sends an HTTP Post request to a server per the URL
defined in the specified
request . |
AQWebRequest newWebRequest(String url) throws Exception
url
- the string to parse as a URLException
- if the string is a malformed URLAQWebResponse submitGetRequest(AQWebRequest request) throws Exception
request
.request
- a web request with a valid URL definedException
- if request
contains invalid data or
failed to communicate with HTTP server due to network errorAQWebResponse submitPostRequest(AQWebRequest request) throws Exception
request
.request
- a web request with a valid URL definedException
- if request
contains invalid data or
failed to communicate with HTTP server due to network errorvoid setProxySettings(String host, int port, String realm, Object username, Object password, String userAgent)
host
- the name of the host where the proxy server is running.port
- the port number from which the proxy server accepts requests.realm
- the realm to which the proxy server to apply the authentication;
may be set to null if authentication is applicable to any realm.username
- the name of the account used for authentication purpose;
may be set to null if authentication is not required.password
- the password of the account used for authentication purpose;
may be set to null if authentication is not required.userAgent
- the string to be stored in the User-Agent
header;
may be set to null.void clearCookies()
void closeConnection()
int getConnectionTimeout()
void setConnectionTimeout(int timeout)
timeout
- timeout in millisecondsint getSocketTimeout()
void setSocketTimeout(int timeout)
timeout
- timeout in millisecondsvoid setBrowserCookiePolicy()
void setRFC2109CookiePolicy()
void setRFC2965CookiePolicy()
void setNetscapeCookiePolicy()
void setIgnoreCookiePolicy()
int getMethodRetryCount()
void setMethodRetryCount(int count)
count
- the number of times a request will be retried
Copyright © 2017 AquaFold, Inc. All Rights Reserved. Use is subject to license terms.