|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.latka.http.RequestImpl
public class RequestImpl
An implementation of a Latka Request interface based on the Apache Commons HttpClient package.
Request
Field Summary | |
---|---|
protected Credentials |
_credentials
credentials for the request |
protected boolean |
_followRedirects
whether or not redirect responses should be followed as part of the request processing |
protected String |
_host
host the request is being made on |
protected org.apache.commons.httpclient.HttpClient |
_httpClient
object used to perform the http requests |
protected org.apache.commons.httpclient.HttpMethod |
_httpMethod
http method implementation |
protected String |
_httpVersion
|
protected String |
_label
name given to the request |
protected static org.apache.log4j.Category |
_log
log4j category used when logging messages |
protected int |
_method
http method being used to make the request |
protected Parameters |
_parameters
parameters sent with this request |
protected int |
_port
port the request is being made on |
protected String |
_query
query string portion of the URL |
protected String |
_requestBody
manually constructed post body |
protected RequestHeaders |
_requestHeaders
headers sent with this request |
protected long |
_requestTiming
time taken for the request in milliseconds |
protected SessionImpl |
_session
http session the request is part of |
protected URL |
_targetURL
URL being requested |
protected List |
_visitedURLs
|
static int |
HTTP_PORT
Standard HTTP Port |
static int |
HTTPS_PORT
Standard HTTPS Port |
Fields inherited from interface org.apache.commons.latka.http.Request |
---|
HTTP_METHOD_GET, HTTP_METHOD_HEAD, HTTP_METHOD_POST |
Constructor Summary | |
---|---|
protected |
RequestImpl(String label,
URL url,
int httpMethod,
org.apache.commons.httpclient.HttpState state,
SessionImpl session,
boolean followRedirects)
Create a RequestImpl |
protected |
RequestImpl(URL url,
int httpMethod,
org.apache.commons.httpclient.HttpState state,
SessionImpl session)
Create a request for the specified URL, process using the supplied method and use the supplied state and session for persistent data |
Method Summary | |
---|---|
void |
addHeader(String headerName,
String headerValue)
Set a header in the request |
protected void |
addHttpClientParameter(String name,
String value)
Associate a parameter with this request. |
void |
addParameter(String name,
String value)
Add a parameter (name and value) to the request |
protected void |
closeConnection()
Closes the http connection associated with the request |
Response |
execute()
Executes the request. |
protected Response |
executeRequestPerHost()
Execute the request - perform the http interaction. |
boolean |
followRedirects()
Defined in the interface |
Credentials |
getCredentials()
Return the credentials for this request |
RequestHeaders |
getHeaders()
Defined in the implemented interface |
protected org.apache.commons.httpclient.HttpMethod |
getHttpMethod()
Returns the object implementing the HttpMethod (get, post, etc.) for this request. |
String |
getLabel()
Get the label used for the request |
int |
getMethod()
Defined in the interface |
Parameters |
getParameters()
Defined in the implemented interface |
Proxy |
getProxy()
Getter for property proxy. |
int |
getRequestTiming()
The amount of time it took to execute the request in milliseconds, or -1 if the request has not been executed successfully |
Session |
getSession()
Retrieve the session associated with this request. |
URL |
getURL()
Get the URL used for the request |
String |
getVersion()
Get the HTTP version to use in this request. |
protected void |
openConnection()
opens an HTTP connection. |
void |
setCredentials(Credentials credentials)
Defined in the implemented interface |
void |
setHeaders(RequestHeaders requestHeaders)
Defined in the implemented interface |
void |
setParameters(Parameters parameters)
Defined in the implemented interface |
void |
setProxy(Proxy proxy)
Setter for property proxy. |
void |
setRequestBody(String body)
Defined in the implemented interface |
void |
setVersion(String version)
Sets the HTTP version for this request. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int HTTP_PORT
public static final int HTTPS_PORT
protected String _host
protected int _port
protected int _method
protected SessionImpl _session
protected Credentials _credentials
protected org.apache.commons.httpclient.HttpMethod _httpMethod
protected URL _targetURL
protected String _query
protected long _requestTiming
protected String _label
protected RequestHeaders _requestHeaders
protected Parameters _parameters
protected String _requestBody
protected boolean _followRedirects
protected org.apache.commons.httpclient.HttpClient _httpClient
protected static final org.apache.log4j.Category _log
protected String _httpVersion
protected List _visitedURLs
Constructor Detail |
---|
protected RequestImpl(URL url, int httpMethod, org.apache.commons.httpclient.HttpState state, SessionImpl session)
url
- the URL to send the request tohttpMethod
- the http method to use in sending the request, as
defined in Request
state
- shared information across requestssession
- state shared across servers and requestsprotected RequestImpl(String label, URL url, int httpMethod, org.apache.commons.httpclient.HttpState state, SessionImpl session, boolean followRedirects)
label
- a name for the requesturl
- the url that this request embodieshttpMethod
- the method by which this request should be executedstate
- shared information across requestssession
- the session that the request should be executed infollowRedirects
- whether http redirect responses should be honouredMethod Detail |
---|
protected org.apache.commons.httpclient.HttpMethod getHttpMethod()
public RequestHeaders getHeaders()
getHeaders
in interface Request
Request.getHeaders()
public void setHeaders(RequestHeaders requestHeaders)
setHeaders
in interface Request
requestHeaders
- new value for the headers propertyRequest.setHeaders(RequestHeaders)
public Parameters getParameters()
getParameters
in interface Request
Request.getParameters()
public void setRequestBody(String body)
setRequestBody
in interface Request
body
- Body to POSTRequest.setRequestBody(String)
public void setParameters(Parameters parameters)
setParameters
in interface Request
parameters
- new value for parameters propertyRequest.setParameters(Parameters)
public void setCredentials(Credentials credentials)
setCredentials
in interface Request
credentials
- username and password to useRequest.setCredentials(Credentials)
public Credentials getCredentials()
Request
getCredentials
in interface Request
protected Response executeRequestPerHost() throws IOException
Response
detailing the html etc
IOException
- when there are problems reading and writingRequest.execute()
public Response execute() throws IOException
execute
in interface Request
IOException
- if the remote server could not be reachedpublic URL getURL()
getURL
in interface Request
URL
of the requestRequest.getURL()
public String getLabel()
getLabel
in interface Request
Request.getLabel()
public void addParameter(String name, String value)
addParameter
in interface Request
name
- the name of the parameter to be addedvalue
- the value of the parameter to be addedRequest.addParameter(String,String)
protected void addHttpClientParameter(String name, String value)
name
- the lvalue of the parameter - must not be nullvalue
- the rvalue of the parameter - must not be nullpublic void addHeader(String headerName, String headerValue)
addHeader
in interface Request
headerName
- name of any HTTP request headerheaderValue
- value of that headerpublic Session getSession()
getSession
in interface Request
Session
objectpublic int getRequestTiming()
Request
getRequestTiming
in interface Request
protected void openConnection() throws IOException
IOException
- if the server could not be contactedprotected void closeConnection() throws IOException
IOException
- if there are problems closing the connectionpublic boolean followRedirects()
followRedirects
in interface Request
Request.followRedirects()
public int getMethod()
getMethod
in interface Request
Request.getMethod()
public Proxy getProxy()
public void setProxy(Proxy proxy)
proxy
- New value of property proxy.public void setVersion(String version)
setVersion
in interface Request
version
- HTTP versionpublic String getVersion()
getVersion
in interface Request
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |