Package io.netty.handler.codec.http
Class DefaultFullHttpResponse
- java.lang.Object
-
- io.netty.handler.codec.http.DefaultHttpObject
-
- io.netty.handler.codec.http.DefaultHttpMessage
-
- io.netty.handler.codec.http.DefaultHttpResponse
-
- io.netty.handler.codec.http.DefaultFullHttpResponse
-
- All Implemented Interfaces:
ByteBufHolder
,DecoderResultProvider
,FullHttpMessage
,FullHttpResponse
,HttpContent
,HttpMessage
,HttpObject
,HttpResponse
,LastHttpContent
,ReferenceCounted
public class DefaultFullHttpResponse extends DefaultHttpResponse implements FullHttpResponse
Default implementation of aFullHttpResponse
.
-
-
Field Summary
-
Fields inherited from interface io.netty.handler.codec.http.LastHttpContent
EMPTY_LAST_CONTENT
-
-
Constructor Summary
Constructors Constructor Description DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status)
Create an empty HTTP response with the given HTTP version and status.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders, boolean singleFieldHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content)
Create an HTTP response with the given HTTP version, status, and contents.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, boolean validateHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, boolean validateHeaders, boolean singleFieldHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, HttpHeadersFactory headersFactory, HttpHeadersFactory trailersFactory)
Create an HTTP response with the given HTTP version, status, contents, and with headers and trailers created by the given header factories.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, HttpHeaders headers, HttpHeaders trailingHeaders)
Create an HTTP response with the given HTTP version, status, contents, headers and trailers.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ByteBuf
content()
Return the data which is held by thisByteBufHolder
.FullHttpResponse
copy()
Creates a deep copy of thisByteBufHolder
.FullHttpResponse
duplicate()
Duplicates thisByteBufHolder
.boolean
equals(java.lang.Object o)
int
hashCode()
int
refCnt()
Returns the reference count of this object.boolean
release()
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.boolean
release(int decrement)
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.FullHttpResponse
replace(ByteBuf content)
Returns a newByteBufHolder
which contains the specifiedcontent
.FullHttpResponse
retain()
Increases the reference count by1
.FullHttpResponse
retain(int increment)
Increases the reference count by the specifiedincrement
.FullHttpResponse
retainedDuplicate()
Duplicates thisByteBufHolder
.FullHttpResponse
setProtocolVersion(HttpVersion version)
Set the protocol version of thisHttpMessage
FullHttpResponse
setStatus(HttpResponseStatus status)
Set the status of thisHttpResponse
.java.lang.String
toString()
FullHttpResponse
touch()
Records the current access location of this object for debugging purposes.FullHttpResponse
touch(java.lang.Object hint)
Records the current access location of this object with an additional arbitrary information for debugging purposes.HttpHeaders
trailingHeaders()
-
Methods inherited from class io.netty.handler.codec.http.DefaultHttpResponse
getStatus, status
-
Methods inherited from class io.netty.handler.codec.http.DefaultHttpMessage
getProtocolVersion, headers, protocolVersion
-
Methods inherited from class io.netty.handler.codec.http.DefaultHttpObject
decoderResult, getDecoderResult, setDecoderResult
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.handler.codec.DecoderResultProvider
decoderResult, setDecoderResult
-
Methods inherited from interface io.netty.handler.codec.http.HttpMessage
getProtocolVersion, headers, protocolVersion
-
Methods inherited from interface io.netty.handler.codec.http.HttpObject
getDecoderResult
-
Methods inherited from interface io.netty.handler.codec.http.HttpResponse
getStatus, status
-
-
-
-
Constructor Detail
-
DefaultFullHttpResponse
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status)
Create an empty HTTP response with the given HTTP version and status.
-
DefaultFullHttpResponse
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content)
Create an HTTP response with the given HTTP version, status, and contents.
-
DefaultFullHttpResponse
@Deprecated public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.Create an empty HTTP response with the given HTTP version, status, and optional header validation.
-
DefaultFullHttpResponse
@Deprecated public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, boolean validateHeaders, boolean singleFieldHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.Create an empty HTTP response with the given HTTP version, status, optional header validation, and optional header combining.
-
DefaultFullHttpResponse
@Deprecated public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, boolean validateHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.Create an HTTP response with the given HTTP version, status, contents, and optional header validation.
-
DefaultFullHttpResponse
@Deprecated public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, boolean validateHeaders, boolean singleFieldHeaders)
Deprecated.Prefer theDefaultFullHttpResponse(HttpVersion, HttpResponseStatus, ByteBuf, HttpHeadersFactory, HttpHeadersFactory)
constructor instead.Create an HTTP response with the given HTTP version, status, contents, optional header validation, and optional header combining.
-
DefaultFullHttpResponse
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, HttpHeadersFactory headersFactory, HttpHeadersFactory trailersFactory)
Create an HTTP response with the given HTTP version, status, contents, and with headers and trailers created by the given header factories.The recommended header factory is
DefaultHttpHeadersFactory.headersFactory()
, and the recommended trailer factory isDefaultHttpHeadersFactory.trailersFactory()
.
-
DefaultFullHttpResponse
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, ByteBuf content, HttpHeaders headers, HttpHeaders trailingHeaders)
Create an HTTP response with the given HTTP version, status, contents, headers and trailers.
-
-
Method Detail
-
trailingHeaders
public HttpHeaders trailingHeaders()
- Specified by:
trailingHeaders
in interfaceLastHttpContent
-
content
public ByteBuf content()
Description copied from interface:ByteBufHolder
Return the data which is held by thisByteBufHolder
.- Specified by:
content
in interfaceByteBufHolder
-
refCnt
public int refCnt()
Description copied from interface:ReferenceCounted
Returns the reference count of this object. If0
, it means this object has been deallocated.- Specified by:
refCnt
in interfaceReferenceCounted
-
retain
public FullHttpResponse retain()
Description copied from interface:ReferenceCounted
Increases the reference count by1
.- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfaceFullHttpMessage
- Specified by:
retain
in interfaceFullHttpResponse
- Specified by:
retain
in interfaceHttpContent
- Specified by:
retain
in interfaceLastHttpContent
- Specified by:
retain
in interfaceReferenceCounted
-
retain
public FullHttpResponse retain(int increment)
Description copied from interface:ReferenceCounted
Increases the reference count by the specifiedincrement
.- Specified by:
retain
in interfaceByteBufHolder
- Specified by:
retain
in interfaceFullHttpMessage
- Specified by:
retain
in interfaceFullHttpResponse
- Specified by:
retain
in interfaceHttpContent
- Specified by:
retain
in interfaceLastHttpContent
- Specified by:
retain
in interfaceReferenceCounted
-
touch
public FullHttpResponse touch()
Description copied from interface:ReferenceCounted
Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
. This method is a shortcut totouch(null)
.- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfaceFullHttpMessage
- Specified by:
touch
in interfaceFullHttpResponse
- Specified by:
touch
in interfaceHttpContent
- Specified by:
touch
in interfaceLastHttpContent
- Specified by:
touch
in interfaceReferenceCounted
-
touch
public FullHttpResponse touch(java.lang.Object hint)
Description copied from interface:ReferenceCounted
Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you viaResourceLeakDetector
.- Specified by:
touch
in interfaceByteBufHolder
- Specified by:
touch
in interfaceFullHttpMessage
- Specified by:
touch
in interfaceFullHttpResponse
- Specified by:
touch
in interfaceHttpContent
- Specified by:
touch
in interfaceLastHttpContent
- Specified by:
touch
in interfaceReferenceCounted
-
release
public boolean release()
Description copied from interface:ReferenceCounted
Decreases the reference count by1
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
release
public boolean release(int decrement)
Description copied from interface:ReferenceCounted
Decreases the reference count by the specifieddecrement
and deallocates this object if the reference count reaches at0
.- Specified by:
release
in interfaceReferenceCounted
- Returns:
true
if and only if the reference count became0
and this object has been deallocated
-
setProtocolVersion
public FullHttpResponse setProtocolVersion(HttpVersion version)
Description copied from interface:HttpMessage
Set the protocol version of thisHttpMessage
- Specified by:
setProtocolVersion
in interfaceFullHttpResponse
- Specified by:
setProtocolVersion
in interfaceHttpMessage
- Specified by:
setProtocolVersion
in interfaceHttpResponse
- Overrides:
setProtocolVersion
in classDefaultHttpResponse
-
setStatus
public FullHttpResponse setStatus(HttpResponseStatus status)
Description copied from interface:HttpResponse
Set the status of thisHttpResponse
.- Specified by:
setStatus
in interfaceFullHttpResponse
- Specified by:
setStatus
in interfaceHttpResponse
- Overrides:
setStatus
in classDefaultHttpResponse
-
copy
public FullHttpResponse copy()
Description copied from interface:ByteBufHolder
Creates a deep copy of thisByteBufHolder
.- Specified by:
copy
in interfaceByteBufHolder
- Specified by:
copy
in interfaceFullHttpMessage
- Specified by:
copy
in interfaceFullHttpResponse
- Specified by:
copy
in interfaceHttpContent
- Specified by:
copy
in interfaceLastHttpContent
-
duplicate
public FullHttpResponse duplicate()
Description copied from interface:ByteBufHolder
Duplicates thisByteBufHolder
. Be aware that this will not automatically callByteBufHolder.retain()
.- Specified by:
duplicate
in interfaceByteBufHolder
- Specified by:
duplicate
in interfaceFullHttpMessage
- Specified by:
duplicate
in interfaceFullHttpResponse
- Specified by:
duplicate
in interfaceHttpContent
- Specified by:
duplicate
in interfaceLastHttpContent
-
retainedDuplicate
public FullHttpResponse retainedDuplicate()
Description copied from interface:ByteBufHolder
Duplicates thisByteBufHolder
. This method returns a retained duplicate unlikeByteBufHolder.duplicate()
.- Specified by:
retainedDuplicate
in interfaceByteBufHolder
- Specified by:
retainedDuplicate
in interfaceFullHttpMessage
- Specified by:
retainedDuplicate
in interfaceFullHttpResponse
- Specified by:
retainedDuplicate
in interfaceHttpContent
- Specified by:
retainedDuplicate
in interfaceLastHttpContent
- See Also:
ByteBuf.retainedDuplicate()
-
replace
public FullHttpResponse replace(ByteBuf content)
Description copied from interface:ByteBufHolder
Returns a newByteBufHolder
which contains the specifiedcontent
.- Specified by:
replace
in interfaceByteBufHolder
- Specified by:
replace
in interfaceFullHttpMessage
- Specified by:
replace
in interfaceFullHttpResponse
- Specified by:
replace
in interfaceHttpContent
- Specified by:
replace
in interfaceLastHttpContent
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classDefaultHttpResponse
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classDefaultHttpResponse
-
toString
public java.lang.String toString()
- Overrides:
toString
in classDefaultHttpResponse
-
-