org.apache.tomcat.util.test
Class HttpRequest

java.lang.Object
  |
  +--org.apache.tomcat.util.test.HttpRequest

public class HttpRequest
extends java.lang.Object

Part of GTest - defines a Http request. This tool gives a lot of control over the request, and is usable with ant ( testing is also a part of the build process :-) or other xml-tools using similar patterns.


Constructor Summary
HttpRequest()
           
 
Method Summary
 void addBody(Body b)
          Add content to the request, for POST ( alternate method )
 void addHeader(Header rh)
          Add a header to the request
 void addHeader(java.lang.String n, java.lang.String v)
           
 void addParam(Parameter rp)
          Add a parameter to the request
 void addText(java.lang.String s)
          Alternate method for sending a verbose request
 void addVerbose(Body b)
          Add content to the request, for POST ( alternate method )
 void execute()
           
static java.util.Hashtable getAllRequests()
          Return one of the "named" clients that have been executed so far.
 java.lang.String getFullRequest()
           
 java.lang.String getHost()
           
 HttpClient getHttpClient()
           
static HttpRequest getHttpRequest(java.lang.String id)
           
static java.util.Enumeration getHttpRequests()
           
 HttpResponse getHttpResponse()
           
static int getId()
           
 int getPort()
           
 java.lang.String getRequestLine()
           
 java.lang.String getURI()
          Return a URI (guessed) from the requestLine/fullRequest
 void prepareRequest()
           
static void registerHttpRequest(java.lang.String id, HttpRequest req)
           
 void setContent(java.lang.String s)
          Do a POST with the specified content.
 void setDebug(int d)
          Display debug info
 void setFullRequest(java.lang.String s)
          Allow sending a verbose request
 void setHeaders(java.lang.String s)
          Add headers - string representation, will be parsed The value is a "|" separated list of headers to expect.
 void setHost(java.lang.String h)
          Server that will receive the request
 void setHttpClient(HttpClient c)
           
 void setHttpResponse(HttpResponse r)
          Associated response, set after executing the request
 void setId(java.lang.String id)
          Set an unique id to this request.
 void setMethod(java.lang.String h)
           
 void setPassword(java.lang.String p)
           
 void setPath(java.lang.String s)
           
 void setPort(java.lang.String portS)
          The port used to send the request
 void setPortInt(int i)
          Set the port as int - different name to avoid confusing introspection
 void setProtocol(java.lang.String s)
           
 void setRequestLine(java.lang.String s)
          Verbose request line - including method and protocol
 void setUser(java.lang.String u)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpRequest

public HttpRequest()
Method Detail

setHttpResponse

public void setHttpResponse(HttpResponse r)
Associated response, set after executing the request

getHttpResponse

public HttpResponse getHttpResponse()

setHttpClient

public void setHttpClient(HttpClient c)

getHttpClient

public HttpClient getHttpClient()

setId

public void setId(java.lang.String id)
Set an unique id to this request. This allows it to be referenced later, for complex tests/matchers that look at multiple requests.

setHost

public void setHost(java.lang.String h)
Server that will receive the request

getHost

public java.lang.String getHost()

setMethod

public void setMethod(java.lang.String h)

setPort

public void setPort(java.lang.String portS)
The port used to send the request

setPortInt

public void setPortInt(int i)
Set the port as int - different name to avoid confusing introspection

getPort

public int getPort()

setUser

public void setUser(java.lang.String u)

setPassword

public void setPassword(java.lang.String p)

setContent

public void setContent(java.lang.String s)
Do a POST with the specified content.

addBody

public void addBody(Body b)
Add content to the request, for POST ( alternate method )

setProtocol

public void setProtocol(java.lang.String s)

setPath

public void setPath(java.lang.String s)

addHeader

public void addHeader(java.lang.String n,
                      java.lang.String v)

addHeader

public void addHeader(Header rh)
Add a header to the request

setHeaders

public void setHeaders(java.lang.String s)
Add headers - string representation, will be parsed The value is a "|" separated list of headers to expect. It's preferable to use the other 2 methods.

addParam

public void addParam(Parameter rp)
Add a parameter to the request

setDebug

public void setDebug(int d)
Display debug info

setRequestLine

public void setRequestLine(java.lang.String s)
Verbose request line - including method and protocol

getRequestLine

public java.lang.String getRequestLine()

setFullRequest

public void setFullRequest(java.lang.String s)
Allow sending a verbose request

getFullRequest

public java.lang.String getFullRequest()

addVerbose

public void addVerbose(Body b)
Add content to the request, for POST ( alternate method )

addText

public void addText(java.lang.String s)
Alternate method for sending a verbose request

execute

public void execute()

prepareRequest

public void prepareRequest()

getURI

public java.lang.String getURI()
Return a URI (guessed) from the requestLine/fullRequest

getId

public static int getId()

getAllRequests

public static java.util.Hashtable getAllRequests()
Return one of the "named" clients that have been executed so far.

registerHttpRequest

public static void registerHttpRequest(java.lang.String id,
                                       HttpRequest req)

getHttpRequest

public static HttpRequest getHttpRequest(java.lang.String id)

getHttpRequests

public static java.util.Enumeration getHttpRequests()


Copyright © 2001 Apache Software Foundation. All Rights Reserved.