EHS provides HTTP server functionality to a child class.
More...
#include <ehs.h>
|
EHSServerParameters | m_oParams |
| Stores a map with server parameters.
|
|
EHS provides HTTP server functionality to a child class.
The child class must inherit from it and then override the HandleRequest method.
- Examples:
- ehs_basicauth.cpp, ehs_exception.cpp, ehs_formtest.cpp, ehs_https.cpp, ehs_mirror.cpp, ehs_privport.cpp, ehs_simple.cpp, ehs_test.cpp, ehs_testharness.cpp, ehs_uploader.cpp, and ehs_wsgate.cpp.
Definition at line 147 of file ehs.h.
◆ EHS()
EHS |
( |
EHS * |
parent = NULL , |
|
|
std::string |
registerpath = "" |
|
) |
| |
Constructs a new instance as child of another EHS instance.
- Parameters
-
parent | The parent EHS instance. |
registerpath | The URI path which the new instance should handle. |
◆ AddResponse()
Enqueues a generic response.
- Parameters
-
response | The response to enqueue |
◆ GetBindHelper()
◆ GetPassphrase()
virtual const std::string GetPassphrase |
( |
bool |
twice | ) |
|
|
virtual |
Default PassphraseHandler implementation.
Takes passphrase from server parameters without prompting.
- Parameters
-
twice | If true, an interactive implementation should ask twice for a passphrase in order to eliminate typing errors. |
- Returns
- A std::string holding the passphrase.
Implements PassphraseHandler.
◆ GetRawSocketHandler()
◆ HandleRequest()
Main request handler.
Reimplement this method in a derived class in order to implement the actual functionality.
- Parameters
-
request | Pointer to the HTTP request that triggered invocation of this method. |
response | Pointer to the HTTP response that is going to be sent to the client. In derived methods, populate the HttpResponse with your data. |
- Returns
- The HTTP response code to be sent to the client.
◆ HandleThreadException()
Hook for handling exceptions in threads.
Called, when an exception was thrown from within a thread. Reimplement this method in a derived class, if you want to handle your own exceptions. The default implementation prints the exception's message on cerr and returns NULL. If returning NULL, you still should invoke StopServer in order to terminate the server's remaining threads.
- Parameters
-
tid | The thread ID of the thread that has thrown the exception. |
request | The current HTTP request that was active wile the exception was thrown. |
ex | The exception that was thrown. Any C-Style exceptions are thrown as runtime_exception("unspecified"). |
- Returns
- NULL if the thread should exit; an appropriate HTTP response, if the thread should continue.
◆ RegisterEHS()
void RegisterEHS |
( |
EHS * |
child, |
|
|
const char * |
uripath |
|
) |
| |
Instructs this EHS instance to invoke HandleRequest of another EHS instance whenever a specific URI is requested.
- Parameters
-
child | The foreign EHS instance which shall handle the requests. |
uripath | The relative URI path, that shall be handled by the child. |
- Exceptions
-
std:runtime_error,if | another instance is already registered with the same path. |
◆ RouteRequest()
Routes a request to the appropriate instance.
- Parameters
-
request | The HTTP request to be routed. |
- Returns
- A pointer to the HttpResponse object, to be sent back to the client.
◆ SetBindHelper()
Sets a PrivilegedBindHelper for use by the network abstraction layer.
- Parameters
-
helper | A pointer to a PrivilegedBindHelper instance, implementing the bind operation to a privileged port. Without this helper, an instance cannot bind to privileged ports (ports < 1024) unless running as root. The BindPrivilegedPort method will only be called for ports < 1024. |
- Examples:
- ehs_https.cpp.
Definition at line 322 of file ehs.h.
◆ SetRawSocketHandler()
◆ SetSourceEHS()
void SetSourceEHS |
( |
EHS & |
source | ) |
|
Establishes this EHS instance as request handler of another EHS instance.
Any HTTP request received by the other EHS instance will be handled by this instance's HandleRequest method.
- Parameters
-
source | A reference to the source EHS instance. |
◆ ShouldTerminate()
bool ShouldTerminate |
( |
| ) |
const |
◆ StartServer()
void StartServer |
( |
EHSServerParameters & |
params | ) |
|
Starts up this instance.
If configured to run in threaded mode, the main listener thread as well as all worker threads are started.
- Parameters
-
params | An EHSServerParameters map used for configuring this instance. |
- Exceptions
-
A | std:runtime_error if an error happens. |
- Examples:
- ehs_https.cpp, and ehs_simple.cpp.
◆ StopServer()
Shuts down this instance.
If running in threaded mode, all associated threads are stopped. Stopping threads is a blocking operation. This method returns, if all relevant threads are terminated.
- Examples:
- ehs_https.cpp, and ehs_simple.cpp.
◆ ThreadExitHandler()
virtual void ThreadExitHandler |
( |
| ) |
|
|
virtual |
Hook for thread shutdown.
Called at exit of a thread routine. Reimplement this method in a derived class, if you need to perform any task (like some cleanup) just before the thread is terminating.
◆ ThreadInitHandler()
virtual bool ThreadInitHandler |
( |
| ) |
|
|
virtual |
Hook for thread startup.
Called at the start of a thread routine. Reimplement this method in a derived class, if you need to perform any task (like setting up thread-local storage) at the start of a thread.
- Returns
- true, if everything is OK, false otherwise.
◆ UnregisterEHS()
void UnregisterEHS |
( |
const char * |
uripath | ) |
|
Removes a previously registered path registration.
- Parameters
-
uripath | The URI path to be removed. |
- Exceptions
-
std:runtime_error,if | nothing registered with the given path. |
The documentation for this class was generated from the following file: