@NotThreadSafe public class MockHttpServletResponse extends Object implements javax.servlet.http.HttpServletResponse
HttpServletResponse.| Modifier and Type | Field and Description |
|---|---|
static Charset |
DEFAULT_CHARSET_OBJ |
static int |
DEFAULT_SERVER_PORT |
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY| Constructor and Description |
|---|
MockHttpServletResponse() |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(javax.servlet.http.Cookie aCookie) |
void |
addDateHeader(String sName,
long nValue) |
void |
addHeader(String sName,
String sValue) |
void |
addIntHeader(String sName,
int nValue) |
boolean |
containsHeader(String sName) |
String |
encodeRedirectUrl(String sUrl)
Deprecated.
|
String |
encodeRedirectURL(String sUrl)
The default implementation returns the given URL String as-is.
|
String |
encodeUrl(String sUrl)
Deprecated.
|
String |
encodeURL(String sUrl)
The default implementation returns the given URL String as-is.
|
void |
flushBuffer() |
int |
getBufferSize() |
String |
getCharacterEncoding() |
Charset |
getCharacterEncodingObj() |
Charset |
getCharacterEncodingObjOrDefault() |
byte[] |
getContentAsByteArray() |
String |
getContentAsString(Charset aCharset) |
int |
getContentLength() |
String |
getContentType() |
javax.servlet.http.Cookie |
getCookie(String sName) |
javax.servlet.http.Cookie[] |
getCookies() |
String |
getEncodeRedirectUrlSuffix() |
String |
getEncodeUrlSuffix() |
String |
getErrorMessage() |
String |
getForwardedUrl() |
String |
getHeader(String sName)
Return the primary value for the given header, if any.
|
com.helger.commons.collection.impl.ICommonsSet<String> |
getHeaderNames()
Return the names of all specified headers as a Set of Strings.
|
com.helger.commons.collection.impl.ICommonsList<String> |
getHeaders(String sName)
Return all values for the given header as a List of value objects.
|
String |
getIncludedUrl() |
Locale |
getLocale() |
javax.servlet.ServletOutputStream |
getOutputStream() |
String |
getRedirectedUrl() |
int |
getStatus() |
PrintWriter |
getWriter() |
boolean |
isCommitted() |
boolean |
isOutputStreamAccessAllowed() |
boolean |
isWriterAccessAllowed() |
void |
reset() |
void |
resetBuffer() |
void |
sendError(int nStatus) |
void |
sendError(int nStatus,
String sErrorMessage) |
void |
sendRedirect(String sUrl) |
void |
setBufferSize(int nBufferSize) |
void |
setCharacterEncoding(Charset aCharacterEncoding) |
void |
setCharacterEncoding(String sCharacterEncoding) |
void |
setCommitted(boolean bCommitted) |
void |
setContentLength(int nContentLength) |
void |
setContentLengthLong(long len) |
void |
setContentType(String sContentType) |
void |
setDateHeader(String sName,
long nValue) |
void |
setEncodeRedirectUrlSuffix(String sEncodeRedirectUrlSuffix) |
void |
setEncodeUrlSuffix(String sEncodeUrlSuffix) |
void |
setForwardedUrl(String sForwardedUrl) |
void |
setHeader(String sName,
String sValue) |
void |
setIncludedUrl(String sIncludedUrl) |
void |
setIntHeader(String sName,
int nValue) |
void |
setLocale(Locale aLocale) |
void |
setOutputStreamAccessAllowed(boolean bOutputStreamAccessAllowed)
Set whether
getOutputStream() access is allowed. |
void |
setStatus(int nStatus) |
void |
setStatus(int nStatus,
String sErrorMessage)
Deprecated.
|
void |
setWriterAccessAllowed(boolean bWriterAccessAllowed)
Set whether
getWriter() access is allowed. |
public static final int DEFAULT_SERVER_PORT
public static final Charset DEFAULT_CHARSET_OBJ
public void setOutputStreamAccessAllowed(boolean bOutputStreamAccessAllowed)
getOutputStream() access is allowed.
Default is true.
bOutputStreamAccessAllowed - true to enabledpublic boolean isOutputStreamAccessAllowed()
getOutputStream() access is allowed.public void setWriterAccessAllowed(boolean bWriterAccessAllowed)
getWriter() access is allowed.
Default is true.
bWriterAccessAllowed - true to enabledpublic boolean isWriterAccessAllowed()
getOutputStream() access is allowed.public void setCharacterEncoding(@Nullable String sCharacterEncoding)
setCharacterEncoding in interface javax.servlet.ServletResponse@Nullable public String getCharacterEncoding()
getCharacterEncoding in interface javax.servlet.ServletResponse@Nonnull public javax.servlet.ServletOutputStream getOutputStream()
getOutputStream in interface javax.servlet.ServletResponse@Nonnull public PrintWriter getWriter()
getWriter in interface javax.servlet.ServletResponse@Nonnull @ReturnsMutableCopy public byte[] getContentAsByteArray()
public void setContentLength(int nContentLength)
setContentLength in interface javax.servlet.ServletResponsepublic int getContentLength()
public void setContentType(@Nullable String sContentType)
setContentType in interface javax.servlet.ServletResponse@Nullable public String getContentType()
getContentType in interface javax.servlet.ServletResponsepublic void setBufferSize(int nBufferSize)
setBufferSize in interface javax.servlet.ServletResponsepublic int getBufferSize()
getBufferSize in interface javax.servlet.ServletResponsepublic void flushBuffer()
flushBuffer in interface javax.servlet.ServletResponsepublic void resetBuffer()
resetBuffer in interface javax.servlet.ServletResponsepublic void setCommitted(boolean bCommitted)
public boolean isCommitted()
isCommitted in interface javax.servlet.ServletResponsepublic void reset()
reset in interface javax.servlet.ServletResponsepublic void setLocale(@Nullable Locale aLocale)
setLocale in interface javax.servlet.ServletResponse@Nullable public Locale getLocale()
getLocale in interface javax.servlet.ServletResponsepublic void addCookie(@Nonnull javax.servlet.http.Cookie aCookie)
addCookie in interface javax.servlet.http.HttpServletResponse@Nonnull @ReturnsMutableCopy public javax.servlet.http.Cookie[] getCookies()
public boolean containsHeader(@Nullable String sName)
containsHeader in interface javax.servlet.http.HttpServletResponse@Nonnull @ReturnsMutableCopy public com.helger.commons.collection.impl.ICommonsSet<String> getHeaderNames()
getHeaderNames in interface javax.servlet.http.HttpServletResponseSet of header name Strings, or an
empty Set if none@Nullable public String getHeader(@Nullable String sName)
Will return the first value in case of multiple values.
getHeader in interface javax.servlet.http.HttpServletResponsesName - the name of the headernull if none@Nonnull public com.helger.commons.collection.impl.ICommonsList<String> getHeaders(@Nullable String sName)
getHeaders in interface javax.servlet.http.HttpServletResponsesName - the name of the header@Nullable public String encodeURL(@Nullable String sUrl)
setEncodeUrlSuffix(String) to define a suffix to be appended.encodeURL in interface javax.servlet.http.HttpServletResponse@Nullable public String encodeRedirectURL(@Nullable String sUrl)
setEncodeRedirectUrlSuffix(String) to define a suffix to be
appended.encodeRedirectURL in interface javax.servlet.http.HttpServletResponse@Deprecated public String encodeUrl(@Nullable String sUrl)
encodeUrl in interface javax.servlet.http.HttpServletResponse@Deprecated public String encodeRedirectUrl(@Nullable String sUrl)
encodeRedirectUrl in interface javax.servlet.http.HttpServletResponsepublic void sendError(int nStatus,
@Nullable
String sErrorMessage)
throws IOException
sendError in interface javax.servlet.http.HttpServletResponseIOExceptionpublic void sendError(int nStatus)
throws IOException
sendError in interface javax.servlet.http.HttpServletResponseIOExceptionpublic void sendRedirect(@Nonnull String sUrl) throws IOException
sendRedirect in interface javax.servlet.http.HttpServletResponseIOExceptionpublic void setDateHeader(@Nullable String sName, long nValue)
setDateHeader in interface javax.servlet.http.HttpServletResponsepublic void addDateHeader(@Nullable String sName, long nValue)
addDateHeader in interface javax.servlet.http.HttpServletResponsepublic void setHeader(@Nullable String sName, @Nullable String sValue)
setHeader in interface javax.servlet.http.HttpServletResponsepublic void addHeader(@Nullable String sName, @Nullable String sValue)
addHeader in interface javax.servlet.http.HttpServletResponsepublic void setIntHeader(@Nullable String sName, int nValue)
setIntHeader in interface javax.servlet.http.HttpServletResponsepublic void addIntHeader(@Nullable String sName, int nValue)
addIntHeader in interface javax.servlet.http.HttpServletResponsepublic void setStatus(int nStatus)
setStatus in interface javax.servlet.http.HttpServletResponse@Deprecated public void setStatus(int nStatus, @Nullable String sErrorMessage)
setStatus in interface javax.servlet.http.HttpServletResponsepublic int getStatus()
getStatus in interface javax.servlet.http.HttpServletResponsepublic void setEncodeRedirectUrlSuffix(@Nullable String sEncodeRedirectUrlSuffix)
public void setContentLengthLong(long len)
setContentLengthLong in interface javax.servlet.ServletResponseCopyright © 2016–2019 Philip Helger. All rights reserved.