Go to the documentation of this file. 1 #ifndef _HTTP_EMBEDDED_SERVER_HPP_
2 #define _HTTP_EMBEDDED_SERVER_HPP_ "$Id: HTTPembeddedServer.hpp 411 2020-07-13 03:02:58Z geoff $"
55 const char *address = targetAddress;
56 int l = (int) strlen(address);
57 const char *colon = (
const char *) memchr(address,
':',
l);
59 int selectedFamily = AF_INET;
61 if (colon !=
nullptr) {
62 uint_fast32_t prefixLen = (uint_fast32_t) (colon - address);
64 if (memcmp(address,
"ipv4:", 5) == 0) {
65 selectedFamily = AF_INET;
67 if ((*address ==
'/') && (*(address + 1) ==
'/')) {
70 }
else if (memcmp(address,
"ipv6:", 5) == 0) {
71 selectedFamily = AF_INET6;
73 if ((*address ==
'/') && (*(address + 1) ==
'/')) {
77 }
else if (memcmp(address,
"file:", 5) == 0) {
78 selectedFamily = AF_LOCAL;
80 if ((*address ==
'/') && (*(address + 1) ==
'/')) {
92 switch (selectedFamily) {
123 enum { MAX_COLONS = 16 };
125 char *colonAddr[MAX_COLONS];
127 uint_fast8_t colonsSeen = 0;
129 const char *src = addressString;
130 char *dest = workBfr;
132 while (*src !=
'\0') {
134 if (colonsSeen < MAX_COLONS) {
135 colonAddr[colonsSeen] = dest;
139 *(dest++) = *(src++);
142 if (colonsSeen != 0) {
143 uint32_t offsetOfLastColon = (uint32_t) (colonAddr[colonsSeen - 1] - workBfr);
144 if (offsetOfLastColon > 5) {
145 *colonAddr[colonsSeen - 1] =
'\0';
146 uint32_t portLen = (uint32_t) (dest - colonAddr[colonsSeen - 1]);
148 port =
text2uint32(colonAddr[colonsSeen - 1] + 1, portLen - 1);
226 uint_fast8_t offset = 0;
227 int32_t bfrLeft = (int32_t) bfrSize;
230 if (includeURLprefix ==
true) {
231 memcpy(addrText,
"ipv4://", 7);
238 inet_ntop(AF_INET,
const_cast<struct in_addr *
>(&
socketAddress.
ipv4.sin_addr), addrText + offset, bfrLeft);
242 if (includeURLprefix ==
true) {
243 memcpy(addrText,
"ipv6://", 7);
250 inet_ntop(AF_INET6,
const_cast<struct in6_addr *
>(&
socketAddress.
ipv6.sin6_addr), addrText + offset, bfrLeft);
255 if (includeURLprefix ==
true) {
256 memcpy(addrText,
"file://", 7);
296 snprintf(bfr, bfrSize,
"%s:%d", addrText, port);
298 _snprintf(bfr, bfrSize,
"%s:%d", addrText, port);
330 rc = memcmp(&
socketAddress, &arg.socketAddress, arg.addressLength);
348 rc = memcmp(&
socketAddress, &arg.socketAddress, arg.addressLength);
360 os <<
"[GenericSocketAddress={";
368 #pragma GCC diagnostic push
369 #pragma GCC diagnostic ignored "-Wsuggest-final-types"
383 int rc = strcmp(arg1, arg2);
384 if (rc < 0)
return (
true);
392 const char *cmd,
char *url,
393 unsigned char *block,
size_t blockLen);
421 uint_fast32_t statusCodeValue=200,
const char *statusText=
"OK",
422 const char *extraHeaders=
"",
423 ssize_t contentLength=0,
const char *extraContent=
"");
444 size_t maxDocSize=1024*128) :
454 #pragma GCC diagnostic push
455 #pragma GCC diagnostic ignored "-Wsuggest-final-methods"
460 #pragma GCC diagnostic pop
471 bool nullTerminate=
false);
493 int_fast32_t optionLength=-1);
520 #pragma GCC diagnostic push
521 #pragma GCC diagnostic ignored "-Wsuggest-final-methods"
526 #pragma GCC diagnostic pop
548 if (line[lineLen - 1] ==
'\n') {
550 if (line[lineLen - 1] ==
'\r') {
569 #pragma GCC diagnostic push
570 #pragma GCC diagnostic ignored "-Wsuggest-final-methods"
577 #pragma GCC diagnostic push
583 char *url,
unsigned char *block,
size_t blockLen);
587 #pragma GCC diagnostic pop
591 os <<
"[HTTP_SessionRecord={";
651 const char *useServerName=
nullptr, uint32_t useBfrSize=0,
652 uint16_t maxEventLength=0)
660 if (useServerName ==
nullptr) {
669 while (*cp !=
'\0') {
741 const char *useServerName=0, uint32_t useBfrSize=0,
742 uint16_t maxEventLen=0) :
749 ACCEPT_CLASS *sessionRec =
new ACCEPT_CLASS(
io, mgr, from,
750 reinterpret_cast<USER_CLASS *
>(extraData));
758 return (
reinterpret_cast<USER_CLASS *
>(
userData));
791 os <<
"[HTTPeventStateRecord={";
793 os <<
" eventType=\"" << arg.
eventType <<
"\"";
816 if (rc < 0)
return (
true);
840 virtual void receiveNotice(
const unsigned char *bfr, uint32_t bfrLen,
841 const char *eventType=
"log") = 0;
907 typedef std::map<HTTPstatusRecordKey,HTTPeventStateRecord,ltHTTPstatusRecordKey>
statusEventMap_t;
949 const unsigned char *lineData, uint32_t lineLen,
950 const char *additional);
954 const unsigned char *data =
const_cast<unsigned char *
>(
lineContent[relLine].iov_base);
958 data, lineLen, additional);
966 virtual void receiveNotice(
const unsigned char *bfr, uint32_t bfrLen,
Core embedded HTTP server logic.
Definition: HTTPembeddedServer.hpp:606
int32_t contentLengthWanted
Definition: read_file.hpp:602
HTTPnotificationPublisher(const char *name)
Definition: HTTPembeddedServer.hpp:859
@ PROCESS_THREAD
Definition: io_processor.hpp:160
#define safe_strcpy(d, s, l)
Safe strcpy() routine that will not copy more than l bytes and always ensures that a null is present ...
Definition: compiler_hints.h:696
#define EALEN
Definition: getether.c:25
virtual ~HTTPembeddedServerBase()
Definition: HTTPembeddedServer.hpp:684
void setBufferSize(uint32_t bfrSize)
Alter buffer size used for new accepted client connections.
Definition: HTTPembeddedServer.hpp:688
SMV_StandaloneNumeric< uint32_t > packetsProcessed
Definition: io_processor.hpp:127
union GenericSocketAddress::GenericSocketAddress_union socketAddress
#define IFLOG_WHEN(lvl)
Convenience declaration for log line that will be conditionally emitted for the default component if ...
Definition: logging_api.hpp:2941
IO_Processor_Statistics * statistics
statistics
Definition: io_processor.hpp:195
Ïúíþ ð Ø ˜ ˜ __text __TEXT € __apple_names __DWARF __apple_objc __DWARF __apple_namespac__DWARF H X __apple_types __DWARF l
Definition: tmp3.o.cpp:1
Intermediary I/O processing object for performing multi-threaded receive-and-process operations on a ...
Definition: io_processor.hpp:154
IO_Processor * ioMgr
Definition: logging_api.hpp:598
GenericSocketAddress(const struct sockaddr_in6 ipv6) OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:165
BufferRegion * bfrMgr
Definition: logging_api.hpp:597
char * getAddressAndPort(char *bfr, uint32_t bfrSize, bool includeURLprefix=false) const
Convenience cover to copyAddressAndPort() that concatenates the port to the result.
Definition: HTTPembeddedServer.hpp:291
FARGOS file processing infrastructure.
virtual ~HTTPstatusLog()
Definition: HTTPembeddedServer.hpp:940
GenericSocketAddress(const std::string &address, uint16_t port)
Definition: HTTPembeddedServer.hpp:188
Per-session HTTP state record.
Definition: HTTPembeddedServer.hpp:378
TimedMutex sessionMutex
Definition: HTTPembeddedServer.hpp:905
HTTPembeddedServer(uint16_t port, USER_CLASS *extraData=0, const char *useServerName=0, uint32_t useBfrSize=0, uint16_t maxEventLen=0)
Definition: HTTPembeddedServer.hpp:740
#define OS_SOCKET_TYPE
Definition: io_processor.hpp:41
FARGOS I/O Processing classes.
@ READ_REQUEST
Definition: read_file.hpp:588
#define fromHex(x)
Definition: HTTPembeddedServer.cpp:31
OS_SOCKET_TYPE listenDescriptor
Definition: HTTPembeddedServer.hpp:617
virtual HTTP_SessionRecord * acceptNewConnection(IO_Processor *io, CircularBufferManager *mgr, const GenericSocketAddress *from, void *extraData)
Definition: HTTPembeddedServer.hpp:748
uint8_t addressLength
Definition: HTTPembeddedServer.hpp:36
Allocation record for chains in a 32-bit shared memory buffer.
Definition: circular_bfr.hpp:103
void * getExtraData() const OME_ALWAYS_INLINE
Retrieve extra information value.
Definition: io_processor.hpp:334
int64_t unlock()
Release a previously locked mutex.
Definition: timed_mutex.cpp:156
int startHTTPlisten()
Start the HTTP server.
Definition: HTTPembeddedServer.cpp:384
virtual void receiveNotice(const unsigned char *bfr, uint32_t bfrLen, const char *eventType="log")=0
Abstract interface to deliver formatted message.
#define SIGPIPE
Definition: tmp.o.cpp:529
Key structure for imposing a partial order on HTTP status events.
Definition: HTTPembeddedServer.hpp:802
std::map< std::string, HTTPcallbackFP > httpRequestHandlerTable
Definition: HTTPembeddedServer.hpp:403
unsigned char * bufferAddress(SharedBufferAllocRecord *rec, size_t *bufferLen=nullptr) const OME_ALWAYS_INLINE
Return physical address of a buffer within the context of the local process' address space.
Definition: io_processor.hpp:275
Abstract interface to receive log message for transmission to HTTP-attached clients.
Definition: HTTPembeddedServer.hpp:828
char serverName[64]
Definition: HTTPembeddedServer.hpp:608
std::set< HTTPnotificationReceiverInterface * > interestedClients
Definition: HTTPembeddedServer.hpp:854
@ OWN_BLOCK
indicates region is owned by the BufferRegion and should be recovered when deleted.
Definition: circular_bfr.hpp:181
~HTTP_SessionRecord()
Definition: HTTPembeddedServer.hpp:456
Templatized embedded HTTP server interface; realizes a complete implementation of HTTPembeddedServerB...
Definition: HTTPembeddedServer.hpp:737
bool closeWhenRequestComplete
Definition: HTTPembeddedServer.hpp:401
static int default_OPTIONS(HTTP_SessionRecord *session, const char *cmd, char *url, unsigned char *block, size_t blockLen)
Default implementation to handle OPTIONS request. It emits Access-Control-Allow headers,...
Definition: HTTPembeddedServer.cpp:197
bool operator()(const char *arg1, const char *arg2) const
Definition: HTTPembeddedServer.hpp:382
USER_CLASS * getUserData() const
Returns the user-specific data as a typed value.
Definition: HTTPembeddedServer.hpp:757
#define VIRTUAL_OVERRIDE
Generates override if the compiler supports it.
Definition: compiler_hints.h:435
Intermediate naming node for supporting variable naming hierarchies.
Definition: shared_variable.hpp:318
SMV_StandaloneNumeric< uint64_t > bytesRead
Definition: io_processor.hpp:122
int waitForHTTPstop()
Wait for server to cease operations.
Definition: HTTPembeddedServer.cpp:457
Definition: HTTPembeddedServer.hpp:27
LogMaskType_t COMPONENT_LOG_MASK() io("io_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(io, warn)|COMPONENT_LEVEL(io, error)|COMPONENT_LEVEL(io, fatal))
Internal record to describe events to be published via HTTP.
Definition: HTTPembeddedServer.hpp:770
#define _INVALID_DESCRIPTOR
Platform-independent reference to invalid descriptor.
Definition: logging_api.hpp:2618
#define INVALID_HANDLE_VALUE
Definition: poll_monitor.hpp:19
GenericSocketAddress & operator=(const struct sockaddr_in ipv4) OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:192
#define SIGIO
Definition: tmp.o.cpp:526
void addHTTPsession(HTTP_SessionRecord *rec, uint64_t fromTime=0)
Definition: HTTPembeddedServer.cpp:576
struct sockaddr_un filename
Definition: HTTPembeddedServer.hpp:33
const void * object
Definition: HTTPembeddedServer.hpp:803
void setCloseAfterRequestFlag(bool doClose)
Set close-when-request-complete flag.
Definition: HTTPembeddedServer.hpp:512
STREAMTYPE & operator<<(STREAMTYPE &os, const GenericSocketAddress &arg)
Definition: HTTPembeddedServer.hpp:358
void setHTTPeventLength(uint32_t maxLen)
Alter maximum length of an HTTP event used for new accepted connections.
Definition: HTTPembeddedServer.hpp:694
FARGOS Embedded HTTP server.
ssize_t sendResponse(const void *bfr, size_t bfrLen)
Definition: HTTPembeddedServer.cpp:147
static char * convertHTTPescapes(char *bfr, int_fast32_t bfrLen=-1, bool nullTerminate=false)
Definition: HTTPembeddedServer.cpp:35
virtual ~HTTPnotificationPublisher()
Definition: HTTPembeddedServer.hpp:881
int stopHTTPlisten(const char *reason)
Stop the HTTP server.
Definition: HTTPembeddedServer.cpp:442
static int readHTTPstream(SharedBufferAllocRecord *rec, IO_Processor *controller)
Definition: HTTPembeddedServer.cpp:215
uint32_t lineLength
Definition: HTTPembeddedServer.hpp:776
static int forwardToClients(SharedBufferAllocRecord *rec, IO_Processor *controller)
Definition: HTTPembeddedServer.cpp:720
#define ntohs(x)
Definition: tmp.o.cpp:3103
Base class for converting a LogManager into a publisher that outputs log event messages to multiple a...
Definition: HTTPembeddedServer.hpp:851
uint32_t eventRecordId
Definition: HTTPembeddedServer.hpp:777
Scan HTTP and parse stream for HTTP requests/responses.
Definition: read_file.hpp:584
#define SIG_BLOCK
Definition: tmp.o.cpp:550
Implements Less-than for HTTPstatusRecordKey.
Definition: HTTPembeddedServer.hpp:809
int setFromHostAndPort(const char *targetAddress, uint16_t port)
Assign from an URL representation of the address and an integer value of the port....
Definition: HTTPembeddedServer.hpp:54
~HTTPnotificationReceiverInterface()
Definition: HTTPembeddedServer.hpp:833
struct sockaddr_in6 ipv6
Definition: HTTPembeddedServer.hpp:31
uint16_t listenPort
Definition: HTTPembeddedServer.hpp:620
int copyAddressAndPort(char *addrText, uint32_t bfrSize, bool includeURLprefix=false) const
Return the address as a URL.
Definition: HTTPembeddedServer.hpp:215
#define AS_ESCAPED_TEXT_BUFFER(...)
Convenience label to enable passing text with known length to output operator<<().
Definition: logging_api.hpp:2100
char eventType[24]
Definition: HTTPembeddedServer.hpp:900
int setThreadMode(ThreadMode mode)
Set threading mode.
Definition: io_processor.cpp:564
void * userData
Definition: HTTPembeddedServer.hpp:616
char httpRequest[16]
Definition: read_file.hpp:600
const char srcID[]
Definition: catSym.c:17
#define SOCKET_CAST(x)
Definition: HTTPembeddedServer.cpp:22
static void becomeEventStream(HTTP_SessionRecord *session, HTTPstatusLog *statusLog)
Static convenience routine to take over an existing HTTP session and turn it into an event forwarder ...
Definition: HTTPembeddedServer.cpp:761
bool operator==(const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:303
bool operator>(const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:337
GenericSocketAddress() OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:156
std::list< HTTP_SessionRecord * > currentHTTPsessions
Definition: HTTPembeddedServer.hpp:906
@ READ_AND_PROCESS_ON_SAME_THREAD
a single spawned read thread will do both read-and-processing
Definition: io_processor.hpp:167
OS_HANDLE_TYPE descriptor
Definition: io_processor.hpp:210
char eventType[24]
Definition: HTTPembeddedServer.hpp:778
char requestURL[1024]
Definition: read_file.hpp:601
int_fast32_t prepareResponseHeader(void *outputBfr, size_t bfrLen, uint_fast32_t statusCodeValue=200, const char *statusText="OK", const char *extraHeaders="", ssize_t contentLength=0, const char *extraContent="")
Definition: HTTPembeddedServer.cpp:132
GenericSocketAddress(const struct sockaddr_in ipv4) OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:160
Implements multi-threaded, deferred physical I/O log file manager.
Definition: logging_api.hpp:552
uint32_t bufferSize
Definition: HTTPembeddedServer.hpp:618
GenericSocketAddress(const struct sockaddr *generic_addr, socklen_t addrLen) OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:174
static int doConsumeLoop(IO_Processor *controller)
Standard consume loop to receive incoming data.
Definition: io_processor.cpp:172
#define OME_EXPECT_TRUE(expr)
Annotation macro for conditional expression expected to be true.
Definition: compiler_hints.h:541
int waitForThreadExit(uint32_t modes)
Wait for threads to terminate.
Definition: io_processor.cpp:728
SMV_StandaloneNumeric< uint32_t > packetsRead
Definition: io_processor.hpp:125
bool operator!=(const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:311
static void * startHTTPacceptThread(void *arg)
Definition: HTTPembeddedServer.cpp:261
virtual SharedBufferAllocRecord * allocateBlock(size_t len)=0
size_t iov_len
Definition: HTTPembeddedServer.hpp:899
int stopThread(uint32_t modes)
Request stop.
Definition: io_processor.cpp:684
CircularBufferManager * bfrMgr
Definition: HTTPembeddedServer.hpp:398
uint_fast32_t text2uint32(const char *textString, uint_fast8_t text_len) NONNULL_PARAMETERS(1) OME_ALWAYS_INLINE OME_ALWAYS_OPTIMIZE("-O3")
Convert a sequence of text characters into an unsigned integer as quickly as possible....
Definition: text2int.h:79
@ PROCESS_DURING_READ
Processing will be performed by the read thread.
Definition: io_processor.hpp:162
Generic mutex implementation that supports timing statistics.
Definition: timed_mutex.hpp:51
GenericSocketAddress fromAddress
Definition: HTTPembeddedServer.hpp:400
GenericSocketAddress & operator=(const struct sockaddr_in6 ipv6) OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:198
int dumpLinesFromTime(HTTP_SessionRecord *rec, uint64_t fromTime)
Definition: HTTPembeddedServer.cpp:528
bool stopAccepting
Definition: HTTPembeddedServer.hpp:621
#define PTHREAD_CREATE_JOINABLE
Definition: tmp.o.cpp:425
Definition: HTTPembeddedServer.hpp:381
#define NULL
Definition: tmp.o.cpp:327
IO_Processor * controller
Definition: HTTPembeddedServer.hpp:397
LogMaskType_t COMPONENT_LOG_MASK() app("app_logMask", &DEFAULT_sharedMemoryVariableManager, COMPONENT_LEVEL(app, defaultMask))
#define htons(x)
Definition: tmp.o.cpp:3100
@ MAX_LINES_HISTORY
Definition: HTTPembeddedServer.hpp:896
Log message record used to remember output format and argument values, potentially deferring formatti...
Definition: logging_api.hpp:1022
char eventType[32]
Definition: HTTPembeddedServer.hpp:804
HTTPeventStateRecord(uint32_t id=0)
Definition: HTTPembeddedServer.hpp:781
int setFromURL(const char *addressString)
Convenience cover to setFromHostAndPort() that also converts the port.
Definition: HTTPembeddedServer.hpp:121
int dumpEventsFromTime(HTTP_SessionRecord *rec, uint64_t fromTime)
Definition: HTTPembeddedServer.cpp:554
static int_fast32_t parseOptions(OptionsAttrValMap_t *tbl, char *optionText, int_fast32_t optionLength=-1)
Parse an HTTP request option string. Elements are separated by "&" characters; each subelement is exp...
Definition: HTTPembeddedServer.cpp:59
@ NONE
No threads will be spawned.
Definition: io_processor.hpp:158
const char srcID[] OME_USED
Definition: tick_time.cpp:24
HTTPeventStateRecord * findOrCreateEventRecord(const void *obj, const char *eventType)
Find an event state record for the indicated object and event type.
Definition: HTTPembeddedServer.cpp:642
void publishKeepAlive()
Definition: HTTPembeddedServer.cpp:665
void addInterestedClient(HTTPnotificationReceiverInterface *client)
Definition: HTTPembeddedServer.hpp:883
@ READ_THREAD
A read thread will be spawned.
Definition: io_processor.hpp:159
time_t lineAddedAtTime[MAX_LINES_HISTORY]
Definition: HTTPembeddedServer.hpp:902
const unsigned char * iov_base
Definition: HTTPembeddedServer.hpp:898
virtual void receiveNotice(const unsigned char *bfr, uint32_t bfrLen, const char *eventType="log") override
Abstract interface to deliver formatted message.
Definition: HTTPembeddedServer.cpp:599
virtual int processHTTPheader(unsigned char *line, size_t lineLen)
User exit for HTTP header line.
Definition: read_file.hpp:732
ssize_t(* HTTPcallbackFP)(HTTP_SessionRecord *session, const char *cmd, char *url, unsigned char *block, size_t blockLen)
Signature for HTTP callback routine.
Definition: HTTPembeddedServer.hpp:391
unsigned char bytes[63]
Definition: HTTPembeddedServer.hpp:28
virtual void connectionEOF()
User-exit called when EOF reached on client connection.
Definition: HTTPembeddedServer.hpp:522
bool operator()(const HTTPstatusRecordKey &arg1, const HTTPstatusRecordKey &arg2) const
Definition: HTTPembeddedServer.hpp:811
#define AS_TEXT_BUFFER(s,...)
Convenience label to enable passing text with known length to output operator<<().
Definition: logging_api.hpp:2087
void removeHTTPsession(HTTP_SessionRecord *rec)
Definition: HTTPembeddedServer.cpp:587
pthread_t acceptThreadID
Definition: HTTPembeddedServer.hpp:612
Impose a circular buffer on a BufferRegion.
Definition: circular_bfr.hpp:330
HTTP_SessionRecord(IO_Processor *io, CircularBufferManager *mgr, const GenericSocketAddress *from, void *extraData=nullptr, size_t maxDocSize=1024 *128)
Create state record for current HTTP session.
Definition: HTTPembeddedServer.hpp:442
int errno
Definition: ethers.c:41
#define LOG_ERR
Definition: getether.c:23
std::map< const char *, const char *, ltCharPtrStr > OptionsAttrValMap_t
Definition: HTTPembeddedServer.hpp:395
#define OME_EXPECT_FALSE(expr)
Annotation macro for conditional expression expected to be false.
Definition: compiler_hints.h:540
#define LOG_COMPONENT_CERR(component, lvl)
Convenience macro that uses LOG_COMPONENT_INTO to conditionally log a message to standard error.
Definition: logging_api.hpp:3030
uint32_t usedLen
Definition: circular_bfr.hpp:107
uint16_t maxHTTPeventLength
Definition: HTTPembeddedServer.hpp:619
struct sockaddr genericAddr
Definition: HTTPembeddedServer.hpp:29
#define OME_ALWAYS_INLINE
Tell the compiler to alway inline a function, regardless of optimization level.
Definition: compiler_hints.h:364
bool operator<(const GenericSocketAddress &arg) const OME_ALWAYS_INLINE
Definition: HTTPembeddedServer.hpp:319
virtual HTTP_SessionRecord * acceptNewConnection(IO_Processor *io, CircularBufferManager *mgr, const GenericSocketAddress *from, void *extraData)=0
void addHTTPhandler(const char *cmd, HTTPcallbackFP routine)
Add a handler routine for an HTTP request command.
Definition: HTTPembeddedServer.hpp:500
#define report
Definition: getether.c:14
uint32_t blockLen
Definition: circular_bfr.hpp:106
HTTPstatusLog()
Definition: HTTPembeddedServer.hpp:930
int emitLogLineAsHTTPevent(IO_Processor *controller, uint32_t relLine, const char *additional)
Definition: HTTPembeddedServer.hpp:952
virtual bool interestedInEvent(const class HTTPeventStateRecord *record)
User-exit to filter out events when session has been converted into use with an HTTPstatusLog object.
Definition: HTTPembeddedServer.hpp:574
int waitForThreadStart(uint32_t mode)
Wait for threads to start.
Definition: io_processor.cpp:712
int emitLineAsHTTPevent(IO_Processor *controller, uint64_t eventId, const char *eventType, const unsigned char *lineData, uint32_t lineLen, const char *additional)
Definition: HTTPembeddedServer.cpp:473
int noteDataToProcess(bool alreadyLocked=false)
Note new data has arrived.
Definition: io_processor.cpp:803
void setOwnership(OwnershipState newOwnership)
Change administrative ownership of region.
Definition: circular_bfr.hpp:232
struct sockaddr_in ipv4
Definition: HTTPembeddedServer.hpp:30
int addIOblockThenProcess(SharedBufferAllocRecord *rec, IO_Processor *controller)
Specialized interface to add incoming block from BufferRegion maintained by an IO_Processor....
Definition: read_file.hpp:541
char httpVersion[16]
Definition: read_file.hpp:597
HTTPnotificationReceiverInterface()
Definition: HTTPembeddedServer.hpp:831
BufferRegion * bfrManager
buffer region
Definition: io_processor.hpp:194
#define LOG_ENDLINE
Closing clause for text line output using << operators.
Definition: logging_api.hpp:2956
virtual ssize_t handleHTTPrequest(unsigned char *block, size_t blockLen)
User-exit called when HTTP request read. Not normally overridden.
Definition: HTTPembeddedServer.cpp:155
GenericSocketAddress(const char *addressString)
Definition: HTTPembeddedServer.hpp:170
void * userData
Definition: HTTPembeddedServer.hpp:399
statusEventMap_t statusEvents
Definition: HTTPembeddedServer.hpp:908
@ CONTIGUOUS_BYTE_STREAM
contiguous byte stream from socket
Definition: io_processor.hpp:183
unsigned char desiredThreadState
Definition: io_processor.hpp:218
void setProcessRoutine(IO_processBlockFP func) OME_ALWAYS_INLINE
Set processing routine.
Definition: io_processor.hpp:344
#define OS_HANDLE_TYPE
Definition: io_processor.hpp:48
void closeConnection()
Close the connection associated with this HTTP session.
Definition: HTTPembeddedServer.cpp:115
SharedMemoryVariableNode namingNode
Definition: HTTPembeddedServer.hpp:857
uint32_t eventRecordsCreated
Definition: HTTPembeddedServer.hpp:904
Protocol-independent representation of a socket address. IPv4, IPv6 and file domain sockets are suppo...
Definition: HTTPembeddedServer.hpp:25
virtual int processHTTPheader(unsigned char *line, size_t lineLen) VIRTUAL_OVERRIDE
User exit to process incoming HTTP header.
Definition: HTTPembeddedServer.hpp:547
virtual int_fast32_t processBlock(unsigned char *blockStart, size_t blockLen) VIRTUAL_OVERRIDE
User-exit for receiving POSTed data.
Definition: HTTPembeddedServer.hpp:535
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.
Definition: HTTPembeddedServer.hpp:650
const char * findHeaderAttribute(const char *headerElement) const
Definition: read_file.hpp:620
@ BOTH_THREADS
Both a read and a processing thread will be spawned.
Definition: io_processor.hpp:164
void setLabelForThread(pthread_t threadId, const char *label)
Definition: io_processor.cpp:51
virtual ~HTTPembeddedServer()
Definition: HTTPembeddedServer.hpp:746
#define SA_SIGINFO
Definition: tmp.o.cpp:494
std::map< HTTPstatusRecordKey, HTTPeventStateRecord, ltHTTPstatusRecordKey > statusEventMap_t
Definition: HTTPembeddedServer.hpp:907
const HTTPeventStateRecord * locateEventRecord(const void *obj, const char *eventType) const
Find an event state record for the indicated object and event type.
Definition: HTTPembeddedServer.cpp:626
uint32_t linesAdded
Definition: HTTPembeddedServer.hpp:903
const void * extraData
Definition: HTTPembeddedServer.hpp:774
Implements HTTPnotificationReceiverInterface to maintain a history of events and log lines which are ...
Definition: HTTPembeddedServer.hpp:893
const char * getServerName() const
Returns the name associated with the HTTP server.
Definition: HTTPembeddedServer.hpp:700
int fd
Definition: ethers.c:41
@ MAX_STATUS_LINE_LENGTH
Definition: HTTPembeddedServer.hpp:773
bool listenActive
Definition: HTTPembeddedServer.hpp:622
uint64_t updateTime
Definition: HTTPembeddedServer.hpp:775
static ssize_t recvConsume(SharedBufferAllocRecord *rec, class IO_Processor *controller)
Definition: io_processor.cpp:279
char lineData[MAX_STATUS_LINE_LENGTH]
Definition: HTTPembeddedServer.hpp:779
struct HTTPstatusLog::@7 lineContent[MAX_LINES_HISTORY]
GenericSocketAddress(const char *address, uint16_t port)
Definition: HTTPembeddedServer.hpp:184
static int forwardBuffer(SharedBufferAllocRecord *rec, IO_Processor *controller)
IO_Processor-compatible processing routine used to forward buffer contents to a connect client.
Definition: HTTPembeddedServer.cpp:739
void publishEventState(const HTTPeventStateRecord *rec)
Definition: HTTPembeddedServer.cpp:687
#define LOG_CERR(lvl)
Convenience macro that uses LOG_INTO() to conditionally log a message to standard error.
Definition: logging_api.hpp:3014
#define EINTR
Definition: tmp.o.cpp:93