B
- The Http body typepublic interface HttpResponse<B> extends HttpMessage<B>
Common interface for HTTP response implementations.
Modifier and Type | Method and Description |
---|---|
static <T> MutableHttpResponse<T> |
accepted()
Return an
HttpStatus.ACCEPTED response with an empty body. |
static <T> MutableHttpResponse<T> |
accepted(URI location)
Return an
HttpStatus.ACCEPTED response with an empty body and a HttpHeaders.LOCATION header. |
static <T> MutableHttpResponse<T> |
badRequest()
Return an
HttpStatus.BAD_REQUEST response with an empty body. |
static <T> MutableHttpResponse<T> |
badRequest(T body)
Return an
HttpStatus.BAD_REQUEST response with a body. |
default B |
body() |
default int |
code() |
static <T> MutableHttpResponse<T> |
created(T body)
Return an
HttpStatus.CREATED response with a body. |
static <T> MutableHttpResponse<T> |
created(T body,
URI location)
Return an
HttpStatus.CREATED response with a body and the location of the new resource. |
static <T> MutableHttpResponse<T> |
created(URI location)
Return an
HttpStatus.CREATED response with the location of the new resource. |
default Optional<Cookie> |
getCookie(String name)
Helper method for retrieving a single Cookie on a response.
|
default Cookies |
getCookies()
Helper method for retrieving all Cookies on a response.
|
HttpStatus |
getStatus() |
default String |
header(CharSequence name)
Return the first value for the given header or null.
|
static <T> MutableHttpResponse<T> |
noContent()
Return an
HttpStatus.NO_CONTENT response with an empty body. |
static <T> MutableHttpResponse<T> |
notAllowed(HttpMethod... allowed)
Return an
HttpStatus.METHOD_NOT_ALLOWED response with an empty body. |
static <T> MutableHttpResponse<T> |
notAllowed(Set<HttpMethod> allowed)
Return an
HttpStatus.METHOD_NOT_ALLOWED response with an empty body. |
static <T> MutableHttpResponse<T> |
notAllowedGeneric(Set<? extends CharSequence> allowed)
Return an
HttpStatus.METHOD_NOT_ALLOWED response with an empty body. |
static <T> MutableHttpResponse<T> |
notFound()
Return an
HttpStatus.NOT_FOUND response with an empty body. |
static <T> MutableHttpResponse<T> |
notFound(T body)
Return an
HttpStatus.NOT_FOUND response with a body. |
static <T> MutableHttpResponse<T> |
notModified()
Return an
HttpStatus.NOT_MODIFIED response with an empty body. |
static <T> MutableHttpResponse<T> |
ok()
Return an
HttpStatus.OK response with an empty body. |
static <T> MutableHttpResponse<T> |
ok(T body)
Return an
HttpStatus.OK response with a body. |
static <T> MutableHttpResponse<T> |
permanentRedirect(URI location)
Return an
HttpStatus.PERMANENT_REDIRECT response with the location of the new resource. |
default String |
reason() |
static <T> MutableHttpResponse<T> |
redirect(URI location)
Return an
HttpStatus.MOVED_PERMANENTLY response with the location of the new resource. |
static <T> MutableHttpResponse<T> |
seeOther(URI location)
Return an
HttpStatus.SEE_OTHER response with the location of the new resource. |
static <T> MutableHttpResponse<T> |
serverError()
Return an
HttpStatus.INTERNAL_SERVER_ERROR response with an empty body. |
static <T> MutableHttpResponse<T> |
serverError(T body)
Return an
HttpStatus.INTERNAL_SERVER_ERROR response with a body. |
default HttpResponse<B> |
setAttribute(CharSequence name,
Object value)
Sets an attribute on the message.
|
default HttpStatus |
status() |
static <T> MutableHttpResponse<T> |
status(HttpStatus status)
Return a response for the given status.
|
static <T> MutableHttpResponse<T> |
status(HttpStatus status,
String reason)
Return a response for the given status.
|
static <T> MutableHttpResponse<T> |
temporaryRedirect(URI location)
Return an
HttpStatus.TEMPORARY_REDIRECT response with the location of the new resource. |
static <T> MutableHttpResponse<T> |
unauthorized()
Return an
HttpStatus.UNAUTHORIZED response with an empty body. |
static <T> MutableHttpResponse<T> |
unprocessableEntity()
Return an
HttpStatus.UNPROCESSABLE_ENTITY response with an empty body. |
static URI |
uri(CharSequence uri)
Helper method for defining URIs.
|
getAttributes, getBody, getBody, getBody, getCharacterEncoding, getContentLength, getContentType, getHeaders, getLocale
removeAttribute
getAttribute, getAttribute
HttpStatus getStatus()
default HttpResponse<B> setAttribute(CharSequence name, Object value)
MutableAttributeHolder
setAttribute
in interface HttpMessage<B>
setAttribute
in interface MutableAttributeHolder
name
- The name of the attributevalue
- The value of the attribute@Nullable default String header(@Nullable CharSequence name)
name
- The namedefault HttpStatus status()
default int code()
default String reason()
static <T> MutableHttpResponse<T> ok()
HttpStatus.OK
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> notFound()
HttpStatus.NOT_FOUND
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> unauthorized()
HttpStatus.UNAUTHORIZED
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> notFound(T body)
HttpStatus.NOT_FOUND
response with a body.T
- The body typebody
- The response bodystatic <T> MutableHttpResponse<T> badRequest()
HttpStatus.BAD_REQUEST
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> badRequest(T body)
HttpStatus.BAD_REQUEST
response with a body.T
- The body typebody
- The response bodystatic <T> MutableHttpResponse<T> unprocessableEntity()
HttpStatus.UNPROCESSABLE_ENTITY
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> notAllowed(HttpMethod... allowed)
HttpStatus.METHOD_NOT_ALLOWED
response with an empty body.T
- The response typeallowed
- Allowed Http Methodsstatic <T> MutableHttpResponse<T> notAllowed(Set<HttpMethod> allowed)
HttpStatus.METHOD_NOT_ALLOWED
response with an empty body.T
- The response typeallowed
- Allowed Http Methodsstatic <T> MutableHttpResponse<T> notAllowedGeneric(Set<? extends CharSequence> allowed)
HttpStatus.METHOD_NOT_ALLOWED
response with an empty body.T
- The response typeallowed
- Allowed Http Methodsstatic <T> MutableHttpResponse<T> serverError()
HttpStatus.INTERNAL_SERVER_ERROR
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> serverError(T body)
HttpStatus.INTERNAL_SERVER_ERROR
response with a body.T
- The response typebody
- The response bodystatic <T> MutableHttpResponse<T> accepted()
HttpStatus.ACCEPTED
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> accepted(URI location)
HttpStatus.ACCEPTED
response with an empty body and a HttpHeaders.LOCATION
header.T
- The response typelocation
- the location in which the new resource will be availablestatic <T> MutableHttpResponse<T> noContent()
HttpStatus.NO_CONTENT
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> notModified()
HttpStatus.NOT_MODIFIED
response with an empty body.T
- The response typestatic <T> MutableHttpResponse<T> ok(T body)
HttpStatus.OK
response with a body.T
- The body typebody
- The response bodystatic <T> MutableHttpResponse<T> created(T body)
HttpStatus.CREATED
response with a body.T
- The body typebody
- The response bodystatic <T> MutableHttpResponse<T> created(URI location)
HttpStatus.CREATED
response with the location of the new resource.T
- The response typelocation
- The location of the new resourcestatic <T> MutableHttpResponse<T> created(T body, URI location)
HttpStatus.CREATED
response with a body and the location of the new resource.T
- The body typebody
- The response bodylocation
- The location of the new resourcestatic <T> MutableHttpResponse<T> seeOther(URI location)
HttpStatus.SEE_OTHER
response with the location of the new resource.T
- The response typelocation
- The location of the new resourcestatic <T> MutableHttpResponse<T> temporaryRedirect(URI location)
HttpStatus.TEMPORARY_REDIRECT
response with the location of the new resource.T
- The response typelocation
- The location of the new resourcestatic <T> MutableHttpResponse<T> permanentRedirect(URI location)
HttpStatus.PERMANENT_REDIRECT
response with the location of the new resource.T
- The response typelocation
- The location of the new resourcestatic <T> MutableHttpResponse<T> redirect(URI location)
HttpStatus.MOVED_PERMANENTLY
response with the location of the new resource.T
- The response typelocation
- The location of the new resourcestatic <T> MutableHttpResponse<T> status(HttpStatus status)
T
- The response typestatus
- The statusstatic <T> MutableHttpResponse<T> status(HttpStatus status, String reason)
T
- The response typestatus
- The statusreason
- An alternatively reason messagestatic URI uri(CharSequence uri)
uri
- The URI char sequencedefault Cookies getCookies()