CPPSERV


Home Projects Jobs Clientele Contact
CPPSERV Documentation Download TODO Mailing lists Bug tracker News RSS Feed Browse source

servlet::NoBodyResponse Class Reference

#include <NoBodyResponse.h>

Inheritance diagram for servlet::NoBodyResponse:
Collaboration diagram for servlet::NoBodyResponse:

List of all members.


Public Member Functions

virtual void setContentLength (int len)
virtual void setCharacterEncoding (const std::string &charset)
virtual void setContentType (const std::string &type)
virtual std::string getContentType ()
virtual std::ostream & getOutputStream ()
virtual std::string getCharacterEncoding ()
virtual void setBufferSize (int size)
virtual int getBufferSize ()
virtual void reset ()
virtual bool isCommitted ()
virtual void flushBuffer ()
virtual void addCookie (const Cookie &cookie)
virtual bool containsHeader (const std::string &name) const
virtual void setStatus (int sc)
virtual void setHeader (const std::string &name, const std::string &value)
virtual void setIntHeader (const std::string &name, int value)
virtual void setDateHeader (const std::string &name, long date)
virtual void sendError (int sc, const std::string &msg)
virtual void sendError (int sc)
virtual void sendRedirect (const std::string &location)
virtual std::string encodeURL (const std::string &url)
virtual std::string encodeRedirectURL (const std::string &url)
virtual void addHeader (const std::string &name, const std::string &value)
virtual void addDateHeader (const std::string &name, long date)
virtual void addIntHeader (const std::string &name, int value)

Private Member Functions

 NoBodyResponse (HttpServletResponse &r)
virtual ~NoBodyResponse ()
void setContentLength ()

Private Attributes

HttpServletResponseresp
onobodystream no_body
bool didSetContentLength

Friends

class HttpServlet

Detailed Description

Definition at line 73 of file NoBodyResponse.h.


Constructor & Destructor Documentation

servlet::NoBodyResponse::NoBodyResponse ( HttpServletResponse r  )  [private]

Definition at line 60 of file NoBodyResponse.cpp.

virtual servlet::NoBodyResponse::~NoBodyResponse (  )  [inline, private, virtual]

Definition at line 79 of file NoBodyResponse.h.


Member Function Documentation

void servlet::NoBodyResponse::addCookie ( const Cookie cookie  )  [virtual]

Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.

Parameters:
cookie the Cookie to return to the client

Implements servlet::HttpServletResponse.

Definition at line 165 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::addCookie(), and resp.

Here is the call graph for this function:

void servlet::NoBodyResponse::addDateHeader ( const std::string &  name,
long  date 
) [virtual]

Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. This method allows response headers to have multiple values.

Parameters:
name the name of the header to set
date the additional date value
See also:
setDateHeader

Implements servlet::HttpServletResponse.

Definition at line 249 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::addDateHeader(), and resp.

Here is the call graph for this function:

void servlet::NoBodyResponse::addHeader ( const std::string &  name,
const std::string &  value 
) [virtual]

Adds a response header with the given name and value. This method allows response headers to have multiple values.

Parameters:
name the name of the header
value the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
See also:
setHeader

Implements servlet::HttpServletResponse.

Definition at line 242 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::addHeader(), and resp.

Here is the call graph for this function:

void servlet::NoBodyResponse::addIntHeader ( const std::string &  name,
int  value 
) [virtual]

Adds a response header with the given name and integer value. This method allows response headers to have multiple values.

Parameters:
name the name of the header
value the assigned integer value
See also:
setIntHeader

Implements servlet::HttpServletResponse.

Definition at line 256 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::addIntHeader(), and resp.

Here is the call graph for this function:

bool servlet::NoBodyResponse::containsHeader ( const std::string &  name  )  const [virtual]

Returns a boolean indicating whether the named response header has already been set.

Parameters:
name the header name
Returns:
true if the named response header has already been set; false otherwise

Implements servlet::HttpServletResponse.

Definition at line 172 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::containsHeader(), and resp.

Here is the call graph for this function:

std::string servlet::NoBodyResponse::encodeRedirectURL ( const std::string &  url  )  [virtual]

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 includes the logic to determine whether the session ID needs to be encoded in the URL. Because the rules for making this determination can differ from those used to decide whether to encode a normal link, this method is separated from the encodeURL method.

All URLs sent to the HttpServletResponse.sendRedirect method should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

Parameters:
url the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.
See also:
sendRedirect

encodeURL

Implements servlet::HttpServletResponse.

Definition at line 235 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::encodeRedirectURL(), and resp.

Here is the call graph for this function:

std::string servlet::NoBodyResponse::encodeURL ( const std::string &  url  )  [virtual]

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 includes 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.

For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.

Parameters:
url the url to be encoded.
Returns:
the encoded URL if encoding is needed; the unchanged URL otherwise.

Implements servlet::HttpServletResponse.

Definition at line 228 of file NoBodyResponse.cpp.

References servlet::HttpServletResponse::encodeURL(), and resp.

Here is the call graph for this function:

void servlet::NoBodyResponse::flushBuffer (  )  [virtual]

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.

See also:
setBufferSize

getBufferSize

isCommitted

reset

Implements servlet::ServletResponse.

Definition at line 146 of file NoBodyResponse.cpp.

References servlet::ServletResponse::flushBuffer(), and resp.

Here is the call graph for this function:

int servlet::NoBodyResponse::getBufferSize (  )  [virtual]

Returns the actual buffer size used for the response. If no buffering is used, this method returns 0.

Returns:
the actual buffer size used
See also:
setBufferSize

flushBuffer

isCommitted

reset

Implements servlet::ServletResponse.

Definition at line 125 of file NoBodyResponse.cpp.

References servlet::ServletResponse::getBufferSize(), and resp.

Here is the call graph for this function:

std::string servlet::NoBodyResponse::getCharacterEncoding (  )  [virtual]

Returns the name of the character encoding (MIME charset) used for the body sent in this response. The character encoding may have been specified explicitly using the setCharacterEncoding or setContentType methods, or implicitly using the setLocale method. Explicit specifications take precedence over implicit specifications. Calls made to these methods after getWriter has been called or after the response has been committed have no effect on the character encoding. If no character encoding has been specified, ISO-8859-1 is returned.

See RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) for more information about character encoding and MIME.

Returns:
a String specifying the name of the character encoding, for example, UTF-8

Implements servlet::ServletResponse.

Definition at line 111 of file NoBodyResponse.cpp.

References servlet::ServletResponse::getCharacterEncoding(), and resp.

Here is the call graph for this function:

std::string servlet::NoBodyResponse::getContentType (  )  [virtual]

Returns the content type used for the MIME body sent in this response. The content type proper must have been specified using setContentType before the response is committed. If no content type has been specified, this method returns null. If a content type has been specified and a character encoding has been explicitly or implicitly specified as described in getCharacterEncoding, the charset parameter is included in the string returned. If no character encoding has been specified, the charset parameter is omitted.

Returns:
a String specifying the content type, for example, text/html; charset=UTF-8, or null
Since:
2.4

Implements servlet::ServletResponse.

Definition at line 97 of file NoBodyResponse.cpp.

References servlet::ServletResponse::getContentType(), and resp.

Here is the call graph for this function:

std::ostream & servlet::NoBodyResponse::getOutputStream (  )  [virtual]

Returns a std::ostream suitable for writing binary data in the response. The servlet container does not encode the binary data.

Calling flush() on the output stream commits the response.

Either this method or getWriter may be called to write the body, not both.

Returns:
a std::ostream for writing binary data
Exceptions:
IllegalStateException if the getWriter method has been called on this response
IOException if an input or output exception occurred
See also:
getWriter

Implements servlet::ServletResponse.

Definition at line 104 of file NoBodyResponse.cpp.

References no_body.

bool servlet::NoBodyResponse::isCommitted (  )  [virtual]

Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.

Returns:
a boolean indicating if the response has been committed
See also:
setBufferSize

getBufferSize

flushBuffer

reset

Implements servlet::ServletResponse.

Definition at line 139 of file NoBodyResponse.cpp.

References servlet::ServletResponse::isCommitted(), and resp.

Here is the call graph for this function:

void servlet::NoBodyResponse::reset (  )  [virtual]

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.

Exceptions:
IllegalStateException if the response has already been committed
See also:
setBufferSize

getBufferSize

flushBuffer

isCommitted

Implements servlet::ServletResponse.

Definition at line 132 of file NoBodyResponse.cpp.

References servlet::ServletResponse::reset(), and resp.

Here is the call graph for this function:

void servlet::NoBodyResponse::sendError ( int  sc  )  [virtual]

Sends an error response to the client using the specified status code and clearing the buffer.

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters:
sc the error status code
Exceptions:
IOException If an input or output exception occurs
IllegalStateException If the response was committed before this method call

Implements servlet::HttpServletResponse.

Definition at line 214 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::sendError().

Here is the call graph for this function:

void servlet::NoBodyResponse::sendError ( int  sc,
const std::string &  msg 
) [virtual]

Sends an error response to the client using the specified status. The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html", leaving cookies and other headers unmodified.

If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter.

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters:
sc the error status code
msg the descriptive message
Exceptions:
IOException If an input or output exception occurs
IllegalStateException If the response was committed

Implements servlet::HttpServletResponse.

Definition at line 207 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::sendError().

Here is the call graph for this function:

void servlet::NoBodyResponse::sendRedirect ( const std::string &  location  )  [virtual]

Sends a temporary redirect response to the client using the specified redirect location URL. This method can accept relative URLs; the servlet container must convert the relative URL to an absolute URL before sending the response to the client. If the location is relative without a leading '/' the container interprets it as relative to the current request URI. If the location is relative with a leading '/' the container interprets it as relative to the servlet container root.

If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.

Parameters:
location the redirect location URL
Exceptions:
IOException If an input or output exception occurs
IllegalStateException If the response was committed or if a partial URL is given and cannot be converted into a valid URL

Implements servlet::HttpServletResponse.

Definition at line 221 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::sendRedirect().

Here is the call graph for this function:

void servlet::NoBodyResponse::setBufferSize ( int  size  )  [virtual]

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.

A larger buffer allows more content to be written before anything is actually sent, thus providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.

This method must be called before any response body content is written; if content has been written or the response object has been committed, this method throws an IllegalStateException.

Parameters:
size the preferred buffer size
Exceptions:
IllegalStateException if this method is called after content has been written
See also:
getBufferSize

flushBuffer

isCommitted

reset

Implements servlet::ServletResponse.

Definition at line 118 of file NoBodyResponse.cpp.

References resp, and servlet::ServletResponse::setBufferSize().

Here is the call graph for this function:

void servlet::NoBodyResponse::setCharacterEncoding ( const std::string &  charset  )  [virtual]

Sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8. If the character encoding has already been set by setContentType or setLocale, this method overrides it. Calling setContentType with the String of text/html and calling this method with the String of UTF-8 is equivalent with calling setContentType with the String of text/html; charset=UTF-8.

This method can be called repeatedly to change the character encoding. This method has no effect if it is called after getWriter has been called or after the response has been committed.

Containers must communicate the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the character encoding is communicated as part of the Content-Type header for text media types. Note that the character encoding cannot be communicated via HTTP headers if the servlet does not specify a content type; however, it is still used to encode text written via the servlet response's writer.

Parameters:
charset a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
See also:
setContentType setLocale
Since:
2.4

Implements servlet::ServletResponse.

Definition at line 83 of file NoBodyResponse.cpp.

References resp, and servlet::ServletResponse::setCharacterEncoding().

Here is the call graph for this function:

void servlet::NoBodyResponse::setContentLength ( int  len  )  [virtual]

Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.

Parameters:
len an integer specifying the length of the content being returned to the client; sets the Content-Length header

Implements servlet::ServletResponse.

Definition at line 75 of file NoBodyResponse.cpp.

References didSetContentLength, resp, and servlet::ServletResponse::setContentLength().

Here is the call graph for this function:

void servlet::NoBodyResponse::setContentLength (  )  [private]

Definition at line 67 of file NoBodyResponse.cpp.

References didSetContentLength, servlet::onobodystream::get_context_length(), no_body, resp, and servlet::ServletResponse::setContentLength().

Referenced by servlet::HttpServlet::doHead().

Here is the call graph for this function:

void servlet::NoBodyResponse::setContentType ( const std::string &  type  )  [virtual]

Sets the content type of the response being sent to the client, if the response has not been committed yet. The given content type may include a character encoding specification, for example, text/html;charset=UTF-8. The response's character encoding is only set from the given content type if this method is called before getWriter is called.

This method may be called repeatedly to change content type and character encoding. This method has no effect if called after the response has been committed. It does not set the response's character encoding if it is called after getWriter has been called or after the response has been committed.

Containers must communicate the content type and the character encoding used for the servlet response's writer to the client if the protocol provides a way for doing so. In the case of HTTP, the Content-Type header is used.

Parameters:
type a String specifying the MIME type of the content
See also:
setLocale

setCharacterEncoding

getOutputStream

getWriter

Implements servlet::ServletResponse.

Definition at line 90 of file NoBodyResponse.cpp.

References resp, and servlet::ServletResponse::setContentType().

Here is the call graph for this function:

void servlet::NoBodyResponse::setDateHeader ( const std::string &  name,
long  date 
) [virtual]

Sets a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. If the header 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.

Parameters:
name the name of the header to set
date the assigned date value
See also:
containsHeader

addDateHeader

Implements servlet::HttpServletResponse.

Definition at line 200 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::setDateHeader().

Here is the call graph for this function:

void servlet::NoBodyResponse::setHeader ( const std::string &  name,
const std::string &  value 
) [virtual]

Sets a response header with the given name and value. If the header 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.

Parameters:
name the name of the header
value the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
See also:
containsHeader

addHeader

Implements servlet::HttpServletResponse.

Definition at line 186 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::setHeader().

Here is the call graph for this function:

void servlet::NoBodyResponse::setIntHeader ( const std::string &  name,
int  value 
) [virtual]

Sets a response header with the given name and integer value. If the header 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.

Parameters:
name the name of the header
value the assigned integer value
See also:
containsHeader

addIntHeader

Implements servlet::HttpServletResponse.

Definition at line 193 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::setIntHeader().

Here is the call graph for this function:

void servlet::NoBodyResponse::setStatus ( int  sc  )  [virtual]

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, and the caller wishes to invoke an error-page defined in the web application, the sendError method should be used instead.

The container clears the buffer and sets the Location header, preserving cookies and other headers.

Parameters:
sc the status code
See also:
sendError

Implements servlet::HttpServletResponse.

Definition at line 179 of file NoBodyResponse.cpp.

References resp, and servlet::HttpServletResponse::setStatus().

Here is the call graph for this function:


Friends And Related Function Documentation

friend class HttpServlet [friend]

Definition at line 114 of file NoBodyResponse.h.


Member Data Documentation

Definition at line 76 of file NoBodyResponse.h.

Referenced by setContentLength().


The documentation for this class was generated from the following files:

SourceForge.net Logo