|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.anteater.test.HttpMessage
Describes the common attributes of an HTTP request and response.
Field Summary | |
static String |
UNSET_BODY
|
static String |
UNSET_HOST
|
static int |
UNSET_PORT
|
static String |
UNSET_PROTOCOL
|
Constructor Summary | |
HttpMessage(javax.servlet.http.HttpServletRequest request)
Creates a new HttpMessage instance from an
HttpServletRequest object. |
|
HttpMessage(org.apache.tools.ant.Project project)
Creates a new HttpMessage instance. |
|
HttpMessage(org.apache.tools.ant.Project proj,
InputStream is)
|
|
HttpMessage(org.apache.tools.ant.Project proj,
InputStream is,
int debug)
Creates a new HttpMessage instance given an
InputStream object to read an HTTP response from the
server. |
|
HttpMessage(org.apache.tools.ant.Project project,
int dbg)
Creates a new HttpMessage instance. |
Method Summary | |
void |
addHeader(Header header)
|
void |
addParameter(Parameter param)
|
String |
getBody()
|
org.dom4j.Document |
getDocument()
Assumes body contains an XML document, and returns a DOM4J Document object representation of it. |
String |
getDocumentAsString()
Obtain the string representation of the XML document. |
Header |
getHeader(String name)
|
HashMap |
getHeaders()
|
String |
getHost()
|
String |
getMethod()
|
Map |
getParameters()
|
String |
getPassword()
|
String |
getPath()
|
int |
getPort()
Returns the port number of this URL. |
String |
getProtocol()
|
String |
getResponseLine()
|
String |
getURL()
Return the URL of the HTTP resource to request. |
String |
getUser()
|
boolean |
isSecure()
Should operate over SSL? |
void |
parseHeaders(BufferedReader br)
Parse the incoming HTTP request headers. |
String |
printHeaders(HashMap headers)
Print a set of Header s. |
String |
readBody(BufferedReader isr)
|
void |
setBody(String bd)
|
void |
setContent(String content)
Assumes the value of the content attribute is an href whose content is to be POSTed. |
void |
setHeaders(String s)
|
void |
setHost(String host)
|
void |
setHref(String href)
Set the URL specifying the resource for a HTTP request message. |
void |
setMethod(String method)
|
void |
setPassword(String password)
|
void |
setPath(String path)
|
void |
setPort(int port)
|
void |
setProject(org.apache.tools.ant.Project proj)
|
void |
setProtocol(String protocol)
Set HTTP protocol, typically HTTP/1.0 or
HTTP/1.1 . |
void |
setQuery(String query)
Parse the 'query' part of the URL, ie the bit after the '?', and store in variable "Parameter". |
void |
setResponseLine(String rsp)
|
void |
setSecure(boolean secure)
Sets whether request/response should be made via SSL. |
void |
setUser(String user)
|
void |
setUseTidy(Boolean yn)
|
String |
toString()
|
protected String |
urlDecode(String str)
|
protected String |
urlEncode(String str)
|
void |
writeTo(OutputStream os,
org.apache.tools.ant.Project project)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int UNSET_PORT
public static final String UNSET_HOST
public static final String UNSET_BODY
public static final String UNSET_PROTOCOL
Constructor Detail |
public HttpMessage(org.apache.tools.ant.Project proj, InputStream is, int debug) throws IOException
HttpMessage
instance given an
InputStream
object to read an HTTP response from the
server.
is
- an InputStream
valuedebug
- an int
value
IOException
- if an error occurspublic HttpMessage(org.apache.tools.ant.Project proj, InputStream is) throws IOException
public HttpMessage(javax.servlet.http.HttpServletRequest request) throws IOException
HttpMessage
instance from an
HttpServletRequest
object. This is the preferred
constructor when creating instances within a servlet container.
Note that if this constructor is used, getURL()
will not have
variables interpolated, as there is no access to the Ant project.
request
- a HttpServletRequest
value
IOException
- if an error occurspublic HttpMessage(org.apache.tools.ant.Project project)
HttpMessage
instance.
public HttpMessage(org.apache.tools.ant.Project project, int dbg)
HttpMessage
instance.
Method Detail |
public void setProject(org.apache.tools.ant.Project proj)
public String toString()
toString
in class Object
public String getURL()
public void setMethod(String method)
public String getMethod()
public void setProtocol(String protocol)
HTTP/1.0
or
HTTP/1.1
.
public String getProtocol()
public void setSecure(boolean secure)
public boolean isSecure()
public void setHref(String href) throws MalformedURLException
href
- URL to request, eg http://whatever/blah?foo=bar
.
The query string (foo=bar
) part provides an alternative to
nested <parameter>
elements.
MalformedURLException
public void setHost(String host)
public String getHost()
public void setPort(int port)
public int getPort()
public void setPath(String path)
public String getPath()
public void setQuery(String query)
query
- The Query string. Can be null.public void setUser(String user)
public String getUser()
public void setPassword(String password)
public String getPassword()
public String getResponseLine()
public void setResponseLine(String rsp)
public void addParameter(Parameter param)
public Map getParameters()
public void addHeader(Header header)
public Header getHeader(String name)
public HashMap getHeaders()
public void setBody(String bd)
public String getBody()
public void setUseTidy(Boolean yn)
public void setHeaders(String s)
public org.dom4j.Document getDocument() throws org.dom4j.DocumentException
getDocument
in interface XMLDocument
Document
object that's the DOM4J
representation of the document.
org.dom4j.DocumentException
public String getDocumentAsString()
XMLDocument
getDocumentAsString
in interface XMLDocument
String
valuepublic void parseHeaders(BufferedReader br) throws IOException
IOException
- if an input/output error occurspublic String readBody(BufferedReader isr) throws IOException
IOException
public void setContent(String content)
public void writeTo(OutputStream os, org.apache.tools.ant.Project project) throws IOException
IOException
public String printHeaders(HashMap headers)
Header
s.
headers
- HashMap of name->Header
objects.
Headers: X-Cocoon-Version: 2.1-dev Content-Length: 187 Content-Type: text/html Server: Tomcat Web Server/3.3.1 Final ( JSP 1.1; Servlet 2.2 ) Date: Mon, 21 Oct 2002 08:39:22 GMT Location: http://localhost:8787/cocoon-cvs/samples/
protected String urlEncode(String str)
protected String urlDecode(String str)
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |