Package com.netflix.zuul.message
Interface ZuulMessage
- All Superinterfaces:
Cloneable
- All Known Subinterfaces:
HttpRequestInfo
,HttpRequestMessage
,HttpResponseInfo
,HttpResponseMessage
- All Known Implementing Classes:
HttpRequestMessageImpl
,HttpResponseMessageImpl
,ZuulMessageImpl
Represents a message that propagates through the Zuul filter chain.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
bufferBodyContents
(io.netty.handler.codec.http.HttpContent chunk) Appends an HTTP content chunk to this message.clone()
Returns a copy of this message.void
Clears the content chunks of this body, callingrelease()
in the process.boolean
Sets the message body to be complete if it was not already so.byte[]
getBody()
Returns the message body.Gets the body of this message as UTF-8 text, ornull
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, or0
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
hasBody()
Returns if this message has an attached body.boolean
Indicates that the message contains a content chunk the implementsLastHttpContent
.void
Reset the chunked body reader indexes.void
runBufferedBodyContentThroughFilter
(ZuulFilter<?, ?> filter) 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
setBodyAsText
(String bodyText) 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
Sets the headers for this message.- Throws:
NullPointerException
- if newHeaders isnull
.
-
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 whenbufferBodyContents(io.netty.handler.codec.http.HttpContent)
is invoked. -
getBody
@Nullable byte[] getBody()Returns the message body. If there is no message body, this returnsnull
. -
getBodyLength
int getBodyLength()Returns the length of the message body, or0
if there isn't a message present. -
setBody
void setBody(@Nullable byte[] body) Sets the message body. Note: if thebody
isnull
, this may not reset the body presence as returned byhasBody()
. The body is considered complete after calling this method. -
setBodyAsText
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 implementLastHttpContent
.- Throws:
NullPointerException
- ifchunk
isnull
.
-
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 implementsLastHttpContent
. -
runBufferedBodyContentThroughFilter
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, callingrelease()
in the process. Users SHOULD call this method when the body content is no longer needed. -
getBodyAsText
Gets the body of this message as UTF-8 text, ornull
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.
-