public class HttpBrowser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected boolean |
catchTransportExceptions |
protected HttpMultiMap<Cookie> |
cookies |
protected HeadersMultiMap |
defaultHeaders |
protected long |
elapsedTime |
protected HttpConnectionProvider |
httpConnectionProvider |
protected HttpRequest |
httpRequest |
protected HttpResponse |
httpResponse |
protected boolean |
keepAlive |
Constructor and Description |
---|
HttpBrowser() |
Modifier and Type | Method and Description |
---|---|
protected HttpResponse |
_sendRequest(HttpRequest httpRequest,
HttpResponse previouseResponse)
Opens connection and sends a response.
|
protected void |
addCookies(HttpRequest httpRequest)
Add cookies to the request.
|
protected void |
addDefaultHeaders(HttpRequest httpRequest)
Add default headers to the request.
|
void |
clearCookies()
Deletes all cookies.
|
void |
close()
Closes browser explicitly, needed when keep-alive connection is used.
|
long |
getElapsedTime()
Returns elapsed time of last
sendRequest(HttpRequest) in milliseconds. |
HttpRequest |
getHttpRequest()
Returns last used request.
|
HttpResponse |
getHttpResponse()
Returns last received
HTTP response object. |
java.lang.String |
getPage()
Returns last response HTML page.
|
boolean |
isKeepAlive()
Returns
true if keep alive is used. |
protected void |
readCookies(HttpResponse httpResponse)
Reads cookies from response and adds to cookies list.
|
HttpResponse |
sendRequest(HttpRequest httpRequest)
Sends new request as a browser.
|
HttpBrowser |
setCatchTransportExceptions(boolean catchTransportExceptions)
Defines if transport exceptions should be thrown.
|
HttpBrowser |
setDefaultHeader(java.lang.String name,
java.lang.String value)
Adds default header to all requests.
|
HttpBrowser |
setHttpConnectionProvider(HttpConnectionProvider httpConnectionProvider)
Defines
HttpConnectionProvider for this browser session. |
HttpBrowser |
setKeepAlive(boolean keepAlive)
Defines that persistent HTTP connection should be used.
|
HttpBrowser |
setProxyInfo(ProxyInfo proxyInfo)
Defines proxy for a browser.
|
protected HttpConnectionProvider httpConnectionProvider
protected HttpRequest httpRequest
protected HttpResponse httpResponse
protected HttpMultiMap<Cookie> cookies
protected HeadersMultiMap defaultHeaders
protected boolean keepAlive
protected long elapsedTime
protected boolean catchTransportExceptions
public boolean isKeepAlive()
true
if keep alive is used.public HttpBrowser setKeepAlive(boolean keepAlive)
public HttpBrowser setCatchTransportExceptions(boolean catchTransportExceptions)
public HttpBrowser setProxyInfo(ProxyInfo proxyInfo)
public HttpBrowser setHttpConnectionProvider(HttpConnectionProvider httpConnectionProvider)
HttpConnectionProvider
for this browser session.
Resets the previous proxy definition, if set.public HttpBrowser setDefaultHeader(java.lang.String name, java.lang.String value)
public HttpRequest getHttpRequest()
public HttpResponse getHttpResponse()
HTTP response
object.public java.lang.String getPage()
public HttpResponse sendRequest(HttpRequest httpRequest)
protected HttpResponse _sendRequest(HttpRequest httpRequest, HttpResponse previouseResponse)
protected void addDefaultHeaders(HttpRequest httpRequest)
public long getElapsedTime()
sendRequest(HttpRequest)
in milliseconds.public void close()
public void clearCookies()
protected void readCookies(HttpResponse httpResponse)
protected void addCookies(HttpRequest httpRequest)
Copyright © 2003-present Jodd Team