|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.owasp.webscarab.model.Message
public class Message
Message is a class that is used to represent the bulk of an HTTP message, namely the headers, and (possibly null) body. Messages should not be instantiated directly, but should rather be created by a derived class, namely Request or Response.
Field Summary | |
---|---|
protected java.util.logging.Logger |
_logger
|
Constructor Summary | |
---|---|
Message()
Message is a class that is used to represent the bulk of an HTTP message, namely the headers, and (possibly null) body. |
Method Summary | |
---|---|
void |
addHeader(NamedValue header)
|
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header with the specified name and value. |
java.lang.String |
deleteHeader(java.lang.String name)
Removes a header |
boolean |
equals(java.lang.Object obj)
|
void |
flushContentStream()
reads all content from the content stream if one exists. |
byte[] |
getContent()
getContent returns the message body that accompanied the request. |
java.lang.String |
getHeader(java.lang.String name)
Returns the value of the requested header |
java.lang.String[] |
getHeaderNames()
Returns an array of header names |
NamedValue[] |
getHeaders()
returns the header names and their values |
java.lang.String[] |
getHeaders(java.lang.String name)
Returns all the values of the requested header, if there are multiple items |
protected java.lang.String |
getLine(java.lang.StringBuffer buffer)
a protected method to read a line up to and including the CR or CRLF. |
void |
parse(java.lang.StringBuffer buffer)
Instructs the class to read the headers and content from the supplied StringBuffer N.B. |
void |
read(java.io.InputStream is)
Instructs the class to read the headers from the InputStream, and assign the InputStream as the contentStream, from which the body of the message can be read. |
protected java.lang.String |
readLine(java.io.InputStream is)
a protected method to read a line up to and including the CR or CRLF. |
void |
setContent(byte[] bytes)
Sets the content of the message body. |
void |
setHeader(NamedValue header)
|
void |
setHeader(java.lang.String name,
java.lang.String value)
sets the value of a header. |
void |
setHeaders(NamedValue[] headers)
sets the headers |
void |
setNoBody()
sets the message to not have a body. |
java.lang.String |
toString()
Returns a String representation of the message, *including* the message body. |
java.lang.String |
toString(java.lang.String crlf)
Returns a String representation of the message, *including* the message body. |
void |
write(java.io.OutputStream os)
Writes the Message headers and content to the supplied OutputStream |
void |
write(java.io.OutputStream os,
java.lang.String crlf)
Writes the Message headers and content to the supplied OutputStream |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.util.logging.Logger _logger
Constructor Detail |
---|
public Message()
Method Detail |
---|
public void read(java.io.InputStream is) throws java.io.IOException
is
- the InputStream to read the Message headers and body from
java.io.IOException
- Propagates any IOExceptions thrown by the InputStream read methodspublic void write(java.io.OutputStream os) throws java.io.IOException
os
- The OutputStream to write the Message headers and content to
java.io.IOException
- any IOException thrown by the supplied OutputStream, or any IOException thrown by the InputStream from which this Message was originally read (if any)public void write(java.io.OutputStream os, java.lang.String crlf) throws java.io.IOException
os
- The OutputStream to write the Message headers and content tocrlf
- the line ending to use for the headers
java.io.IOException
- any IOException thrown by the supplied OutputStream, or any IOException thrown by the InputStream from which this Message was originally read (if any)public void parse(java.lang.StringBuffer buffer) throws java.text.ParseException
buffer
- The StringBuffer to parse the headers and content from. This buffer is "consumed" i.e. characters are removed from the buffer as the Message is parsed.
java.text.ParseException
- if there is an error parsing the Message structurepublic java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toString(java.lang.String crlf)
crlf
- The required line separator string
public void setHeader(java.lang.String name, java.lang.String value)
name
- the name of the header (without a colon)value
- the value of the headerpublic void setHeader(NamedValue header)
public void addHeader(java.lang.String name, java.lang.String value)
name
- the name of the header (without a colon)value
- the value of the headerpublic void addHeader(NamedValue header)
public java.lang.String deleteHeader(java.lang.String name)
name
- the name of the header (without a colon)
public java.lang.String[] getHeaderNames()
public java.lang.String getHeader(java.lang.String name)
name
- the name of the header (without a colon)
public java.lang.String[] getHeaders(java.lang.String name)
name
- the name of the header (without a colon)
public NamedValue[] getHeaders()
public void setHeaders(NamedValue[] headers)
table
- a two dimensional array of Strings, where table[i][0] is the header name and
table[i][1] is the header valueprotected java.lang.String readLine(java.io.InputStream is) throws java.io.IOException
is
- The InputStream to read the line from
java.io.IOException
- if an IOException occurs while reading from the supplied InputStreamprotected java.lang.String getLine(java.lang.StringBuffer buffer)
buffer
- the StringBuffer to read the line from
public byte[] getContent()
public void flushContentStream()
public void setNoBody()
public void setContent(byte[] bytes)
bytes
- a byte array containing the message bodypublic boolean equals(java.lang.Object obj)
equals
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |