Package com.netflix.zuul.message.http
Class HttpResponseMessageImpl
java.lang.Object
com.netflix.zuul.message.http.HttpResponseMessageImpl
- All Implemented Interfaces:
HttpResponseInfo
,HttpResponseMessage
,ZuulMessage
,Cloneable
User: michaels
Date: 2/24/15
Time: 10:54 AM
-
Constructor Summary
ConstructorsConstructorDescriptionHttpResponseMessageImpl
(SessionContext context, Headers headers, HttpRequestMessage request, int status) HttpResponseMessageImpl
(SessionContext context, HttpRequestMessage request, int status) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSetCookie
(io.netty.handler.codec.http.cookie.Cookie cookie) void
bufferBodyContents
(io.netty.handler.codec.http.HttpContent chunk) Appends an HTTP content chunk to this message.clone()
Returns a copy of this message.protected HttpResponseInfo
static HttpResponseMessage
defaultErrorResponse
(HttpRequestMessage request) 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 entire buffered message body, or0
if there isn't a message present.Returns the session context of this message.Returns the headers for this message.The immutable request that was originally received from client.The immutable response that was received from Origin.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.The mutable request that will be sent to Origin.int
boolean
hasBody()
Returns if this message has an attached body.boolean
Indicates that the message contains a content chunk the implementsLastHttpContent
.boolean
hasSetCookieWithName
(String cookieName) parseSetCookieHeader
(String setCookieValue) boolean
removeExistingSetCookie
(String cookieName) 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
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.void
setSetCookie
(io.netty.handler.codec.http.cookie.Cookie cookie) void
setStatus
(int status) void
This should be called after response received from Origin, to store a copy of the response as-is.toString()
-
Constructor Details
-
HttpResponseMessageImpl
-
HttpResponseMessageImpl
public HttpResponseMessageImpl(SessionContext context, Headers headers, HttpRequestMessage request, int status)
-
-
Method Details
-
defaultErrorResponse
-
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 interfaceZuulMessage
-
getContext
Description copied from interface:ZuulMessage
Returns the session context of this message.- Specified by:
getContext
in interfaceZuulMessage
-
setHeaders
Description copied from interface:ZuulMessage
Sets the headers for this message.- Specified by:
setHeaders
in interfaceZuulMessage
-
setHasBody
public void setHasBody(boolean hasBody) Description copied from interface:ZuulMessage
Declares that this message has a body. This method is automatically called whenZuulMessage.bufferBodyContents(io.netty.handler.codec.http.HttpContent)
is invoked.- Specified by:
setHasBody
in interfaceZuulMessage
-
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 interfaceZuulMessage
-
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 implementLastHttpContent
.- Specified by:
bufferBodyContents
in interfaceZuulMessage
-
setBodyAsText
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 interfaceZuulMessage
-
setBody
public void setBody(byte[] body) Description copied from interface:ZuulMessage
Sets the message body. Note: if thebody
isnull
, this may not reset the body presence as returned byZuulMessage.hasBody()
. The body is considered complete after calling this method.- Specified by:
setBody
in interfaceZuulMessage
-
getBodyAsText
Description copied from interface:ZuulMessage
Gets the body of this message as UTF-8 text, ornull
if there is no body.- Specified by:
getBodyAsText
in interfaceZuulMessage
-
getBody
public byte[] getBody()Description copied from interface:ZuulMessage
Returns the message body. This is the entire buffered body, regardless of whether the underlying body chunks have been read or not. If there is no message body, this returnsnull
.- Specified by:
getBody
in interfaceZuulMessage
-
getBodyLength
public int getBodyLength()Description copied from interface:ZuulMessage
Returns the length of the entire buffered message body, or0
if there isn't a message present.- Specified by:
getBodyLength
in interfaceZuulMessage
-
hasCompleteBody
public boolean hasCompleteBody()Description copied from interface:ZuulMessage
Indicates that the message contains a content chunk the implementsLastHttpContent
.- Specified by:
hasCompleteBody
in interfaceZuulMessage
-
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 interfaceZuulMessage
- Returns:
true
if the body was not yet complete, or else false.
-
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 interfaceZuulMessage
-
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 interfaceZuulMessage
-
runBufferedBodyContentThroughFilter
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 interfaceZuulMessage
-
disposeBufferedBody
public void disposeBufferedBody()Description copied from interface:ZuulMessage
Clears the content chunks of this body, callingrelease()
in the process. Users SHOULD call this method when the body content is no longer needed.- Specified by:
disposeBufferedBody
in interfaceZuulMessage
-
getInboundRequest
Description copied from interface:HttpResponseInfo
The immutable request that was originally received from client.- Specified by:
getInboundRequest
in interfaceHttpResponseInfo
-
getOutboundRequest
Description copied from interface:HttpResponseMessage
The mutable request that will be sent to Origin.- Specified by:
getOutboundRequest
in interfaceHttpResponseMessage
-
getStatus
public int getStatus()- Specified by:
getStatus
in interfaceHttpResponseInfo
-
setStatus
public void setStatus(int status) - Specified by:
setStatus
in interfaceHttpResponseMessage
-
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 interfaceHttpResponseMessage
- Specified by:
getMaxBodySize
in interfaceZuulMessage
-
parseSetCookieHeader
- Specified by:
parseSetCookieHeader
in interfaceHttpResponseInfo
-
hasSetCookieWithName
- Specified by:
hasSetCookieWithName
in interfaceHttpResponseInfo
-
removeExistingSetCookie
- Specified by:
removeExistingSetCookie
in interfaceHttpResponseMessage
-
addSetCookie
public void addSetCookie(io.netty.handler.codec.http.cookie.Cookie cookie) - Specified by:
addSetCookie
in interfaceHttpResponseMessage
-
setSetCookie
public void setSetCookie(io.netty.handler.codec.http.cookie.Cookie cookie) - Specified by:
setSetCookie
in interfaceHttpResponseMessage
-
clone
Description copied from interface:ZuulMessage
Returns a copy of this message.- Specified by:
clone
in interfaceHttpResponseInfo
- Specified by:
clone
in interfaceZuulMessage
- Overrides:
clone
in classObject
-
copyResponseInfo
-
toString
-
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 interfaceHttpResponseMessage
-
getInboundResponse
Description copied from interface:HttpResponseMessage
The immutable response that was received from Origin.- Specified by:
getInboundResponse
in interfaceHttpResponseMessage
-
getInfoForLogging
Description copied from interface:ZuulMessage
Returns a string that reprsents this message which is suitable for debugging.- Specified by:
getInfoForLogging
in interfaceHttpResponseInfo
- Specified by:
getInfoForLogging
in interfaceZuulMessage
-