Package com.linecorp.armeria.common
Interface AggregatedHttpMessage
-
public interface AggregatedHttpMessage
A complete HTTP message whose content is readily available as a singleHttpData
. It can be an HTTP request or an HTTP response depending on what header values it contains. For example, having aHttpHeaderNames.STATUS
header could mean it is an HTTP response.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description default String
authority()
Returns theAUTHORITY
of this message, in the form of"hostname:port"
.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.HttpHeaders
headers()
Returns the HTTP headers.List<HttpHeaders>
informationals()
Returns the informational class (1xx) HTTP headers.default HttpMethod
method()
Returns theMETHOD
of this message.static AggregatedHttpMessage
of(int statusCode)
Creates a new HTTP response.static AggregatedHttpMessage
of(HttpHeaders headers)
Creates a new HTTP message with empty content.static AggregatedHttpMessage
of(HttpHeaders headers, HttpData content)
Creates a new HTTP message.static AggregatedHttpMessage
of(HttpHeaders headers, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP message.static AggregatedHttpMessage
of(HttpMethod method, String path)
Creates a new HTTP request with empty content.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, byte[] content)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, byte[] content, int offset, int length)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, HttpData content)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, CharSequence content)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, String content)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpMethod method, String path, MediaType mediaType, String format, Object... args)
Creates a new HTTP request.static AggregatedHttpMessage
of(HttpStatus status)
Creates a new HTTP response.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, byte[] content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, byte[] content, int offset, int length)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, HttpData content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, CharSequence content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, String content)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(HttpStatus status, MediaType mediaType, String format, Object... args)
Creates a new HTTP response of the specifiedHttpStatus
.static AggregatedHttpMessage
of(Iterable<HttpHeaders> informationals, HttpHeaders headers, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP message.default String
path()
Returns thePATH
of this message.default String
scheme()
Returns theSCHEME
of this message.default HttpStatus
status()
Returns theSTATUS
of this message.default HttpRequest
toHttpRequest()
Deprecated.default HttpResponse
toHttpResponse()
Deprecated.HttpHeaders
trailingHeaders()
Returns the trailing HTTP headers.
-
-
-
Method Detail
-
of
static AggregatedHttpMessage of(HttpMethod method, String path)
Creates a new HTTP request with empty content.- Parameters:
method
- the HTTP method of the requestpath
- the path of the request
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, CharSequence content)
Creates a new HTTP request.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentcontent
- the content of the request
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, String content)
Creates a new HTTP request.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentcontent
- the content of the request
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, String format, Object... args)
Creates a new HTTP request. The content of the request is formatted byString.format(Locale, String, Object...)
with English locale.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentformat
- the format string of the request contentargs
- the arguments referenced by the format specifiers in the format string
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, byte[] content)
Creates a new HTTP request.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentcontent
- the content of the request
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, byte[] content, int offset, int length)
Creates a new HTTP request.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentcontent
- the content of the requestoffset
- the start offset ofcontent
length
- the length ofcontent
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, HttpData content)
Creates a new HTTP request.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentcontent
- the content of the request
-
of
static AggregatedHttpMessage of(HttpMethod method, String path, MediaType mediaType, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP request.- Parameters:
method
- the HTTP method of the requestpath
- the path of the requestmediaType
- theMediaType
of the request contentcontent
- the content of the requesttrailingHeaders
- the trailing HTTP headers
-
of
static AggregatedHttpMessage of(int statusCode)
Creates a new HTTP response.- Parameters:
statusCode
- the HTTP status code
-
of
static AggregatedHttpMessage of(HttpStatus status)
Creates a new HTTP response.- Parameters:
status
- the HTTP status
-
of
static AggregatedHttpMessage 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 AggregatedHttpMessage 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 AggregatedHttpMessage 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 AggregatedHttpMessage of(HttpStatus status, MediaType mediaType, byte[] content)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the response
-
of
static AggregatedHttpMessage of(HttpStatus status, MediaType mediaType, byte[] content, int offset, int length)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the responseoffset
- the start offset ofcontent
length
- the length ofcontent
-
of
static AggregatedHttpMessage 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 AggregatedHttpMessage of(HttpStatus status, MediaType mediaType, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP response of the specifiedHttpStatus
.- Parameters:
mediaType
- theMediaType
of the response contentcontent
- the content of the responsetrailingHeaders
- the trailing HTTP headers
-
of
static AggregatedHttpMessage of(HttpHeaders headers)
Creates a new HTTP message with empty content.- Parameters:
headers
- the HTTP headers
-
of
static AggregatedHttpMessage of(HttpHeaders headers, HttpData content)
Creates a new HTTP message.- Parameters:
headers
- the HTTP headerscontent
- the content of the HTTP message
-
of
static AggregatedHttpMessage of(HttpHeaders headers, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP message.- Parameters:
headers
- the HTTP headerscontent
- the content of the HTTP messagetrailingHeaders
- the trailing HTTP headers
-
of
static AggregatedHttpMessage of(Iterable<HttpHeaders> informationals, HttpHeaders headers, HttpData content, HttpHeaders trailingHeaders)
Creates a new HTTP message.- Parameters:
informationals
- the informational class (1xx) HTTP headersheaders
- the HTTP headerscontent
- the content of the HTTP messagetrailingHeaders
- the trailing HTTP headers
-
informationals
List<HttpHeaders> informationals()
Returns the informational class (1xx) HTTP headers.
-
headers
HttpHeaders headers()
Returns the HTTP headers.
-
trailingHeaders
HttpHeaders trailingHeaders()
Returns the trailing HTTP headers.
-
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.
-
scheme
@Nullable default String scheme()
Returns theSCHEME
of this message.- Returns:
- the scheme, or
null
if there's no such header
-
method
@Nullable default HttpMethod method()
Returns theMETHOD
of this message.- Returns:
- the method, or
null
if there's no such header
-
path
@Nullable default String path()
Returns thePATH
of this message.- Returns:
- the path, or
null
if there's no such header
-
authority
@Nullable default String authority()
Returns theAUTHORITY
of this message, in the form of"hostname:port"
.- Returns:
- the authority, or
null
if there's no such header
-
status
@Nullable default HttpStatus status()
Returns theSTATUS
of this message.- Returns:
- the status, or
null
if there's no such header
-
contentType
@Nullable default MediaType contentType()
Returns the value of the'content-type'
header.- Returns:
- the valid header value if present.
null
otherwise.
-
toHttpRequest
@Deprecated default HttpRequest toHttpRequest()
Deprecated.Converts this message into a new completeHttpRequest
.
-
toHttpResponse
@Deprecated default HttpResponse toHttpResponse()
Deprecated.Converts this message into a new completeHttpResponse
.
-
-