Barracuda Application Server C/C++ Reference
NO
|
Trace the communication between a client and the server.
This class is enabled if the Barracuda Web-Server library is compiled with macro HTTP_TRACE enabled. The methods in this class have no effect if the trace functionality is not enabled by macro HTTP_TRACE. You must also provide a console callback function before the trace functionality is activated. See HttpTrace::setFLushCallback for more information.
Most user functions in the web-server return 0 on success and an error number if any of the parameters were incorrect. The web-server also prints the error to the trace buffer, and it is for this reason recommended that you always provide a trace callback function when doing development.
The trace library is typically used by your code when debugging. The printf and write member functions take the message priority as argument. You can, therefore, design the code such that more important functions use a higher priority. See HttpTrace::setPrio for more information.
The web-server is using the trace library to write information about user requests and response data. This is by default disabled. If enabled, the web-server writes the data to the trace buffer by using priority 5. See the setXXX functions for more information.
The trace callback function can write to internal memory, your screen (if you have one) or use an SMTP library.
Here is a trace callback function example that is using the SMTP library:
The methods in the HttpTrace class are re-entrant, except for HttpTrace::setFLushCallback and HttpTrace::setBufSize. These two functions, if used, must be called at system startup.
#include <HttpTrace.h>
Static Public Member Functions | |
static void | setFLushCallback (HttpTrace_Flush fcb) |
The HTTP_TRACE compile time macro adds the trace library to the Barracuda library, but the trace functions will have no effect if you do not provide a callback function. More... | |
static void | vprintf (int prio, const char *fmt, va_list argList) |
Write data to the trace buffer. More... | |
static void | printf (int prio, const char *fmt,...) |
Write data to the trace buffer. More... | |
static void | write (int prio, const char *buf, int len=-1) |
Write data to the trace buffer. More... | |
static int | setPrio (int prio) |
Set the trace message priority filter. More... | |
static BufPrint * | getWriter () |
Get and lock the trace BufPrint object. More... | |
static void | releaseWriter (void) |
Release the trace. More... | |
static void | setRequest (bool cmd) |
If enabled, the web-server prints the first line in the request header to the trace buffer. More... | |
static void | setRequestHeaders (bool cmd) |
If enabled, the web-server dumps the content of the request header to the trace buffer. | |
static void | setResponseHeaders (bool cmd) |
If enabled, the web-server dumps the content of the response header to the trace buffer. | |
static void | setResponseBody (bool cmd) |
If enabled, the web-server dumps the content of the response body to the trace buffer. More... | |
static void | setHttp11State (bool cmd) |
If enabled, prints the status for each active client connection of the internal "HTTP 1.1 persistent connection" state machine to the trace buffer. More... | |
static void | setReqBufOverflow (bool cmd) |
Prints "ReqBufOverflow" if enabled and the HttpRequest buffer overflows. More... | |
static int | setBufSize (int size) |
Set trace buffer. More... | |
static void | flush () |
Force a flush on data in trace buffer; i.e., call the flush callback. | |
|
static |
Get and lock the trace BufPrint object.
|
static |
Write data to the trace buffer.
Works just like the regular printf function.
prio | See HttpTrace::setPrio. |
fmt | See BufPrint::printf |
|
static |
|
static |
Set trace buffer.
The default buffer is 80 characters long. This function is not re-entrant, and you should therefore call this function at system startup.
|
static |
The HTTP_TRACE compile time macro adds the trace library to the Barracuda library, but the trace functions will have no effect if you do not provide a callback function.
This function is not re-entrant; therefore, you should call this function at system startup.
The following example dumps data to the console:
Please note that data written to the trace is not automatically flushed. It may be a good idea to run the web-server in poll mode and flush the data manually after the web-server is run.
|
static |
If enabled, prints the status for each active client connection of the internal "HTTP 1.1 persistent connection" state machine to the trace buffer.
The state machine can be in one of 5 states. As an example, a non-persistent connection will go through the following states for each request:
A persistent HTTP connection is in one of the Connected or Running states.
|
static |
Set the trace message priority filter.
Priority 0 is the highest priority. Setting the priority to say 10 means that only trace messages with a priority greater than or equal to 10 will be printed to the trace buffer.
prio | The priority [default=5] |
|
static |
Prints "ReqBufOverflow" if enabled and the HttpRequest buffer overflows.
A buffer overflow occurs if the client request stream overflows the request buffer. This could potentially be an indication of a Buffer Overflow Attack. Buffer Overflow Attacks are very common against web servers. Barracuda is immune to Buffer Overflow Attacks. See HttpServerConfig::setRequest for more information.
|
static |
If enabled, the web-server prints the first line in the request header to the trace buffer.
Example:
|
static |
If enabled, the web-server dumps the content of the response body to the trace buffer.
Warning: this generates an enormous amount of trace data.
|
static |
Write data to the trace buffer.
Works just like the regular vprintf function.
prio | See HttpTrace::setPrio. |
fmt | See BufPrint::vprintf |
argList | See BufPrint::vprintf more information. |
|
static |
Write data to the trace buffer.
prio | See HttpTrace::setPrio. |
buf | a pointer to the buffer/string. |
len | is optional, not needed for strings. |