|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectice.net.HttpMessage
The HttpMessage is an abstract class, which functions as the
base class for HTTP messages containing the common functionality. It is
responsible for all the HTTP header management and the
.HttpMessage.EntityBody
Additionally, it has all the HTTP 1.0 and 1.1 general header, as well as a commonly used extension general header constant, and HTTP version constants as a convenience and uniform use of these HTTP elements.
Finally, it contains a couple of convenience methods, namely
getBytes(), getLength() and
getMessage() for byte related tasks with HTTP messages.
Subclasses have to implement at least the only abstract method
getMessage(boolean) for the actual representation of the
specific HTTP message.
For detailed information on the HyperText Transfer Protocol and some of its extensions see:
| Nested Class Summary | |
static class |
HttpMessage.EntityBody
The EntityBody class represents the entity body of an
HTTP message. |
| Field Summary | |
static String |
CACHE_CONTROL
HTTP 1.1 general header: Cache-Control. |
protected static String |
COLON
|
static String |
CONNECTION
HTTP 1.1 general header: Connection. |
protected static String |
CR_LF
|
static String |
DATE
HTTP 1.0 general header: Date. |
static int |
DISCONNECTED_OPERATION
HTTP 1.1 warning code 112: Disconnected operation. |
protected HttpMessage.EntityBody |
entityBody
This HttpMessage's entity body. |
protected HeaderMap |
headerMap
The map containing all the headers for this HttpMessage. |
static int |
HEURISTIC_EXPIRATION
HTTP 1.1 warning code 113: Heuristic expiration. |
static String |
HTTP_10
HTTP 1.0 version: HTTP/1.0. |
static String |
HTTP_11
HTTP 1.1 version: HTTP/1.1 |
protected String |
httpVersion
This HttpMessage's HTTP version string. |
static String |
KEEP_ALIVE
HTTP general header (extension): Keep-Alive. |
static int |
MISCELLANEOUS_PERSISTENT_WARNING
HTTP 1.1 warning code 299: Miscellaneous persistent warning. |
static int |
MISCELLANEOUS_WARNING
HTTP 1.1 warning code 199: Miscellaneous warning. |
static String |
PRAGMA
HTTP 1.0 general header: Pragma. |
static String |
PROXY_CONNECTION
HTTP general header (extension): Proxy-Connection. |
static int |
RESPONSE_IS_STALE
HTTP 1.1 warning code 110: Response is stale. |
static int |
REVALIDATION_FAILED
HTTP 1.1 warning code 111: Revalidation failed. |
protected static String |
SPACE
|
static String |
TRAILER
HTTP 1.1 general header: Trailer. |
static String |
TRANSFER_ENCODING
HTTP 1.1 general header: Transfer-Encoding. |
static int |
TRANSFORMATION_APPLIED
HTTP 1.1 warning code 214: Transformation applied. |
static String |
UPGRADE
HTTP 1.1 general header: Upgrade. |
static String |
VIA
HTTP 1.1 general header: Via. |
static String |
WARNING
HTTP 1.1 general header: Warning. |
| Constructor Summary | |
protected |
HttpMessage(String httpVersion)
Constructs a new HttpMessage with the specified
httpVersion as the HTTP version. |
| Method Summary | |
void |
clearHeaders()
Removes all the headers from this HttpMessage. |
Object |
clone()
|
boolean |
containsHeader(String fieldName)
Returns true if this HttpMessage contains a
header with the specified fieldName. |
void |
dispose()
Releases all of the resources used by this HttpMessage and its subcomponent
EntityBody, if it exists. |
boolean |
equals(Object object)
|
byte[] |
getBytes()
Convenience method for getting the byte array of this HttpMessage. |
HttpMessage.EntityBody |
getEntityBody()
Returns the entity body of this HttpMessage. |
String |
getFieldName(int index)
Returns the field name at the specified index in this
HttpMessage. |
String |
getFieldValue(int index)
Returns the field value at the specified index in this
HttpMessage. |
String[] |
getFieldValues(String fieldName)
Returns the field values that are mapped with the specified fieldName in this HttpMessage. |
HeaderMap.Header |
getHeader(int index)
Returns the header at the specified index in
this HttpMessage. |
int |
getHeaderCount()
Returns the number of headers contained in this HttpMessage. |
String |
getHttpVersion()
Returns the HTTP version of this HttpMessage. |
int |
getLength()
Convenience method for getting the length of this HttpMessage. |
String |
getMessage()
Convenience method for getting the actual String
representation of this HttpMessage without the entity
body. |
abstract String |
getMessage(boolean showBody)
Convenience method for getting the actual String
representation of this HttpMessage depending on the
specified showBody with or without the entity body. |
abstract String |
getStartLine()
Gets the start-line of this HttpMessage. |
void |
putHeader(String fieldName,
String fieldValue)
Maps the specified fieldValue with the specified
fieldName in this HttpMessage. |
void |
removeHeader(int index)
Removes the mapping at the specified index from this
HttpMessage if present. |
void |
removeHeaders(String fieldName)
Removes all mappings for the specified fieldName from
this HttpMessage if one is present. |
void |
setEntityBody(HttpMessage.EntityBody entityBody)
Sets the entity body of this HttpMessage to the specified
entityBody. |
void |
setHttpVersion(String httpVersion)
Sets the HTTP version of this HttpMessage to the
specified httpVersion. |
| Methods inherited from class java.lang.Object |
finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
public static final String CACHE_CONTROL
public static final String CONNECTION
public static final String DATE
public static final String PRAGMA
public static final String TRAILER
public static final String TRANSFER_ENCODING
public static final String UPGRADE
public static final String VIA
public static final String WARNING
public static final String KEEP_ALIVE
public static final String PROXY_CONNECTION
public static final String HTTP_10
public static final String HTTP_11
public static final int RESPONSE_IS_STALE
public static final int REVALIDATION_FAILED
public static final int DISCONNECTED_OPERATION
public static final int HEURISTIC_EXPIRATION
public static final int MISCELLANEOUS_WARNING
public static final int TRANSFORMATION_APPLIED
public static final int MISCELLANEOUS_PERSISTENT_WARNING
protected static final String CR_LF
protected static final String COLON
protected static final String SPACE
protected HttpMessage.EntityBody entityBody
HttpMessage's entity body.
protected HeaderMap headerMap
HttpMessage.
protected String httpVersion
HttpMessage's HTTP version string.
| Constructor Detail |
protected HttpMessage(String httpVersion)
throws IllegalArgumentException
Constructs a new HttpMessage with the specified
httpVersion as the HTTP version.
httpVersion - the HTTP version of the HTTP message to be constructed.
IllegalArgumentException - if the specified httpVersion is either
null or empty.HTTP_10,
HTTP_11| Method Detail |
public void clearHeaders()
Removes all the headers from this HttpMessage.
public Object clone()
public boolean containsHeader(String fieldName)
Returns true if this HttpMessage contains a
header with the specified fieldName.
fieldName - field name whose presence in this
HttpMessage is to be tested.
true if this HttpMessage contains a
header with the specified fieldName.public void dispose()
Releases all of the resources used by this
HttpMessage and its subcomponent
EntityBody, if it exists. That is, the resources will be
destroyed and any memory they consume will be returned to the OS.
public boolean equals(Object object)
public byte[] getBytes()
Convenience method for getting the byte array of this
HttpMessage. This method has the same effect as:
getMessage(true).getBytes()
HttpMessage.public HttpMessage.EntityBody getEntityBody()
Returns the entity body of this HttpMessage.
#setEntityBody(EntityBody)public HeaderMap.Header getHeader(int index)
Returns the header at the specified index in
this HttpMessage.
index - the index of the header to return.
index
in this HttpMessage, or null.public int getHeaderCount()
Returns the number of headers contained in this
HttpMessage.
public String getFieldName(int index)
Returns the field name at the specified index in this
HttpMessage.
index - the index of the field name to return.
index in this
HttpMessage, or null.getFieldValue(int)public String getFieldValue(int index)
Returns the field value at the specified index in this
HttpMessage.
index - the index of the field value to return.
index in this
HttpMessage, or null.getFieldName(int)public String[] getFieldValues(String fieldName)
Returns the field values that are mapped with the specified
fieldName in this HttpMessage.
If this HttpMessage contains more than one mapping with
the specified fieldName, all the field values are
returned.
fieldName - the field name whose mapped field value is to be
returned.
HttpMessage maps the specified
fieldName.public String getHttpVersion()
Returns the HTTP version of this HttpMessage.
setHttpVersion(String)public int getLength()
Convenience method for getting the length of this
HttpMessage. This method has the same effect as:
getBytes().length
public String getMessage()
Convenience method for getting the actual String
representation of this HttpMessage without the entity
body.
String representation.getMessage(boolean)public abstract String getMessage(boolean showBody)
Convenience method for getting the actual String
representation of this HttpMessage depending on the
specified showBody with or without the entity body.
String representation.public abstract String getStartLine()
Gets the start-line of this HttpMessage.
public void putHeader(String fieldName,
String fieldValue)
Maps the specified fieldValue with the specified
fieldName in this HttpMessage. If this
HttpMessage previously contained a mapping for
this fieldName, an additional mapping is created for the
specified fieldValue.
fieldName - the field name with which the specified
fieldValue is to be mapped.fieldValue - the field value to be mapped with the specified
fieldName.public void removeHeader(int index)
Removes the mapping at the specified index from this
HttpMessage if present.
index - the index of the mapping to be removed from this
HttpMessage.public void removeHeaders(String fieldName)
Removes all mappings for the specified fieldName from
this HttpMessage if one is present.
fieldName - the field name whose mappings are to be removed from this
HttpMessage.public void setEntityBody(HttpMessage.EntityBody entityBody)
Sets the entity body of this HttpMessage to the specified
entityBody.
entityBody - the new entity body.getEntityBody()
public void setHttpVersion(String httpVersion)
throws IllegalArgumentException
Sets the HTTP version of this HttpMessage to the
specified httpVersion.
httpVersion - the new HTTP version.
IllegalArgumentException - if the specified httpVersion is either
null or empty.getHttpVersion()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||