Package com.linecorp.armeria.common
Interface AggregatedHttpResponse
-
public interface AggregatedHttpResponse
A complete HTTP response whose content is readily available as a singleHttpData
.
-
-
Method Summary
Modifier and Type Method Description HttpData
content()
Returns the content of this message.default String
content(Charset charset)
Returns the content of this message as a string encoded in the specifiedCharset
.default String
contentAscii()
Returns the content of this message as an ASCII string.default MediaType
contentType()
Returns the value of the'content-type'
header.default String
contentUtf8()
Returns the content of this message as a UTF-8 string.ResponseHeaders
headers()
Returns theResponseHeaders
.List<ResponseHeaders>
informationals()
Returns the informational class (1xx) HTTP headers.static AggregatedHttpResponse
of(int statusCode)
Creates a new HTTP response.static AggregatedHttpResponse
of(HttpStatus status)
Creates a new HTTP response.static AggregatedHttpResponse
of(HttpStatus status, MediaType mediaType, byte[] content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpResponse
of(HttpStatus status, MediaType mediaType, HttpData content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpResponse
of(HttpStatus status, MediaType mediaType, HttpData content, HttpHeaders trailers)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpResponse
of(HttpStatus status, MediaType mediaType, CharSequence content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpResponse
of(HttpStatus status, MediaType mediaType, String content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpResponse
of(HttpStatus status, MediaType mediaType, String format, Object... args)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpResponse
of(ResponseHeaders headers)
Creates a new HTTP response with empty content.static AggregatedHttpResponse
of(ResponseHeaders headers, HttpData content)
Creates a new HTTP response.static AggregatedHttpResponse
of(ResponseHeaders headers, HttpData content, HttpHeaders trailers)
Creates a new HTTP response.static AggregatedHttpResponse
of(Iterable<ResponseHeaders> informationals, ResponseHeaders headers, HttpData content, HttpHeaders trailers)
Creates a new HTTP response.HttpStatus
status()
Returns the STATUS of this response.default HttpResponse
toHttpResponse()
Converts this response into a new completeHttpResponse
.HttpHeaders
trailers()
Returns the HTTP trailers.default HttpHeaders
trailingHeaders()
Deprecated.Usetrailers()
.
-
-
-
Method Detail
-
of
static AggregatedHttpResponse of(int statusCode)
Creates a new HTTP response.- Parameters:
statusCode
- the HTTP status code
-
of
static AggregatedHttpResponse of(HttpStatus status)
Creates a new HTTP response.- Parameters:
status
- the HTTP status
-
of
static AggregatedHttpResponse of(HttpStatus status, MediaType mediaType, CharSequence content)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the response
-
of
static AggregatedHttpResponse of(HttpStatus status, MediaType mediaType, String content)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the response
-
of
static AggregatedHttpResponse of(HttpStatus status, MediaType mediaType, String format, Object... args)
Creates a new HTTP response of the specifiedHttpStatus
. The content of the response is formatted byString.format(Locale, String, Object...)
with English locale.- Parameters:
mediaType
- theMediaType
of the response contentformat
- the format string of the response contentargs
- the arguments referenced by the format specifiers in the format string
-
of
static AggregatedHttpResponse of(HttpStatus status, MediaType mediaType, byte[] content)
Creates a new HTTP response of the specifiedHttpStatus
. Thecontent
will be wrapped usingHttpData.wrap(byte[])
, so any changes made tocontent
will be reflected in the response.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the response
-
of
static AggregatedHttpResponse of(HttpStatus status, MediaType mediaType, HttpData content)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the response
-
of
static AggregatedHttpResponse of(HttpStatus status, MediaType mediaType, HttpData content, HttpHeaders trailers)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the responsetrailers
- the HTTP trailers
-
of
static AggregatedHttpResponse of(ResponseHeaders headers)
Creates a new HTTP response with empty content.- Parameters:
headers
- the HTTP headers
-
of
static AggregatedHttpResponse of(ResponseHeaders headers, HttpData content)
Creates a new HTTP response.- Parameters:
headers
- the HTTP headerscontent
- the content of the HTTP response
-
of
static AggregatedHttpResponse of(ResponseHeaders headers, HttpData content, HttpHeaders trailers)
Creates a new HTTP response.- Parameters:
headers
- the HTTP headerscontent
- the content of the HTTP responsetrailers
- the HTTP trailers
-
of
static AggregatedHttpResponse of(Iterable<ResponseHeaders> informationals, ResponseHeaders headers, HttpData content, HttpHeaders trailers)
Creates a new HTTP response.- Parameters:
informationals
- the informational class (1xx) HTTP headersheaders
- the HTTP headerscontent
- the content of the HTTP responsetrailers
- the HTTP trailers
-
headers
ResponseHeaders headers()
Returns theResponseHeaders
.
-
informationals
List<ResponseHeaders> informationals()
Returns the informational class (1xx) HTTP headers.
-
status
HttpStatus status()
Returns the STATUS of this response.
-
toHttpResponse
default HttpResponse toHttpResponse()
Converts this response into a new completeHttpResponse
.- Returns:
- the new
HttpResponse
converted from this response.
-
trailingHeaders
@Deprecated default HttpHeaders trailingHeaders()
Deprecated.Usetrailers()
.Returns the HTTP trailers.
-
trailers
HttpHeaders trailers()
Returns the HTTP trailers.
-
content
HttpData content()
Returns the content of this message.
-
content
default String content(Charset charset)
Returns the content of this message as a string encoded in the specifiedCharset
.
-
contentUtf8
default String contentUtf8()
Returns the content of this message as a UTF-8 string.
-
contentAscii
default String contentAscii()
Returns the content of this message as an ASCII string.
-
contentType
@Nullable default MediaType contentType()
Returns the value of the'content-type'
header.- Returns:
- the valid header value if present.
null
otherwise.
-
-