HydraExpress 4.6 |
HydraExpress C++ API Reference Guide |
|
Represents the response object that the servlet returns to the client. More...
#include <rwsf/servlet/http/HttpServletResponse.h>
rwsf::HttpServletResponse provides an HTTP-specific response object and provides a method for accessing HTTP-specific functionality, such as cookies and HTTP headers. For each request from a client, an HTTP servlet receives an instance of rwsf::HttpServletReponse that represents the response to the request.
StatusCode provides an enumeration over common HTTP status codes.
virtual rwsf::HttpServletResponse::~HttpServletResponse | ( | ) | [virtual] |
Destructor.
void rwsf::HttpServletResponse::addCookie | ( | const rwsf::Cookie & | cookie | ) |
Adds cookie to the collection of cookies in the response.
void rwsf::HttpServletResponse::addDateHeader | ( | const std::string & | name, | |
const rwsf::DateTime & | date | |||
) |
Adds the value of date to the header named by name in this response. If no header matching name exists, creates a new header. Otherwise, appends the value of date to the list of values in the header. Header name comparisons are case-insensitive.
void rwsf::HttpServletResponse::addHeader | ( | const std::string & | name, | |
const std::string & | value | |||
) |
Adds value to the header named by name in this response. If no header matching name exists, creates a new header. Otherwise, appends value to the list of values in the header. Header name comparisons are case-insensitive.
void rwsf::HttpServletResponse::addIntHeader | ( | const std::string & | name, | |
int | value | |||
) |
Adds value to the header named by name in this response. If no header matching name exists, creates a new header. Otherwise, appends value to the list of values in the first matching header. Header name comparisons are case-insensitive.
bool rwsf::HttpServletResponse::checkSpecialHeader | ( | const std::string & | name, | |
const std::string & | value | |||
) | [private] |
Sets internal fields for special header names. Called from setHeader() or addHeader(). Returns true
if the header is special and there is no need to set the header.
bool rwsf::HttpServletResponse::containsHeader | ( | const std::string & | name | ) | const |
Returns true
if the response contains an HTTP header matching name, false
otherwise. Header name comparisons are case- insensitive.
std::string rwsf::HttpServletResponse::encodeRedirectURL | ( | const std::string & | url | ) | const |
Returns url encoded as necessary to preserve session information for a redirect. If the servlet uses session tracking, a location provided to sendRedirect() should be encoded using this function.
std::string rwsf::HttpServletResponse::encodeURL | ( | const std::string & | url | ) | const |
Returns url encoded as necessary to preserve session information. If the servlet uses session tracking, any URLs returned to the client should be encoded using this function.
std::string rwsf::HttpServletResponse::getCharacterEncoding | ( | ) | const |
Returns the character set specified in the Content-Type
of the response, or 8859_1
if the Content-Type
contains no character set information.
int rwsf::HttpServletResponse::getContentLength | ( | ) | const |
Returns the value set by setContentLength(), or -1
if no value is set.
std::string rwsf::HttpServletResponse::getContentType | ( | ) | const |
Returns the value of the Content-Type
header of this response. If self contains no Content-Type
header, returns the empty string. Header name comparisons are case-insensitive.
std::string rwsf::HttpServletResponse::getDateString | ( | const rwsf::DateTime & | date | ) | const [private] |
Converts the rwsf::DateTime represented by date to an std::string.
bool rwsf::HttpServletResponse::isEncodeable | ( | const std::string & | url | ) | const [private] |
Returns true
if the URL denoted by url can be encoded, false
otherwise.
void rwsf::HttpServletResponse::sendError | ( | int | sc | ) |
Sends an error to the client with the status code sc. Clears the contents of this response before sending the error. If the context web.xml
file defines an error-page
for sc, the Agent forwards the error to that resource. Otherwise, if the global web.xml
file defines an error-page
for sc, the Agent forwards the request to the global page. If neither file defines an error-page
for sc, returns the error directly to the client.
void rwsf::HttpServletResponse::sendError | ( | int | sc, | |
const std::string & | msg | |||
) |
Sends an error to the client with the status code sc and the message msg. If the context web.xml
file defines an error-page
for sc, the Agent forwards the error to that page. Otherwise, if the global web.xml
file defines an error-page
for sc, the Agent forwards the request to the global page. If neither file defines an error-page
for sc, returns the error directly to the client with msg as a payload.
void rwsf::HttpServletResponse::sendRedirect | ( | const std::string & | location | ) |
Redirects the client to location, using SC_MOVED_TEMPORARILY
as the redirect status code. If location is a relative URL, the Agent modifies the URL to be a fully qualified URL. If the servlet uses session tracking, encode the location using the encodeRedirectURL() function before providing the location to this function.
virtual void rwsf::HttpServletResponse::setContentLength | ( | int | contentLength | ) | [virtual] |
Sets the value of the Content-Length
header of the response to contentLength.
Reimplemented from rwsf::ServletResponse.
void rwsf::HttpServletResponse::setContentType | ( | const std::string & | contentType | ) | [virtual] |
Sets the value of the Content-Type
header of the response to contentType. This function is an extension to the Servlet Specification.
Reimplemented from rwsf::ServletResponse.
void rwsf::HttpServletResponse::setDateHeader | ( | const std::string & | name, | |
const rwsf::DateTime & | date | |||
) |
Sets the header named by name to the value of date, replacing any previous header value. If no header matching name exists, creates a new header. Header name comparisons are case-insensitive.
void rwsf::HttpServletResponse::setHeader | ( | const std::string & | name, | |
const std::string & | value | |||
) |
Sets the header named by name to value, replacing any previous header value. If no header matching name exists, creates a new header. Header name comparisons are case-insensitive.
void rwsf::HttpServletResponse::setIntHeader | ( | const std::string & | name, | |
int | value | |||
) |
Sets the header named by name to value, replacing any previous header value. If no header matching name exists, creates a new header. Header name comparisons are case-insensitive.
void rwsf::HttpServletResponse::setStatus | ( | int | sc, | |
const std::string & | msg | |||
) |
Sets the HTTP status code of this response to sc, and sets the status message of this response to msg. Note that the Servlet Specification deprecates this mehtod. The Servlet Specification recommends the sendError() method to return an error to the client and the setStatus(int) method to set the status code on responses that do not indicate an error.
void rwsf::HttpServletResponse::setStatus | ( | int | sc | ) |
Sets the HTTP status code for this response to sc. Use this function for a status that does not indicate an error. Use the sendError() methods for error responses.
std::string rwsf::HttpServletResponse::toEncoded | ( | const std::string & | url, | |
const std::string & | sessionId | |||
) | const [private] |
Returns an encoded url for a given session sessionId of a given url.
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo are registered trademarks of Rogue Wave Software, and HydraExpress is a trademark of Rogue Wave Software. All other trademarks are the property of their respective owners.