Class HTTPMessageData

java.lang.Object
org.omegazero.http.common.HTTPMessageData
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
HTTPRequestData, HTTPResponseData

public class HTTPMessageData extends Object implements Serializable
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 Details

  • Constructor Details

    • HTTPMessageData

      public HTTPMessageData(HTTPMessage httpMessage, byte[] data)
      Creates a new HTTPMessageData instance.
      Parameters:
      httpMessage - The HTTP message
      data - The full or partial body of the httpMessage. May be null
    • HTTPMessageData

      public HTTPMessageData(HTTPMessage httpMessage, boolean lastPacket, byte[] data)
      Creates a new HTTPMessageData instance.
      Parameters:
      httpMessage - The HTTP message
      lastPacket - Whether this HTTPMessageData represents the last body data part
      data - The full or partial body of the httpMessage. May be null
  • Method Details

    • getHttpMessage

      public HTTPMessage getHttpMessage()
      Returns the HTTPMessage stored in this HTTPMessageData object.
      Returns:
      The HTTPMessage
    • getData

      public byte[] getData()
      Returns the data stored in this HTTPMessageData 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 this HTTPMessageData was not initialized with data (null passed in the constructor) and the given data is not null
      UnsupportedOperationException - If the HTTPMessage 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 this HTTPMessageData represents the last body data part of the HTTP message.
      Returns:
      true if this is the last body data part