@Immutable public final class ResponseHelper extends Object
HttpServletResponse objects.UnifiedResponse for easy and consistent HTTP
response handling.| Modifier and Type | Method and Description |
|---|---|
static void |
finishReponseOutputStream(OutputStream aOS) |
static OutputStream |
getBestSuitableOutputStream(javax.servlet.http.HttpServletRequest aHttpRequest,
javax.servlet.http.HttpServletResponse aHttpResponse)
Get the best suitable output stream for the given combination of request and
response.
|
static EResponseStreamType |
getBestSuitableOutputStreamType(javax.servlet.http.HttpServletRequest aHttpRequest)
Determine the best suitable output stream type for the given request without
actually modifying response data.
|
static com.helger.commons.http.HttpHeaderMap |
getResponseHeaderMap(javax.servlet.http.HttpServletResponse aHttpResponse)
Get a complete response header map as a copy.
|
static boolean |
isEmptyStatusCode(int nSC) |
static void |
setContentLength(javax.servlet.http.HttpServletResponse aHttpResponse,
long nContentLength)
Set the content length of an HTTP response.
|
@Nonnull public static EResponseStreamType getBestSuitableOutputStreamType(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest)
EResponseStreamType.GZIP, if the request supports deflate or
compress, the result will be a EResponseStreamType.DEFLATE. If none
of that matches, the regular value EResponseStreamType.PLAIN will be
returned.aHttpRequest - requestnull.ResponseHelperSettings@Nonnull public static OutputStream getBestSuitableOutputStream(@Nonnull javax.servlet.http.HttpServletRequest aHttpRequest, @Nonnull javax.servlet.http.HttpServletResponse aHttpResponse) throws IOException
GZIPOutputStream, if the request supports deflate or compress, the
result will be a ZipOutputStream. If none of that matches, the
regular response output stream is usedaHttpRequest - requestaHttpResponse - ResponseIOException - In case of IO errorResponseHelperSettingspublic static void finishReponseOutputStream(@Nonnull OutputStream aOS) throws IOException
IOExceptionpublic static boolean isEmptyStatusCode(int nSC)
public static void setContentLength(@Nonnull javax.servlet.http.HttpServletResponse aHttpResponse, @Nonnegative long nContentLength)
aHttpResponse.setContentLength is invoked, else
the HTTP header CHttpHeader.CONTENT_LENGTH is set manually.aHttpResponse - The response to set the content length tonContentLength - The content length to set@Nonnull @ReturnsMutableCopy public static com.helger.commons.http.HttpHeaderMap getResponseHeaderMap(@Nonnull javax.servlet.http.HttpServletResponse aHttpResponse)
aHttpResponse - The source HTTP response. May not be null.null.Copyright © 2016–2019 Philip Helger. All rights reserved.