public class UserAgent
extends java.lang.Object
Constructor and Description |
---|
UserAgent() |
UserAgent(java.net.Proxy proxy) |
Modifier and Type | Method and Description |
---|---|
void |
addHeader(java.lang.String name,
java.lang.String value)
Add a header value to the header with the given name.
|
protected void |
applyRequestHeaders(java.net.HttpURLConnection connection,
Headers headerDef) |
protected void |
applyUserAgent(java.net.HttpURLConnection connection) |
protected boolean |
canHaveContent(int responseCode) |
int |
getConnectTimeout() |
java.lang.String |
getHeader(java.lang.String name)
Returns a single value (the first) of the header with the given name.
|
protected Headers |
getHeaders() |
protected Logger |
getLogger() |
java.net.Proxy |
getProxy()
Returns the user agent's proxy.
|
int |
getReadTimeout() |
java.lang.String |
getUserAgentName() |
boolean |
hasProxy() |
protected boolean |
isSupposedToHaveContent(ServerResponse response) |
protected java.net.HttpURLConnection |
openHttpConnection(java.net.URL url) |
void |
removeHeader(java.lang.String name)
Returns the header with the given name and all its associated values.
|
protected ServerResponse |
retrieveResponse(java.net.HttpURLConnection connection,
IResponseStreamHandler responseStreamHandler) |
ServerResponse |
sendRequest(ClientRequest request)
Sends a request based on the given request definition and the user agent's
own state.
|
ServerResponse |
sendRequest(ClientRequest request,
IResponseStreamHandler responseStreamHandler)
Sends a request based on the given request definition and the user agent's
own state.
|
protected void |
sendRequestBody(java.net.HttpURLConnection connection,
ClientRequest request) |
void |
setConnectTimeout(int connectTimeout) |
void |
setHeader(java.lang.String name,
java.lang.String value)
A a header with a single value.
|
void |
setProxy(java.net.Proxy proxy)
Sets the user agent's proxy.
|
void |
setReadTimeout(int readTimeout) |
void |
setUserAgentName(java.lang.String userAgentName) |
public java.net.Proxy getProxy()
public void setProxy(java.net.Proxy proxy)
public void addHeader(java.lang.String name, java.lang.String value)
public void setHeader(java.lang.String name, java.lang.String value)
public java.lang.String getHeader(java.lang.String name)
public void removeHeader(java.lang.String name)
public ServerResponse sendRequest(ClientRequest request) throws java.io.IOException
request
- The definition of the request to be sent (must not be null).java.io.IOException
- Any problem during remote communication.public ServerResponse sendRequest(ClientRequest request, IResponseStreamHandler responseStreamHandler) throws java.io.IOException
request
- The definition of the request to be sent (must not be null).responseStreamHandler
- An optional (may be null) handler for the response stream.
If provided the ServerResponse methods hasContentData(), getContentData(), getConentText(),
getContentReader() must not be used anymore!java.io.IOException
- Any problem during remote communication.public int getReadTimeout()
public void setReadTimeout(int readTimeout)
public int getConnectTimeout()
public void setConnectTimeout(int connectTimeout)
public java.lang.String getUserAgentName()
public void setUserAgentName(java.lang.String userAgentName)
public boolean hasProxy()
protected java.net.HttpURLConnection openHttpConnection(java.net.URL url) throws java.io.IOException
java.io.IOException
protected void sendRequestBody(java.net.HttpURLConnection connection, ClientRequest request) throws java.io.IOException
java.io.IOException
protected void applyUserAgent(java.net.HttpURLConnection connection)
protected void applyRequestHeaders(java.net.HttpURLConnection connection, Headers headerDef)
protected ServerResponse retrieveResponse(java.net.HttpURLConnection connection, IResponseStreamHandler responseStreamHandler) throws java.io.IOException
java.io.IOException
protected boolean isSupposedToHaveContent(ServerResponse response)
protected boolean canHaveContent(int responseCode)
protected Headers getHeaders()
protected Logger getLogger()