public class SessionImpl extends java.lang.Object implements Session
Modifier and Type | Field and Description |
---|---|
protected org.apache.commons.httpclient.HttpState |
_state
this state object 'belongs' to HttpClient
we maintain a reference in SessionImpl for
simplicity
|
protected java.util.LinkedList |
_urls
tracks URLs treated by this session
Session will automatically set the referer
header for a request to the URL of the
previous request
|
Constructor and Description |
---|
SessionImpl() |
Modifier and Type | Method and Description |
---|---|
void |
addCookie(java.lang.String domain,
java.lang.String path,
java.lang.String name,
java.lang.String value)
Adds a cookie to all HTTP requests whose domain and path match (according
to RFC2109).
|
Request |
createRequest(java.lang.String label,
java.net.URL url,
int httpMethod,
java.lang.String version,
boolean followRedirects)
Creates a labeled request object with the specified URL, HTTP Method,
version, and redirect handling behavior.
|
Request |
createRequest(java.lang.String label,
java.net.URL url,
int httpMethod,
java.lang.String version,
boolean followRedirects,
Proxy proxy)
Create a labeled request , with the specified URL, HTTP method, version, and
redirect handling behavior, using the given proxy for communications.
|
Request |
createRequest(java.net.URL url,
int httpMethod,
Proxy proxy,
java.lang.String version)
Creates a request object with the specified URL, HTTP Method, and
version to be accessed via the provided proxy.
|
Request |
createRequest(java.net.URL url,
int httpMethod,
java.lang.String version)
Creates a request object with the specified URL, HTTP Method,
and version.
|
java.lang.String |
getCookieValue(java.lang.String name)
Returns the value of cookie
name . |
protected java.net.URL |
getReferer()
The URL of the last request that was executed.
|
protected void |
setReferer(java.net.URL url)
Called inside the request.execute() method, setting the
referer for the next request.
|
protected java.util.LinkedList _urls
protected org.apache.commons.httpclient.HttpState _state
public Request createRequest(java.net.URL url, int httpMethod, java.lang.String version)
createRequest
in interface Session
url
- The URL to request of the HTTP server.httpMethod
- An integer representing the HTTP method (e.g. GET, PUT)
used to communicate with server.version
- A String representing the version of the HTTP request, i.e.
1.0 or 1.1.Request
object representing the url
and httpMethod
Request.HTTP_METHOD_GET
,
Request.HTTP_METHOD_POST
public Request createRequest(java.lang.String label, java.net.URL url, int httpMethod, java.lang.String version, boolean followRedirects)
createRequest
in interface Session
label
- Name of the requesturl
- The URL to request of the HTTP server.httpMethod
- An integer representing the HTTP method (e.g. GET, PUT)
used to communicate with server.version
- A String representing the version of the HTTP request, i.e.
1.0 or 1.1.followRedirects
- whether HTTP redirects should be processedRequest
object representing the url
and httpMethod
Request.HTTP_METHOD_GET
,
Request.HTTP_METHOD_POST
public Request createRequest(java.net.URL url, int httpMethod, Proxy proxy, java.lang.String version)
createRequest
in interface Session
url
- The URL to request of the HTTP server.httpMethod
- An integer representing the HTTP method (e.g. GET, PUT)
used to communicate with server.version
- A String representing the version of the HTTP request, i.e.
1.0 or 1.1.proxy
- a proxy to use during the requestRequest
object representing the url
and httpMethod
Request.HTTP_METHOD_GET
,
Request.HTTP_METHOD_POST
,
Proxy
public Request createRequest(java.lang.String label, java.net.URL url, int httpMethod, java.lang.String version, boolean followRedirects, Proxy proxy)
createRequest
in interface Session
label
- a name used to identify the requesturl
- The URL to request of the HTTP server.httpMethod
- An integer representing the HTTP method (e.g. GET, PUT)
used to communicate with server.version
- A String representing the version of the HTTP request, i.e.
1.0 or 1.1.followRedirects
- whether to follow HTTP redirection responsesproxy
- a proxy to use during the requestRequest
object representing the url
and httpMethod
.Request.HTTP_METHOD_GET
,
Request.HTTP_METHOD_POST
,
Proxy
protected void setReferer(java.net.URL url)
url
- URL of the last executed request.protected java.net.URL getReferer()
public void addCookie(java.lang.String domain, java.lang.String path, java.lang.String name, java.lang.String value)
public java.lang.String getCookieValue(java.lang.String name)
name
.getCookieValue
in interface Session
name
- the name of the cookieCopyright © 2002-2013 The Apache Software Foundation. All Rights Reserved.