FARGOS/VISTA Object Management Environment Core
..
|
Core embedded HTTP server logic. More...
#include <HTTPembeddedServer.hpp>
Public Member Functions | |
HTTPembeddedServerBase (uint16_t port, void *extraData=nullptr, const char *useServerName=nullptr, uint32_t useBfrSize=0, uint16_t maxEventLength=0) | |
Configures the HTTP server for listening on the indicated port. More... | |
virtual | ~HTTPembeddedServerBase () |
void | setBufferSize (uint32_t bfrSize) |
Alter buffer size used for new accepted client connections. More... | |
void | setHTTPeventLength (uint32_t maxLen) |
Alter maximum length of an HTTP event used for new accepted connections. More... | |
const char * | getServerName () const |
Returns the name associated with the HTTP server. More... | |
int | startHTTPlisten () |
Start the HTTP server. More... | |
int | stopHTTPlisten (const char *reason) |
Stop the HTTP server. More... | |
int | waitForHTTPstop () |
Wait for server to cease operations. More... | |
virtual HTTP_SessionRecord * | acceptNewConnection (IO_Processor *io, CircularBufferManager *mgr, const GenericSocketAddress *from, void *extraData)=0 |
Public Attributes | |
void * | userData |
OS_SOCKET_TYPE | listenDescriptor |
uint32_t | bufferSize |
uint16_t | maxHTTPeventLength |
uint16_t | listenPort |
bool | stopAccepting |
bool | listenActive |
Static Protected Member Functions | |
static int | readHTTPstream (SharedBufferAllocRecord *rec, IO_Processor *controller) |
static void * | startHTTPacceptThread (void *arg) |
Protected Attributes | |
char | serverName [64] |
pthread_t | acceptThreadID |
Core embedded HTTP server logic.
Invokes the abstract function acceptNewConnection() to obtain desired per-session application logic.
The templatized HTTPembeddedServer<> class provides a convenient typed interface and is how most user implementations create the HTTP server.
|
inline |
Configures the HTTP server for listening on the indicated port.
port | specifies the TCP port onto which incoming connections will be accepted. |
extraData | will be passed to each of the HTTP_SessionRecord objects that are created. |
useServerName | allows an alternate server name to be specified; the default uses the host's name. |
useBfrSize | allows the buffer size to be specified. If 0, which is the default, the buffer size will be determined based on the maximum event size. |
maxEventLength | allows the maximum size of a single event to be specified. If 0, the default size will be used. |
NOTE: the server is not started until startHTTPlisten() is called.
References bufferSize, listenActive, listenPort, maxHTTPeventLength, safe_strcpy, serverName, stopAccepting, and userData.
|
inlinevirtual |
|
pure virtual |
After the HTTP server has accepted an incoming connection, a new session object is created via a call to acceptNewConnection().
NOTE: this is an abstract function which must be implemented by the subclass realizing the server implementation.
Implemented in HTTPembeddedServer< ACCEPT_CLASS, USER_CLASS >.
|
inline |
Returns the name associated with the HTTP server.
References serverName.
|
staticprotected |
References Extract_And_Process_Document_Stream::addIOblockThenProcess(), IO_Processor::bufferAddress(), HTTP_SessionRecord::connectionEOF(), IO_Processor::descriptor, HTTP_SessionRecord::fromAddress, IO_Processor::getExtraData(), IFLOG_WHEN, LOG_ENDLINE, IO_Processor::READ_THREAD, SOCKET_CAST, and IO_Processor::stopThread().
|
inline |
Alter buffer size used for new accepted client connections.
References bufferSize.
|
inline |
Alter maximum length of an HTTP event used for new accepted connections.
References maxHTTPeventLength.
|
staticprotected |
References listenDescriptor, LOG_CERR, LOG_ENDLINE, OS_SOCKET_TYPE, SIG_BLOCK, and SIGPIPE.
Referenced by startHTTPlisten().
int HTTPembeddedServerBase::startHTTPlisten | ( | ) |
Start the HTTP server.
0 | indicates the server started successfully |
-1 | indicates the server failed to start, usually because the desired port is already in use. |
References acceptThreadID, GenericSocketAddress::addressLength, GenericSocketAddress::GenericSocketAddress_union::genericAddr, IFLOG_WHEN, GenericSocketAddress::GenericSocketAddress_union::ipv4, listenDescriptor, listenPort, LOG_CERR, LOG_ENDLINE, ntohs, NULL, OME_EXPECT_FALSE, PTHREAD_CREATE_JOINABLE, setLabelForThread(), GenericSocketAddress::socketAddress, and startHTTPacceptThread().
int HTTPembeddedServerBase::stopHTTPlisten | ( | const char * | reason | ) |
Stop the HTTP server.
References acceptThreadID, IFLOG_WHEN, listenActive, LOG_ENDLINE, SIGIO, and stopAccepting.
int HTTPembeddedServerBase::waitForHTTPstop | ( | ) |
Wait for server to cease operations.
References acceptThreadID.
|
protected |
Referenced by startHTTPlisten(), stopHTTPlisten(), and waitForHTTPstop().
uint32_t HTTPembeddedServerBase::bufferSize |
Referenced by HTTPembeddedServerBase(), and setBufferSize().
bool HTTPembeddedServerBase::listenActive |
Referenced by HTTPembeddedServerBase(), and stopHTTPlisten().
OS_SOCKET_TYPE HTTPembeddedServerBase::listenDescriptor |
Referenced by startHTTPacceptThread(), and startHTTPlisten().
uint16_t HTTPembeddedServerBase::listenPort |
Referenced by HTTPembeddedServerBase(), and startHTTPlisten().
uint16_t HTTPembeddedServerBase::maxHTTPeventLength |
Referenced by HTTPembeddedServerBase(), and setHTTPeventLength().
|
protected |
Referenced by getServerName(), and HTTPembeddedServerBase().
bool HTTPembeddedServerBase::stopAccepting |
Referenced by HTTPembeddedServerBase(), and stopHTTPlisten().
void* HTTPembeddedServerBase::userData |
![]() | Generated: Tue Jul 28 2020 16:03:27
Support Information |