Google APIs Client Library for C++
|
Provides a web server for samples and testing. More...
#include "client/util/mongoose_webserver.h"
Public Member Functions | |
MongooseWebServer (int port) | |
Constructs an http server on the given port. | |
virtual | ~MongooseWebServer () |
Standard destructor. | |
bool | use_ssl () const |
Determines whether we are using SSL or not. | |
void | set_mongoose_options (const map< string, string > &options) |
Override Mongoose options. | |
const map< string, string > & | mongoose_options () const |
Returns Mongoose options that were overriden. | |
void | clear_mongoose_options () |
Clears Mongoose option overrides. | |
void | set_mongoose_option (const StringPiece &name, const StringPiece &value) |
Explicitly configure an individual Mongoose server option. | |
const string | mongoose_option (const string &name) const |
Returns value for individual option, or empty if not set. | |
void | clear_mongoose_option (const StringPiece &name) |
Clears an overiden Mongoose options back to the default value. | |
virtual string | url_protocol () const |
Returns actual protocol depending on whether SSL was enabled. | |
Static Public Attributes | |
static const StringPiece | ACCESS_LOG_FILE |
static const StringPiece | DOCUMENT_ROOT |
static const StringPiece | ENABLE_KEEP_ALIVE |
static const StringPiece | ERROR_LOG_FILE |
static const StringPiece | LISTENING_PORTS |
static const StringPiece | NUM_THREADS |
static const StringPiece | REQUEST_TIMEOUT_MS |
static const StringPiece | SSL_CERTIFICATE |
Protected Member Functions | |
virtual util::Status | DoStartup () |
Starts the server. | |
virtual void | DoShutdown () |
Stops the server. | |
int | SendResponse (const StringPiece &content_type, int http_code, const StringPiece &body, struct mg_connection *connection) |
Sends the body response with the given http_code. |
Provides a web server for samples and testing.
This class and the use of Mongoose Web Server available from https://code.google.com/p/mongoose/
This class is currently only intended to support testing and tinkering. It is not robust for production use. The underlying library is probably sufficient, but this wrapper uses only minimal configuration and processing.
MongooseWebServer | ( | int | port | ) | [explicit] |
Constructs an http server on the given port.
[in] | port | Should be non-0. |
virtual ~MongooseWebServer | ( | ) | [virtual] |
Standard destructor.
void clear_mongoose_option | ( | const StringPiece & | name | ) | [inline] |
Clears an overiden Mongoose options back to the default value.
void clear_mongoose_options | ( | ) | [inline] |
Clears Mongoose option overrides.
virtual void DoShutdown | ( | ) | [protected, virtual] |
virtual util::Status DoStartup | ( | ) | [protected, virtual] |
const string mongoose_option | ( | const string & | name | ) | const [inline] |
Returns value for individual option, or empty if not set.
const map<string, string>& mongoose_options | ( | ) | const [inline] |
Returns Mongoose options that were overriden.
int SendResponse | ( | const StringPiece & | content_type, |
int | http_code, | ||
const StringPiece & | body, | ||
struct mg_connection * | connection | ||
) | [protected] |
Sends the body response with the given http_code.
[in] | content_type | The MIME content_type for the response. |
[in] | http_code | The HTTP status code to return. |
[in] | body | The HTTP body to return. |
[in] | connection | The connection passed to the DoHandleUrl. |
void set_mongoose_option | ( | const StringPiece & | name, |
const StringPiece & | value | ||
) | [inline] |
Explicitly configure an individual Mongoose server option.
[in] | name | See the Mongoose Documentation for option names. |
[in] | value | See the Mongoose Documentation for option values. |
void set_mongoose_options | ( | const map< string, string > & | options | ) | [inline] |
Override Mongoose options.
This replaces the old options that were overriden.
[in] | options | The options will be copied. They must be set before the server is started. |
virtual string url_protocol | ( | ) | const [virtual] |
Returns actual protocol depending on whether SSL was enabled.
Reimplemented from AbstractWebServer.
bool use_ssl | ( | ) | const [inline] |
Determines whether we are using SSL or not.
const StringPiece ACCESS_LOG_FILE [static] |
const StringPiece DOCUMENT_ROOT [static] |
const StringPiece ENABLE_KEEP_ALIVE [static] |
const StringPiece ERROR_LOG_FILE [static] |
const StringPiece LISTENING_PORTS [static] |
const StringPiece NUM_THREADS [static] |
const StringPiece REQUEST_TIMEOUT_MS [static] |
const StringPiece SSL_CERTIFICATE [static] |