Nebula
|
#include <httpserver.h>
Implements an extremly simple standalone HTTP server with attached HttpRequestHandlers.
Can be used to serve debug information about the Nebula application to web browsers.
Inherits Core::RefCounted.
Classes | |
struct | PendingRequest |
Public Member Functions | |
HttpServer () | |
constructor | |
virtual | ~HttpServer () |
destructor | |
void | SetPort (ushort p) |
set port number for http service | |
ushort | GetPort () const |
get port number of http service | |
void | SetSingleThreadMode (bool b) |
turn single-thread mode on/off (useful for debugging), default is off | |
bool | IsSingleThreadMode () const |
get single-thread mode | |
bool | Open () |
open the http server | |
void | Close () |
close the http server | |
bool | IsOpen () const |
return true if server is open | |
void | AttachRequestHandler (const Ptr< HttpRequestHandler > &h) |
attach a request handler to the server | |
void | RemoveRequestHandler (const Ptr< HttpRequestHandler > &h) |
remove a request handler from the server | |
Util::Array< Ptr< HttpRequestHandler > > | GetRequestHandlers () const |
get registered request handlers | |
void | OnFrame () |
call this method frequently to serve http connections | |
Public Member Functions inherited from Core::RefCounted | |
RefCounted () | |
constructor | |
int | GetRefCount () const |
get the current refcount | |
void | AddRef () |
increment refcount by one | |
void | Release () |
decrement refcount and destroy object if refcount is zero | |
bool | IsInstanceOf (const Rtti &rtti) const |
return true if this object is instance of given class | |
bool | IsInstanceOf (const Util::String &className) const |
return true if this object is instance of given class by string | |
bool | IsInstanceOf (const Util::FourCC &classFourCC) const |
return true if this object is instance of given class by fourcc | |
bool | IsA (const Rtti &rtti) const |
return true if this object is instance of given class, or a derived class | |
bool | IsA (const Util::String &rttiName) const |
return true if this object is instance of given class, or a derived class, by string | |
bool | IsA (const Util::FourCC &rttiFourCC) const |
return true if this object is instance of given class, or a derived class, by fourcc | |
const Util::String & | GetClassName () const |
get the class name | |
Util::FourCC | GetClassFourCC () const |
get the class FourCC code | |
Private Member Functions | |
__DeclareClass (HttpServer) | |
__DeclareSingleton (HttpServer) | |
bool | HandleHttpRequest (const Ptr< Net::TcpClientConnection > &clientConnection) |
handle an HttpRequest | |
bool | BuildHttpResponse (const Ptr< Net::TcpClientConnection > &clientConnection, const Ptr< HttpRequest > &httpRequest) |
build an HttpResponse for a handled http request | |
Private Attributes | |
Util::Dictionary< Util::String, Ptr< HttpRequestHandler > > | requestHandlers |
Ptr< DefaultHttpRequestHandler > | defaultRequestHandler |
Net::IpAddress | ipAddress |
Ptr< Net::TcpServer > | tcpServer |
Util::Array< PendingRequest > | pendingRequests |
bool | isOpen |
bool | isSingleThreadMode |
Additional Inherited Members | |
Static Public Member Functions inherited from Core::RefCounted | |
static void | DumpRefCountingLeaks () |
dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!) | |
Protected Member Functions inherited from Core::RefCounted | |
virtual | ~RefCounted () |
destructor (called when refcount reaches zero) | |
Http::HttpServer::HttpServer | ( | ) |
constructor
|
virtual |
destructor
|
private |
|
private |
void Http::HttpServer::AttachRequestHandler | ( | const Ptr< HttpRequestHandler > & | h | ) |
attach a request handler to the server
|
private |
build an HttpResponse for a handled http request
void Http::HttpServer::Close | ( | ) |
close the http server
|
inline |
get port number of http service
|
inline |
get registered request handlers
|
private |
handle an HttpRequest
|
inline |
return true if server is open
|
inline |
get single-thread mode
void Http::HttpServer::OnFrame | ( | ) |
call this method frequently to serve http connections
bool Http::HttpServer::Open | ( | ) |
open the http server
void Http::HttpServer::RemoveRequestHandler | ( | const Ptr< HttpRequestHandler > & | h | ) |
remove a request handler from the server
|
inline |
set port number for http service
|
inline |
turn single-thread mode on/off (useful for debugging), default is off
Switch on single thread mode, default is off.
In single thread mode, http requests will be processed immediately in the OnFrame() method, not added to the request handler for asynchronous processing. This may be useful for debugging, but is dangerous/impossible if HTTP request handlers live in different threads!!!
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |