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 HTTPMessage
SeegetHttpMessage()
.protected final boolean
SeeisLastPacket()
. -
Constructor Summary
ConstructorsConstructorDescriptionHTTPMessageData
(HTTPMessage httpMessage, boolean lastPacket, byte[] data) Creates a newHTTPMessageData
instance.HTTPMessageData
(HTTPMessage httpMessage, byte[] data) Creates a newHTTPMessageData
instance. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]
getData()
Returns the data stored in thisHTTPMessageData
object.Returns theHTTPMessage
stored in thisHTTPMessageData
object.boolean
Returns whether thisHTTPMessageData
represents the last body data part of the HTTP message.void
setData
(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 newHTTPMessageData
instance.- Parameters:
httpMessage
- The HTTP messagedata
- The full or partial body of the httpMessage. May benull
-
HTTPMessageData
Creates a newHTTPMessageData
instance.- Parameters:
httpMessage
- The HTTP messagelastPacket
- Whether thisHTTPMessageData
represents the last body data partdata
- The full or partial body of the httpMessage. May benull
-
-
Method Details
-
getHttpMessage
Returns theHTTPMessage
stored in thisHTTPMessageData
object.- Returns:
- The
HTTPMessage
-
getData
public byte[] getData()Returns the data stored in thisHTTPMessageData
object.- Returns:
- The data
-
setData
public void setData(byte[] data) Replaces the stored data with the given data.If the
HTTPMessage
body 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 thisHTTPMessageData
was not initialized with data (null
passed in the constructor) and the given data is notnull
UnsupportedOperationException
- If theHTTPMessage
body 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 thisHTTPMessageData
represents the last body data part of the HTTP message.- Returns:
true
if this is the last body data part
-