Barracuda Application Server C/C++ Reference
NO
|
This object is used when sending response messages back to the client.
The HttpServer creates an HttpResponse object and passes it as the second argument to the HttpPage Service Function.
The HttpResponse struct contains a number of methods that can be used when sending messages back to the client from the HttpPage Service Function. Most of the response functions return an int. The methods return 0 on success or -1 on failure. A function might, for example, send -1 if the socket connection closes.
#include <HttpServer.h>
Public Member Functions | |
U32 | byteCount () |
Returns number of bytes sent thus far. | |
HttpCookie * | createCookie (const char *name) |
Create a cookie. More... | |
const char * | containsHeader (const char *name) |
Searches the internal response header database for a header with the specified name. More... | |
const char * | encodeRedirectURL (const char *pathName) |
Encodes the specified URL into an absolute URL, or if encoding is not needed, returns the URL unchanged. More... | |
const char * | encodeRedirectURLWithParam (const char *pathName) |
This method is similar to HttpResponse::encodeRedirectURL, but this method also includes all URL-encoded parameters in the request line and in the body if the client sent a POST message. More... | |
const char * | encodeUrl (const char *path) |
Encodes an absolute or relative URL, or if encoding is not needed, returns the URL unchanged. More... | |
int | flush () |
Forces any content in the buffer to be written to the client. More... | |
int | forward (const char *path) |
Forwards a request from a servlet to another resource (servlet, CSP file, or HTML file). More... | |
int | redirect (const char *path) |
Internally redirects the request to another resource. More... | |
HttpRequest * | getRequest () |
Get the HttpRequest object. | |
HttpCommand * | getCommand () |
Get the HttpCommand object. | |
int | include (const char *path) |
Includes the content of a resource (servlet, CSP page, HTML file) in the response. More... | |
bool | committed () const |
Returns a boolean indicating if the response has been committed. More... | |
bool | isForward () const |
Returns true if this is a forward request from another servlet or CSP file. | |
bool | isInclude () const |
Returns true if this is an include from another servlet or CSP file. | |
bool | initial () const |
Returns true if this is the initial page. More... | |
int | resetHeaders () |
Removes all HTTP headers. More... | |
int | resetBuffer () |
Clears the content of the underlying buffer in the response without clearing headers or status code. More... | |
int | sendError (int eCode) |
Sends an error response as a simple HTML page to the client using the specified status code. More... | |
int | sendError (int eCode, const char *msg) |
Sends an error response as a simple HTML page to the client using the specified status code. More... | |
int | sendBufAsError (int eCode) |
Sends the data formatted into the HttpResponse buffer as an error message to the client. More... | |
int | sendBufAsTxtError (int eCode) |
Sends the data formatted into the HttpResponse buffer as an error message to the client. More... | |
int | fmtError (int eCode, const char *fmt,...) |
This method implements a printf like implementation for formatting and sending an error message. More... | |
int | sendRedirect (const char *url) |
Sends a temporary redirect (302) response to the client using the specified redirect location URL. More... | |
int | redirect2TLS () |
Converts the URL to HTTPS and sends a redirect (301) response to the client if this is a non secure connection. More... | |
int | setContentLength (BaFileSize len) |
Sets the "Content-Length" parameter value. More... | |
int | setContentType (const char *type) |
Sets the "Content-Type" parameter value. More... | |
int | setDateHeader (const char *name, BaTime time) |
Sets a response header with the given name and date-value. More... | |
int | setHeader (const char *name, const char *value, bool replace=true) |
Sets a HTTP response header with the given name and value. More... | |
int | setMaxAge (BaTime seconds) |
Sets header "Cache-Control: max-age=seconds". More... | |
char * | fmtHeader (const char *name, int valueLen, bool replace=true) |
Pre-allocate memory for a {name, value} pair in the response header database. More... | |
void | setStatus (int statusCode) |
Sets the status code for this response. More... | |
int | printf (const char *fmt,...) |
printf is used for sending formatted data to the client. More... | |
BufPrint * | getWriter () |
Returns a BufPrint object that can send any type of data to the client. More... | |
int | write (const void *data, int len, int useBuffering=TRUE) |
Used for sending pre-formatted data to the client. More... | |
int | write (const char *data, int useBuffering=TRUE) |
Used for sending a zero terminated string to the client. More... | |
int | send (const void *data, int len) |
Used when sending raw data to the client. More... | |
int | setDefaultHeaders () |
Sets the most common header values in servlet and CSP files. More... | |
int | setResponseBuf (BufPrint *buf, bool useDefBuffer=true) |
This is an advanced function that makes it possible to redirect the output, which is normally sent to the client, to another buffer. More... | |
int | removeResponseBuf () |
Remove buffer set by using setResponseBuf. More... | |