| java.lang.Object com.meterware.servletunit.ServletUnitHttpResponse
Method Summary | |
public void | addCookie(Cookie cookie) Adds the specified cookie to the response. | public void | addDateHeader(String name, long value) Adds a response header with the given name and value. | public void | addHeader(String name, String value) Adds a response header with the given name and value. | public void | addIntHeader(String name, int value) Adds a response header with the given name and value. | public boolean | containsHeader(String name) Checks whether the response message header has a field with
the specified name. | public String | encodeRedirectURL(String url) Encodes the specified URL for use in the
sendRedirect method or, if encoding is not needed,
returns the URL unchanged. | public String | encodeRedirectUrl(String url) | public String | encodeURL(String url) Encodes the specified URL by including the session ID in it,
or, if encoding is not needed, returns the URL unchanged. | public String | encodeUrl(String url) | public void | flushBuffer() Forces any content in the buffer to be written to the client. | public int | getBufferSize() Returns the actual buffer size used for the response. | public String | getCharacterEncoding() Returns the name of the character set encoding used for
the MIME body sent by this response. | public String | getContentType() Returns the content type defined for this response. | byte[] | getContents() Returns the contents of this response. | String | getHeaderField(String name) Returns the headers defined for this response. | public String[] | getHeaderFieldNames() | public String[] | getHeaderFields(String name) Return an array of all the header values associated with the
specified header name, or an zero-length array if there are no such
header values. | public Locale | getLocale() Returns the locale assigned to the response. | String | getMessage() Returns the message associated with this response's status. | public ServletOutputStream | getOutputStream() Returns a
ServletOutputStream suitable for writing binary
data in the response. | int | getStatus() Returns the status of this response. | public PrintWriter | getWriter() Returns a PrintWriter object that you
can use to send character text to the client. | public boolean | isCommitted() Returns a boolean indicating if the response has been committed. | public void | reset() Clears any data that exists in the buffer as well as the status code and headers. | public void | resetBuffer() Clears the content of the underlying buffer in the response without clearing headers or status code. | public void | sendError(int sc) Sends an error response to the client using the specified status
code and descriptive message. | public void | sendError(int sc, String msg) Sends an error response to the client using the specified status
code and descriptive message. | public void | sendRedirect(String location) Sends a temporary redirect response to the client using the
specified redirect location URL. | public void | setBufferSize(int size) Sets the preferred buffer size for the body of the response. | public void | setCharacterEncoding(String string) | public void | setContentLength(int len) Sets the length of the content the server returns
to the client. | public void | setContentType(String type) Sets the content type of the response the server sends to
the client. | public void | setDateHeader(String name, long date) Adds a field to the response header with the given name and
date-valued field. | public void | setHeader(String name, String value) Adds a field to the response header with the given name and value.
If the field had already been set, the new value overwrites the
previous one. | public void | setIntHeader(String name, int value) Adds a field to the response header with the given name and
integer value. | public void | setLocale(Locale locale) Sets the locale of the response, setting the headers (including the Content-Type's charset)
as appropriate. | public void | setStatus(int sc) Sets the status code for this response. | public void | setStatus(int sc, String msg) |
addCookie | public void addCookie(Cookie cookie)(Code) | | Adds the specified cookie to the response. It can be called
multiple times to set more than one cookie.
|
addDateHeader | public void addDateHeader(String name, long value)(Code) | | Adds a response header with the given name and value. This method allows response headers to have multiple values.
|
addHeader | public void addHeader(String name, String value)(Code) | | Adds a response header with the given name and value. This method allows response headers to have multiple values.
|
addIntHeader | public void addIntHeader(String name, int value)(Code) | | Adds a response header with the given name and value. This method allows response headers to have multiple values.
|
containsHeader | public boolean containsHeader(String name)(Code) | | Checks whether the response message header has a field with
the specified name.
|
encodeRedirectURL | public String encodeRedirectURL(String url)(Code) | | Encodes the specified URL for use in the
sendRedirect method or, if encoding is not needed,
returns the URL unchanged. The implementation of this method
should include the logic to determine whether the session ID
needs to be encoded in the URL. Because the rules for making
this determination differ from those used to decide whether to
encode a normal link, this method is seperate from the
encodeUrl method.
|
encodeURL | public String encodeURL(String url)(Code) | | Encodes the specified URL by including the session ID in it,
or, if encoding is not needed, returns the URL unchanged.
The implementation of this method should include the logic to
determine whether the session ID needs to be encoded in the URL.
For example, if the browser supports cookies, or session
tracking is turned off, URL encoding is unnecessary.
|
flushBuffer | public void flushBuffer() throws IOException(Code) | | Forces any content in the buffer to be written to the client. A call to this method automatically
commits the response, meaning the status code and headers will be written.
|
getBufferSize | public int getBufferSize()(Code) | | Returns the actual buffer size used for the response. If no buffering is used, this method returns 0.
|
getCharacterEncoding | public String getCharacterEncoding()(Code) | | Returns the name of the character set encoding used for
the MIME body sent by this response.
|
getContentType | public String getContentType()(Code) | | Returns the content type defined for this response.
|
getContents | byte[] getContents()(Code) | | Returns the contents of this response.
|
getHeaderField | String getHeaderField(String name)(Code) | | Returns the headers defined for this response.
|
getHeaderFieldNames | public String[] getHeaderFieldNames()(Code) | | |
getHeaderFields | public String[] getHeaderFields(String name)(Code) | | Return an array of all the header values associated with the
specified header name, or an zero-length array if there are no such
header values.
Parameters: name - Header name to look up |
getLocale | public Locale getLocale()(Code) | | Returns the locale assigned to the response.
|
getMessage | String getMessage()(Code) | | Returns the message associated with this response's status.
|
getStatus | int getStatus()(Code) | | Returns the status of this response.
|
isCommitted | public boolean isCommitted()(Code) | | Returns a boolean indicating if the response has been committed. A committed response has
already had its status code and headers written.
|
reset | public void reset()(Code) | | Clears any data that exists in the buffer as well as the status code and headers.
If the response has been committed, this method throws an IllegalStateException.
|
resetBuffer | public void resetBuffer()(Code) | | Clears the content of the underlying buffer in the response without clearing headers or status code.
If the response has been committed, this method throws an IllegalStateException.
since: 1.3 |
sendError | public void sendError(int sc) throws IOException(Code) | | Sends an error response to the client using the specified status
code and descriptive message. If setStatus has previously been
called, it is reset to the error status code. The message is
sent as the body of an HTML page, which is returned to the user
to describe the problem. The page is sent with a default HTML
header; the message is enclosed in simple body tags
(<body></body>).
|
sendError | public void sendError(int sc, String msg) throws IOException(Code) | | Sends an error response to the client using the specified status
code and descriptive message. If setStatus has previously been
called, it is reset to the error status code. The message is
sent as the body of an HTML page, which is returned to the user
to describe the problem. The page is sent with a default HTML
header; the message is enclosed in simple body tags
(<body></body>).
|
sendRedirect | public void sendRedirect(String location) throws IOException(Code) | | Sends a temporary redirect response to the client using the
specified redirect location URL. The URL must be absolute (for
example, https://hostname/path/file.html ).
Relative URLs are not permitted here.
|
setBufferSize | public void setBufferSize(int size)(Code) | | Sets the preferred buffer size for the body of the response. The servlet container
will use a buffer at least as large as the size requested. The actual buffer size
used can be found using getBufferSize.
|
setCharacterEncoding | public void setCharacterEncoding(String string)(Code) | | |
setContentLength | public void setContentLength(int len)(Code) | | Sets the length of the content the server returns
to the client. In HTTP servlets, this method sets the
HTTP Content-Length header.
|
setContentType | public void setContentType(String type)(Code) | | Sets the content type of the response the server sends to
the client. The content type may include the type of character
encoding used, for example, text/html; charset=ISO-8859-4 .
You can only use this method once, and you should call it
before you obtain a PrintWriter or
ServletOutputStream object to return a response.
|
setDateHeader | public void setDateHeader(String name, long date)(Code) | | Adds a field to the response header with the given name and
date-valued field. The date is specified in terms of
milliseconds since the epoch. If the date field had already
been set, the new value overwrites the previous one. The
containsHeader method can be used to test for the
presence of a header before setting its value.
|
setHeader | public void setHeader(String name, String value)(Code) | | Adds a field to the response header with the given name and value.
If the field had already been set, the new value overwrites the
previous one. The containsHeader method can be
used to test for the presence of a header before setting its
value.
|
setIntHeader | public void setIntHeader(String name, int value)(Code) | | Adds a field to the response header with the given name and
integer value. If the field had already been set, the new value
overwrites the previous one. The containsHeader
method can be used to test for the presence of a header before
setting its value.
|
setLocale | public void setLocale(Locale locale)(Code) | | Sets the locale of the response, setting the headers (including the Content-Type's charset)
as appropriate. This method should be called before a call to getWriter().
By default, the response locale is the default locale for the server.
|
setStatus | public void setStatus(int sc)(Code) | | Sets the status code for this response. This method is used to
set the return status code when there is no error (for example,
for the status codes SC_OK or SC_MOVED_TEMPORARILY). If there
is an error, the sendError method should be used
instead.
|
|
|