Class HttpResponseMessageImpl

java.lang.Object
com.netflix.zuul.message.http.HttpResponseMessageImpl
All Implemented Interfaces:
HttpResponseInfo, HttpResponseMessage, ZuulMessage, Cloneable

public class HttpResponseMessageImpl extends Object implements HttpResponseMessage
User: michaels Date: 2/24/15 Time: 10:54 AM
  • Constructor Details

  • Method Details

    • defaultErrorResponse

      public static HttpResponseMessage defaultErrorResponse(HttpRequestMessage request)
    • getHeaders

      public Headers getHeaders()
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      getHeaders in interface ZuulMessage
    • getContext

      public SessionContext getContext()
      Description copied from interface: ZuulMessage
      Returns the session context of this message.
      Specified by:
      getContext in interface ZuulMessage
    • setHeaders

      public void setHeaders(Headers newHeaders)
      Description copied from interface: ZuulMessage
      Sets the headers for this message.
      Specified by:
      setHeaders in interface ZuulMessage
    • setHasBody

      public void setHasBody(boolean hasBody)
      Description copied from interface: ZuulMessage
      Declares that this message has a body. This method is automatically called when ZuulMessage.bufferBodyContents(io.netty.handler.codec.http.HttpContent) is invoked.
      Specified by:
      setHasBody in interface ZuulMessage
    • hasBody

      public boolean hasBody()
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      hasBody in interface ZuulMessage
    • bufferBodyContents

      public void bufferBodyContents(io.netty.handler.codec.http.HttpContent chunk)
      Description copied from interface: ZuulMessage
      Appends an HTTP content chunk to this message. Callers should be careful not to add multiple chunks that implement LastHttpContent.
      Specified by:
      bufferBodyContents in interface ZuulMessage
    • setBodyAsText

      public void setBodyAsText(String bodyText)
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      setBodyAsText in interface ZuulMessage
    • setBody

      public void setBody(byte[] body)
      Description copied from interface: ZuulMessage
      Sets the message body. Note: if the body is null, this may not reset the body presence as returned by ZuulMessage.hasBody(). The body is considered complete after calling this method.
      Specified by:
      setBody in interface ZuulMessage
    • getBodyAsText

      public String getBodyAsText()
      Description copied from interface: ZuulMessage
      Gets the body of this message as UTF-8 text, or null if there is no body.
      Specified by:
      getBodyAsText in interface ZuulMessage
    • getBody

      public byte[] getBody()
      Description copied from interface: ZuulMessage
      Returns the message body. If there is no message body, this returns null.
      Specified by:
      getBody in interface ZuulMessage
    • getBodyLength

      public int getBodyLength()
      Description copied from interface: ZuulMessage
      Returns the length of the message body, or 0 if there isn't a message present.
      Specified by:
      getBodyLength in interface ZuulMessage
    • hasCompleteBody

      public boolean hasCompleteBody()
      Description copied from interface: ZuulMessage
      Indicates that the message contains a content chunk the implements LastHttpContent.
      Specified by:
      hasCompleteBody in interface ZuulMessage
    • finishBufferedBodyIfIncomplete

      public boolean finishBufferedBodyIfIncomplete()
      Description copied from interface: ZuulMessage
      Sets the message body to be complete if it was not already so.
      Specified by:
      finishBufferedBodyIfIncomplete in interface ZuulMessage
      Returns:
      true if the body was not yet complete, or else false.
    • getBodyContents

      public Iterable<io.netty.handler.codec.http.HttpContent> getBodyContents()
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      getBodyContents in interface ZuulMessage
    • resetBodyReader

      public void resetBodyReader()
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      resetBodyReader in interface ZuulMessage
    • runBufferedBodyContentThroughFilter

      public void runBufferedBodyContentThroughFilter(ZuulFilter filter)
      Description copied from interface: ZuulMessage
      Passes the body content chunks through the given filter, and sets them back into this message.
      Specified by:
      runBufferedBodyContentThroughFilter in interface ZuulMessage
    • disposeBufferedBody

      public void disposeBufferedBody()
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      disposeBufferedBody in interface ZuulMessage
    • getInboundRequest

      public HttpRequestInfo getInboundRequest()
      Description copied from interface: HttpResponseInfo
      The immutable request that was originally received from client.
      Specified by:
      getInboundRequest in interface HttpResponseInfo
    • getOutboundRequest

      public HttpRequestMessage getOutboundRequest()
      Description copied from interface: HttpResponseMessage
      The mutable request that will be sent to Origin.
      Specified by:
      getOutboundRequest in interface HttpResponseMessage
    • getStatus

      public int getStatus()
      Specified by:
      getStatus in interface HttpResponseInfo
    • setStatus

      public void setStatus(int status)
      Specified by:
      setStatus in interface HttpResponseMessage
    • getMaxBodySize

      public int getMaxBodySize()
      Description copied from interface: ZuulMessage
      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.
      Specified by:
      getMaxBodySize in interface HttpResponseMessage
      Specified by:
      getMaxBodySize in interface ZuulMessage
    • parseSetCookieHeader

      public Cookies parseSetCookieHeader(String setCookieValue)
      Specified by:
      parseSetCookieHeader in interface HttpResponseInfo
    • hasSetCookieWithName

      public boolean hasSetCookieWithName(String cookieName)
      Specified by:
      hasSetCookieWithName in interface HttpResponseInfo
    • removeExistingSetCookie

      public boolean removeExistingSetCookie(String cookieName)
      Specified by:
      removeExistingSetCookie in interface HttpResponseMessage
    • addSetCookie

      public void addSetCookie(io.netty.handler.codec.http.Cookie cookie)
      Specified by:
      addSetCookie in interface HttpResponseMessage
    • setSetCookie

      public void setSetCookie(io.netty.handler.codec.http.Cookie cookie)
      Specified by:
      setSetCookie in interface HttpResponseMessage
    • clone

      public ZuulMessage clone()
      Description copied from interface: ZuulMessage
      Returns a copy of this message.
      Specified by:
      clone in interface HttpResponseInfo
      Specified by:
      clone in interface ZuulMessage
      Overrides:
      clone in class Object
    • copyResponseInfo

      protected HttpResponseInfo copyResponseInfo()
    • toString

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

      public void storeInboundResponse()
      Description copied from interface: HttpResponseMessage
      This should be called after response received from Origin, to store a copy of the response as-is.
      Specified by:
      storeInboundResponse in interface HttpResponseMessage
    • getInboundResponse

      public HttpResponseInfo getInboundResponse()
      Description copied from interface: HttpResponseMessage
      The immutable response that was received from Origin.
      Specified by:
      getInboundResponse in interface HttpResponseMessage
    • getInfoForLogging

      public String getInfoForLogging()
      Description copied from interface: ZuulMessage
      Returns a string that reprsents this message which is suitable for debugging.
      Specified by:
      getInfoForLogging in interface HttpResponseInfo
      Specified by:
      getInfoForLogging in interface ZuulMessage