Package org.omegazero.http.common
Class HTTPMessageData
java.lang.Object
org.omegazero.http.common.HTTPMessageData
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
HTTPRequestData,HTTPResponseData
An object of this class contains a single
HTTPMessage and its body data (or a part of it).- Since:
- 1.2.1
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected byte[]SeegetData().protected final HTTPMessageSeegetHttpMessage().protected final booleanSeeisLastPacket(). -
Constructor Summary
ConstructorsConstructorDescriptionHTTPMessageData(HTTPMessage httpMessage, boolean lastPacket, byte[] data) Creates a newHTTPMessageDatainstance.HTTPMessageData(HTTPMessage httpMessage, byte[] data) Creates a newHTTPMessageDatainstance. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]getData()Returns the data stored in thisHTTPMessageDataobject.Returns theHTTPMessagestored in thisHTTPMessageDataobject.booleanReturns whether thisHTTPMessageDatarepresents the last body data part of the HTTP message.voidsetData(byte[] data) Replaces the stored data with the given data.
-
Field Details
-
httpMessage
SeegetHttpMessage(). -
lastPacket
protected final boolean lastPacketSeeisLastPacket(). -
data
protected byte[] dataSeegetData().
-
-
Constructor Details
-
HTTPMessageData
Creates a newHTTPMessageDatainstance.- Parameters:
httpMessage- The HTTP messagedata- The full or partial body of the httpMessage. May benull
-
HTTPMessageData
Creates a newHTTPMessageDatainstance.- Parameters:
httpMessage- The HTTP messagelastPacket- Whether thisHTTPMessageDatarepresents the last body data partdata- The full or partial body of the httpMessage. May benull
-
-
Method Details
-
getHttpMessage
Returns theHTTPMessagestored in thisHTTPMessageDataobject.- Returns:
- The
HTTPMessage
-
getData
public byte[] getData()Returns the data stored in thisHTTPMessageDataobject.- Returns:
- The data
-
setData
public void setData(byte[] data) Replaces the stored data with the given data.If the
HTTPMessagebody of this object is not chunked, the given byte array must have the same length as before.- Parameters:
data- The new data- Throws:
IllegalStateException- If thisHTTPMessageDatawas not initialized with data (nullpassed in the constructor) and the given data is notnullUnsupportedOperationException- If theHTTPMessagebody of this object is not chunked and the given byte array does not have the same length as the original byte array
-
isLastPacket
public boolean isLastPacket()Returns whether thisHTTPMessageDatarepresents the last body data part of the HTTP message.- Returns:
trueif this is the last body data part
-