Interface ZuulMessage

All Superinterfaces:
Cloneable
All Known Subinterfaces:
HttpRequestInfo, HttpRequestMessage, HttpResponseInfo, HttpResponseMessage
All Known Implementing Classes:
HttpRequestMessageImpl, HttpResponseMessageImpl, ZuulMessageImpl

public interface ZuulMessage extends Cloneable
Represents a message that propagates through the Zuul filter chain.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    bufferBodyContents(io.netty.handler.codec.http.HttpContent chunk)
    Appends an HTTP content chunk to this message.
    Returns a copy of this message.
    void
    Clears the content chunks of this body, calling release() in the process.
    boolean
    Sets the message body to be complete if it was not already so.
    byte[]
    Returns the message body.
    Gets the body of this message as UTF-8 text, or null if there is no body.
    Iterable<io.netty.handler.codec.http.HttpContent>
    Returns the HTTP content chunks that are part of this message.
    int
    Returns the length of the message body, or 0 if there isn't a message present.
    Returns the session context of this message.
    Returns the headers for this message.
    Returns a string that reprsents this message which is suitable for debugging.
    int
    Returns the maximum body size that this message is willing to hold.
    boolean
    Returns if this message has an attached body.
    boolean
    Indicates that the message contains a content chunk the implements LastHttpContent.
    void
    Reset the chunked body reader indexes.
    void
    Passes the body content chunks through the given filter, and sets them back into this message.
    void
    setBody(byte[] body)
    Sets the message body.
    void
    Sets the message body as UTF-8 encoded text.
    void
    setHasBody(boolean hasBody)
    Declares that this message has a body.
    void
    setHeaders(Headers newHeaders)
    Sets the headers for this message.
  • Method Details

    • getContext

      SessionContext getContext()
      Returns the session context of this message.
    • getHeaders

      Headers getHeaders()
      Returns the headers for this message. They may be request or response headers, depending on the underlying type of this object. For some messages, there may be no headers, such as with chunked requests or responses. In this case, a non-null default headers value will be returned.
    • setHeaders

      void setHeaders(Headers newHeaders)
      Sets the headers for this message.
      Throws:
      NullPointerException - if newHeaders is null.
    • hasBody

      boolean hasBody()
      Returns if this message has an attached body. For requests, this is typically an HTTP POST body. For responses, this is typically the HTTP response.
    • setHasBody

      void setHasBody(boolean hasBody)
      Declares that this message has a body. This method is automatically called when bufferBodyContents(io.netty.handler.codec.http.HttpContent) is invoked.
    • getBody

      @Nullable byte[] getBody()
      Returns the message body. If there is no message body, this returns null.
    • getBodyLength

      int getBodyLength()
      Returns the length of the message body, or 0 if there isn't a message present.
    • setBody

      void setBody(@Nullable byte[] body)
      Sets the message body. Note: if the body is null, this may not reset the body presence as returned by hasBody(). The body is considered complete after calling this method.
    • setBodyAsText

      void setBodyAsText(@Nullable String bodyText)
      Sets the message body as UTF-8 encoded text. Note that this does NOT set any headers related to the Content-Type; callers must set or reset the content type to UTF-8. The body is considered complete after calling this method.
    • bufferBodyContents

      void bufferBodyContents(io.netty.handler.codec.http.HttpContent chunk)
      Appends an HTTP content chunk to this message. Callers should be careful not to add multiple chunks that implement LastHttpContent.
      Throws:
      NullPointerException - if chunk is null.
    • getBodyContents

      Iterable<io.netty.handler.codec.http.HttpContent> getBodyContents()
      Returns the HTTP content chunks that are part of this message. Callers should avoid retaining the return value, as the contents may change with subsequent body mutations.
    • finishBufferedBodyIfIncomplete

      boolean finishBufferedBodyIfIncomplete()
      Sets the message body to be complete if it was not already so.
      Returns:
      true if the body was not yet complete, or else false.
    • hasCompleteBody

      boolean hasCompleteBody()
      Indicates that the message contains a content chunk the implements LastHttpContent.
    • runBufferedBodyContentThroughFilter

      void runBufferedBodyContentThroughFilter(ZuulFilter<?,?> filter)
      Passes the body content chunks through the given filter, and sets them back into this message.
    • disposeBufferedBody

      void disposeBufferedBody()
      Clears the content chunks of this body, calling release() in the process. Users SHOULD call this method when the body content is no longer needed.
    • getBodyAsText

      @Nullable String getBodyAsText()
      Gets the body of this message as UTF-8 text, or null if there is no body.
    • resetBodyReader

      void resetBodyReader()
      Reset the chunked body reader indexes. Users SHOULD call this method before retrying requests as the chunked body buffer will have had the reader indexes changed during channel writes.
    • getMaxBodySize

      int getMaxBodySize()
      Returns the maximum body size that this message is willing to hold. This value value should be more than the sum of lengths of the body chunks. The max body size may not be strictly enforced, and is informational.
    • clone

      ZuulMessage clone()
      Returns a copy of this message.
    • getInfoForLogging

      String getInfoForLogging()
      Returns a string that reprsents this message which is suitable for debugging.