Class HttpResponsePacket

All Implemented Interfaces:
org.glassfish.grizzly.attributes.AttributeStorage, org.glassfish.grizzly.Cacheable, MimeHeadersPacket

public abstract class HttpResponsePacket extends HttpHeader
The HttpHeader object, which represents HTTP response message.
Author:
Alexey Stashok
See Also:
  • Field Details

    • httpStatus

      protected HttpStatus httpStatus
      Status code.
  • Constructor Details

    • HttpResponsePacket

      protected HttpResponsePacket()
  • Method Details

    • builder

      public static HttpResponsePacket.Builder builder(HttpRequestPacket request)
      Returns HttpResponsePacket builder.
      Returns:
      HttpResponsePacket.Builder.
    • getStatus

      public int getStatus()
      Gets the status code for this response.
      Returns:
      the status code for this response.
    • getHttpStatus

      public HttpStatus getHttpStatus()
      Gets the HTTP status for this response.
      Returns:
      the HTTP status for this response.
    • setStatus

      public void setStatus(int status)
      Sets the status code for this response.
      Parameters:
      status - the status code for this response.
    • setStatus

      public void setStatus(HttpStatus status)
      Sets the status code for this response.
      Parameters:
      status - the status for this response.
    • isAllowCustomReasonPhrase

      public final boolean isAllowCustomReasonPhrase()
      Returns true if custom status reason phrases are allowed for this response, or false otherwise.
      Returns:
      true if custom status reason phrases are allowed for this response, or false otherwise.
    • setAllowCustomReasonPhrase

      public final void setAllowCustomReasonPhrase(boolean allowCustomReasonPhrase)
      Sets if the custom status reason phrases are allowed for this response.
      Parameters:
      allowCustomReasonPhrase - true if custom status reason phrases are allowed for this response, or false otherwise.
    • isHtmlEncodingCustomReasonPhrase

      public boolean isHtmlEncodingCustomReasonPhrase()
      Returns if we need to encode HTML sensitive characters in custom reason phrase.
    • setHtmlEncodingCustomReasonPhrase

      public void setHtmlEncodingCustomReasonPhrase(boolean isHtmlEncodingCustomReasonPhrase)
      Sets if we need to encode HTML sensitive characters in custom reason phrase.
    • getReasonPhraseRawDC

      public final DataChunk getReasonPhraseRawDC()
      Gets the custom status reason phrase for this response as DataChunk (avoid creation of a String object}.
      Returns:
      the status reason phrase for this response as DataChunk (avoid creation of a String object}.
    • getReasonPhraseDC

      public final DataChunk getReasonPhraseDC()
      Gets the status reason phrase for this response as DataChunk (avoid creation of a String object}. This implementation takes into consideration the isAllowCustomReasonPhrase() property - if the custom reason phrase is allowed and it's value is not null - then the returned result will be equal to getReasonPhraseRawDC(), otherwise if custom reason phrase is disallowed or its value is null - the default reason phrase for the HTTP response getStatus() will be returned.
      Returns:
      the status reason phrase for this response as DataChunk (avoid creation of a String object}.
    • getReasonPhrase

      public final String getReasonPhrase()
      Gets the status reason phrase for this response.
      Returns:
      the status reason phrase for this response.
    • setReasonPhrase

      public void setReasonPhrase(String message)
      Sets the status reason phrase for this response.
      Parameters:
      message - the status reason phrase for this response.
    • setReasonPhrase

      public void setReasonPhrase(org.glassfish.grizzly.Buffer reason)
    • isCustomReasonPhraseSet

      public final boolean isCustomReasonPhraseSet()
    • getRequest

      public HttpRequestPacket getRequest()
      Returns:
      the request that triggered this response
    • isAcknowledgement

      public boolean isAcknowledgement()
      Returns:
      true if this response packet is intended as an acknowledgment to an expectation from a client request.
    • setAcknowledgement

      public void setAcknowledgement(boolean acknowledgement)
      Mark this packet as an acknowledgment to a client expectation.
      Parameters:
      acknowledgement - true if this packet is an acknowledgment to a client expectation.
    • acknowledged

      public void acknowledged()
      Mark this packet as having been acknowledged.
    • reset

      protected void reset()
      Reset the internal state.
      Overrides:
      reset in class HttpHeader
    • isRequest

      public final boolean isRequest()
      Returns true, if the current HttpHeader represent HTTP request message, or false otherwise.
      Specified by:
      isRequest in class HttpHeader
      Returns:
      true, if the current HttpHeader represent HTTP request message, or false otherwise.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getLocale

      public Locale getLocale()
      Returns:
      the Locale of this response.
    • setLocale

      public void setLocale(Locale locale)
      Called explicitly by user to set the Content-Language and the default encoding
    • getContentLanguage

      public String getContentLanguage()
      Returns:
      the value that will be used by the Content-Language response header
    • setContentLanguage

      public void setContentLanguage(String contentLanguage)
      Set the value that will be used by the Content-Language response header.
    • setContentLengthLong

      public void setContentLengthLong(long contentLength)
      Description copied from class: HttpHeader
      Set the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
      Overrides:
      setContentLengthLong in class HttpHeader
      Parameters:
      contentLength - the content-length of this HttpPacket. Applicable only in case of fixed-length HTTP message.
    • setRequest

      public void setRequest(HttpRequestPacket request)
      Associates the request that triggered this response.
      Parameters:
      request - the request that triggered this response