Package org.microproxy.http
Class DefaultFullHttpResponse
java.lang.Object
org.microproxy.http.DefaultHttpResponse
org.microproxy.http.DefaultFullHttpResponse
- All Implemented Interfaces:
FullHttpMessage,FullHttpResponse,HttpContent,HttpMessage,HttpObject,HttpResponse,LastHttpContent
- Direct Known Subclasses:
HttpCache.Answer,ServerReplay.Replayed
public non-sealed class DefaultFullHttpResponse
extends DefaultHttpResponse
implements FullHttpResponse
A complete response with its body.
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status) Creates a complete response with empty headers and an empty body.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, byte[] content) Creates a complete response with empty headers.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, String body) Creates a complete response with a UTF-8 body and empty headers.DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, HttpHeaders headers, byte[] content) Creates a complete response using the supplied headers and body. -
Method Summary
Modifier and TypeMethodDescriptionbyte[]content()Returns the live backing array of body bytes, not a copy.setContent(byte[] content) Replaces the body bytes of this piece.setProtocolVersion(HttpVersion version) Changes the message's protocol version.Returns the mutable trailer fields following the body.Methods inherited from class org.microproxy.http.DefaultHttpResponse
headers, protocolVersion, setStatus, status, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.microproxy.http.HttpContent
contentAsString, contentAsString, contentLengthMethods inherited from interface org.microproxy.http.HttpMessage
headers, protocolVersionMethods inherited from interface org.microproxy.http.HttpResponse
setStatus, status
-
Constructor Details
-
DefaultFullHttpResponse
Creates a complete response with empty headers and an empty body.- Parameters:
version- protocol versionstatus- response status
-
DefaultFullHttpResponse
Creates a complete response with empty headers.- Parameters:
version- protocol versionstatus- response statuscontent- body backing array, retained without copying
-
DefaultFullHttpResponse
public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, HttpHeaders headers, byte[] content) Creates a complete response using the supplied headers and body.- Parameters:
version- protocol versionstatus- response statusheaders- mutable headers, retained without copyingcontent- body backing array, retained without copying
-
DefaultFullHttpResponse
Creates a complete response with a UTF-8 body and empty headers.- Parameters:
version- protocol versionstatus- response statusbody- body text to encode as UTF-8
-
-
Method Details
-
content
public byte[] content()Description copied from interface:HttpContentReturns the live backing array of body bytes, not a copy.- Specified by:
contentin interfaceHttpContent- Returns:
- the live backing array of body bytes, not a copy
-
setContent
Description copied from interface:HttpContentReplaces the body bytes of this piece.- Specified by:
setContentin interfaceFullHttpMessage- Specified by:
setContentin interfaceFullHttpResponse- Specified by:
setContentin interfaceHttpContent- Specified by:
setContentin interfaceLastHttpContent- Parameters:
content- new backing array, retained without copying- Returns:
- this content object
-
trailingHeaders
Description copied from interface:LastHttpContentReturns the mutable trailer fields following the body.- Specified by:
trailingHeadersin interfaceLastHttpContent- Returns:
- the mutable trailer fields following the body
-
setProtocolVersion
Description copied from interface:HttpMessageChanges the message's protocol version.- Specified by:
setProtocolVersionin interfaceHttpMessage- Specified by:
setProtocolVersionin interfaceHttpResponse- Overrides:
setProtocolVersionin classDefaultHttpResponse- Parameters:
version- new protocol version- Returns:
- this message
-