org.apache.commons.latka.http
Interface Request

All Known Implementing Classes:
RequestImpl

public interface Request

A Latka Request represents a request from an HTTP server.

Author:
Doug Sale, Morgan Delagrange, dIon Gillard

Field Summary
static int HTTP_METHOD_GET
          An integer representing the HTTP GET method
static int HTTP_METHOD_HEAD
          An integer representing the HTTP POST method
static int HTTP_METHOD_POST
          An integer representing the HTTP POST method
 
Method Summary
 void addHeader(String headerName, String headerValue)
          Sets a request header.
 void addParameter(String name, String value)
          Associate a parameter with this request.
 Response execute()
          Execute this HTTP request.
 boolean followRedirects()
          Whether or not this request will instruct HttpClient to follow local redirects automatically.
 Credentials getCredentials()
          Return the credentials for this request
 RequestHeaders getHeaders()
          Get the headers for the request, so that they can be copied to another request if necessary.
 String getLabel()
          Assigns a text label to this request.
 int getMethod()
          Return the constant representing the HTTP method to use in this request
 Parameters getParameters()
          Get the parameters for the request, so that they can be copied to another request if necessary.
 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()
          Gets the URL that Latka will attempt to contact.
 String getVersion()
          Get the HTTP version to use in this request
 void setCredentials(Credentials credentials)
          Sets the basic authentication credentials for this request, if any.
 void setHeaders(RequestHeaders requestHeaders)
          Set all the headers for the request.
 void setParameters(Parameters parameters)
          Set all the parameters for the request.
 void setRequestBody(String body)
          Set the request body for a manual POST.
 void setVersion(String version)
          Sets the version of HTTP that is used in the request.
 

Field Detail

HTTP_METHOD_GET

static final int HTTP_METHOD_GET
An integer representing the HTTP GET method

See Also:
Constant Field Values

HTTP_METHOD_POST

static final int HTTP_METHOD_POST
An integer representing the HTTP POST method

See Also:
Constant Field Values

HTTP_METHOD_HEAD

static final int HTTP_METHOD_HEAD
An integer representing the HTTP POST method

See Also:
Constant Field Values
Method Detail

execute

Response execute()
                 throws IOException
Execute this HTTP request. In the event of a 301 or 302, this method may need to create a new Request, due to an idiosyncracy of HttpClient. In that case, the Response.getRequest() method will return the actual Request that was executed. This will probably be fixed at some point in the future.

Returns:
a Response object represnting the HTTP response to the request
Throws:
IOException - if the remote server could not be reached

getLabel

String getLabel()
Assigns a text label to this request. This label will be made available to a LatkaEventListener during a test's execution

Returns:
the label associated with this request

getURL

URL getURL()
Gets the URL that Latka will attempt to contact. Note: since Latka will respect most redirects, this may not be the URL that returns the actual response.

Returns:
the URL associated with this HTTP request

addParameter

void addParameter(String name,
                  String value)
Associate a parameter with this request.

Parameters:
name - the name of the parameter
value - the value of the parameter

setParameters

void setParameters(Parameters parameters)
Set all the parameters for the request. Overrides any parameters that have been already set by addParameter();

Parameters:
parameters - all parameters for this request

getParameters

Parameters getParameters()
Get the parameters for the request, so that they can be copied to another request if necessary.

Returns:
parameters for this request

addHeader

void addHeader(String headerName,
               String headerValue)
Sets a request header.

Parameters:
headerName - header name
headerValue - header value or null for a null header

setHeaders

void setHeaders(RequestHeaders requestHeaders)
Set all the headers for the request. Overrides any headers that have been already set by addHeader();

Parameters:
requestHeaders - all headers for this request

getHeaders

RequestHeaders getHeaders()
Get the headers for the request, so that they can be copied to another request if necessary.

Returns:
headers for this request

getSession

Session getSession()
Retrieve the session associated with this request.

Returns:
a Session object

getRequestTiming

int getRequestTiming()
The amount of time it took to execute the request in milliseconds, or -1 if the request has not been executed successfully

Returns:
time it took to execute the request in millis

setCredentials

void setCredentials(Credentials credentials)
Sets the basic authentication credentials for this request, if any.

Parameters:
credentials - user's identification

getCredentials

Credentials getCredentials()
Return the credentials for this request

Returns:
Request credentials

followRedirects

boolean followRedirects()
Whether or not this request will instruct HttpClient to follow local redirects automatically.

Returns:
true if HttpClient will redirect a 301 or 302 response

getMethod

int getMethod()
Return the constant representing the HTTP method to use in this request

Returns:
HTTP method for this request

setRequestBody

void setRequestBody(String body)
Set the request body for a manual POST. You may not both set the request body and add parameters.

Parameters:
body - Body to POST

setVersion

void setVersion(String version)
Sets the version of HTTP that is used in the request. If the version of HTTP specified is not 1.0 or 1.1, then the default of 1.1 will be used.

Parameters:
version - HTTP version.

getVersion

String getVersion()
Get the HTTP version to use in this request

Returns:
HTTP version for the request


Copyright © 2001-2010 The Apache Software Foundation. All Rights Reserved.