2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
42#ifndef WEB_HTTP_SERVER_REQUEST_H
43#define WEB_HTTP_SERVER_REQUEST_H
45#include "web/http/ConnectionState.h"
47#ifndef DOXYGEN_SHOULD_SKIP_THIS
49#include "web/http/CiStringMap.h"
58namespace web::http::
server {
70 const std::string&
get(
const std::string& key,
int i = 0)
const;
71 const std::string&
cookie(
const std::string& key)
const;
72 const std::string&
query(
const std::string& key)
const;
85 std::map<std::string, std::string>
queries;
91 Request(
int status,
const std::string& reason =
"");
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#define DECLARE_ROOTROUTE_REQUESTMETHOD(METHOD)
#define DECLARE_ROUTE_REQUESTMETHOD(METHOD)
#define DEFINE_ROUTE_TEMPLATE_REQUESTMETHOD(METHOD, HTTP_METHOD)
#define DECLARE_ROUTER_REQUESTMETHOD(METHOD)
#define APPLICATION(req, res)
#define MIDDLEWARE(req, res, next)
#define DEFINE_ROUTER_TEMPLATE_REQUESTMETHOD(METHOD, HTTP_METHOD)
utils::Timeval lastTriggered
virtual void timeoutEvent()=0
const utils::Timeval initialTimeout
DescriptorEventReceiver(const std::string &name, DescriptorEventPublisher &descriptorEventPublisher, const utils::Timeval &timeout=TIMEOUT::DISABLE)
utils::Timeval maxInactivity
void onSignal(int signum)
void triggered(const utils::Timeval ¤tTime)
virtual void dispatchEvent()=0
DescriptorEventPublisher & descriptorEventPublisher
int getRegisteredFd() const
void setEnabled(const utils::Timeval ¤tTime)
void onEvent(const utils::Timeval ¤tTime) final
void setTimeout(const utils::Timeval &timeout)
virtual void signalEvent(int signum)=0
void checkTimeout(const utils::Timeval ¤tTime)
utils::Timeval getTimeout(const utils::Timeval ¤tTime) const
Descriptor(Descriptor &&descriptor) noexcept
Descriptor & operator=(const Descriptor &descriptor)=delete
Descriptor & operator=(int fd)
Descriptor & operator=(Descriptor &&descriptor) noexcept
Descriptor(const Descriptor &d)=delete
const std::string & getName() const
static void atNextTick(const std::function< void(void)> &callBack)
virtual void onEvent(const utils::Timeval ¤tTime)=0
EventReceiver & operator=(EventReceiver &&)=delete
virtual ~EventReceiver()=default
EventReceiver(EventReceiver &)=delete
EventReceiver(const std::string &name)
EventReceiver(EventReceiver &&)=delete
EventReceiver & operator=(EventReceiver &)=delete
const std::string & getName() const
void dispatch(const utils::Timeval ¤tTime)
EventMultiplexer & eventMultiplexer
EventReceiver * eventReceiver
Event(EventReceiver *eventReceiver, const std::string &name)
EventReceiver * getEventReceiver() const
Observer(Observer &&)=delete
Observer(Observer &)=delete
virtual void unobservedEvent()=0
static void init(int argc, char *argv[])
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
virtual void acceptTimeout()
void signalEvent(int signum) override
AcceptEventReceiver(const std::string &name, const utils::Timeval &timeout)
virtual void acceptEvent()=0
void dispatchEvent() final
void timeoutEvent() final
virtual void readTimeout()
void dispatchEvent() final
virtual void readEvent()=0
void signalEvent(int signum) override
void timeoutEvent() final
ReadEventReceiver(const std::string &name, const utils::Timeval &timeout)
virtual void writeTimeout()
void signalEvent(int signum) override
WriteEventReceiver(const std::string &name, const utils::Timeval &timeout)
void timeoutEvent() final
void dispatchEvent() final
virtual void writeEvent()=0
Socket & operator=(Socket &&) noexcept=delete
const std::shared_ptr< Config > config
Socket & operator=(const Socket &)=default
Socket(const Socket &)=default
Socket(const std::shared_ptr< Config > &config)
Config & getConfig() const
Socket(Socket &&) noexcept=delete
Socket(const std::string &name)
State & operator^=(int state)
State & operator&=(int state)
static constexpr int DISABLED
bool operator==(const int &state) const
State operator&(int state)
State & operator=(int state)
static constexpr int ERROR
static constexpr int FATAL
State(const int &state, const std::string &file, const int &line)
State operator^(int state)
State(const int &state, const std::string &file, const int &line, int errnum, const std::string &errstr)
std::string where() const
static constexpr int NO_RETRY
State operator|(int state)
State & operator|=(int state)
void stopReconnectAndRetry()
bool isReconnectEnabled() const
AutoConnectControl & operator=(AutoConnectControl &&)=delete
AutoConnectControl(const AutoConnectControl &)=delete
bool cancelRetryScheduled
AutoConnectControl & operator=(const AutoConnectControl &)=delete
void cancelReconnectTimer()
bool cancelReconnectScheduled
void armReconnectTimer(double timeoutSeconds, const std::function< void()> &dispatcher)
bool isRetryEnabled() const
void armRetryTimer(double timeoutSeconds, const std::function< void()> &dispatcher)
std::unique_ptr< core::timer::Timer > reconnectTimer
std::unique_ptr< core::timer::Timer > retryTimer
AutoConnectControl(AutoConnectControl &&)=delete
std::function< void(SocketConnection *)> onConnected
SocketConnectionT< PhysicalServerSocket, Config > SocketConnection
PhysicalSocketServerT PhysicalServerSocket
SocketAcceptor(const SocketAcceptor &socketAcceptor)
SocketAddress bindAddress
SocketAcceptor(const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, const std::function< void(core::eventreceiver::AcceptEventReceiver *)> &onInitState, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, const std::shared_ptr< Config > &config)
std::function< void(SocketConnection *)> onConnect
std::function< void(SocketConnection *)> onDisconnect
void unobservedEvent() final
std::shared_ptr< Config > config
virtual void useNextSocketAddress()=0
typename PhysicalServerSocket::SocketAddress SocketAddress
~SocketAcceptor() override
PhysicalServerSocket physicalServerSocket
std::function< void(core::eventreceiver::AcceptEventReceiver *)> onInitState
std::function< void(const SocketAddress &, core::socket::State)> onStatus
SocketAddress remoteAddress
void onReceivedFromPeer(std::size_t available) final
void setReadTimeout(const utils::Timeval &timeout) final
bool streamToPeer(core::pipe::Source *source) final
std::size_t getTotalSent() const override
SocketConnectionT(PhysicalSocket &&physicalSocket, const std::function< void()> &onDisconnect, const std::shared_ptr< Config > &config)
core::socket::stream::SocketConnection Super
std::shared_ptr< Config > config
const SocketAddress & getBindAddress() const final
void doWriteShutdown(const std::function< void()> &onShutdown) override
void shutdownWrite() final
void writeTimeout() final
const SocketAddress & getRemoteAddress() const final
void sendToPeer(const char *chunk, std::size_t chunkLen) final
void setWriteTimeout(const utils::Timeval &timeout) final
std::function< void()> onDisconnect
void setTimeout(const utils::Timeval &timeout) final
PhysicalSocket physicalSocket
void onReadError(int errnum)
bool onSignal(int signum) final
std::size_t readFromPeer(char *chunk, std::size_t chunkLen) final
std::size_t getTotalProcessed() const override
SocketAddress localAddress
Config & getConfig() const
std::size_t getTotalRead() const override
void unobservedEvent() final
void onWriteError(int errnum)
SocketConnectionT()=delete
~SocketConnectionT() override
void shutdownRead() final
SocketWriterT SocketWriter
PhysicalSocketT PhysicalSocket
typename PhysicalSocket::SocketAddress SocketAddress
const SocketAddress & getLocalAddress() const final
std::size_t getTotalQueued() const override
SocketReaderT SocketReader
std::string connectionName
virtual void shutdownRead()=0
virtual void setReadTimeout(const utils::Timeval &timeout)=0
virtual void sendToPeer(const char *chunk, std::size_t chunkLen)=0
SocketConnection(int fd, const net::config::ConfigInstance *config)
core::socket::stream::SocketContext * newSocketContext
core::socket::stream::SocketContext * socketContext
virtual void setWriteTimeout(const utils::Timeval &timeout)=0
virtual const core::socket::SocketAddress & getLocalAddress() const =0
static std::string timePointToString(const std::chrono::time_point< std::chrono::system_clock > &timePoint)
virtual ~SocketConnection()
virtual void setTimeout(const utils::Timeval &timeout)=0
virtual const core::socket::SocketAddress & getBindAddress() const =0
void sentToPeer(const std::vector< char > &data)
const net::config::ConfigInstance * getConfigInstance() const
void sentToPeer(const std::vector< uint8_t > &data)
void setSocketContext(const std::shared_ptr< SocketContextFactory > &socketContextFactory)
static std::string durationToString(const std::chrono::time_point< std::chrono::system_clock > &bevore, const std::chrono::time_point< std::chrono::system_clock > &later=std::chrono::system_clock::now())
const std::string & getConnectionName() const
SocketConnection(const SocketConnection &)=delete
virtual void shutdownWrite()=0
void setSocketContext(SocketContext *socketContext)
virtual std::size_t getTotalRead() const =0
virtual std::size_t getTotalQueued() const =0
virtual const core::socket::SocketAddress & getRemoteAddress() const =0
virtual int getFd() const =0
virtual void streamEof()=0
void sendToPeer(const std::string &data)
virtual std::size_t readFromPeer(char *chunk, std::size_t chunkLen)=0
std::string getOnlineSince() const
std::string getOnlineDuration() const
virtual std::size_t getTotalSent() const =0
SocketContext * getSocketContext() const
std::chrono::time_point< std::chrono::system_clock > onlineSinceTimePoint
virtual bool streamToPeer(core::pipe::Source *source)=0
virtual std::size_t getTotalProcessed() const =0
const std::string & getInstanceName() const
std::size_t totalProcessed
void signalEvent(int sigNum) final
SocketReader(const std::string &instanceName, const std::function< void(int)> &onStatus, const utils::Timeval &timeout, std::size_t blockSize, const utils::Timeval &terminateTimeout)
std::vector< char > readBuffer
std::size_t readFromPeer(char *chunk, std::size_t chunkLen)
void setBlockSize(std::size_t readBlockSize)
utils::Timeval terminateTimeout
std::size_t getTotalProcessed() const
std::size_t getTotalRead() const
virtual void onReceivedFromPeer(std::size_t available)=0
virtual ssize_t read(char *chunk, std::size_t chunkLen)
std::function< void(int)> onStatus
SocketAcceptorT SocketAcceptor
SocketServer(Args &&... args)
const SocketServer & listen(const SocketAddress &localAddress, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
SocketServer(const std::shared_ptr< Config > &config, const std::shared_ptr< Context > &sharedContext)
std::shared_ptr< SocketContextFactory > getSocketContextFactory() const
SocketServer(const std::string &name, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, Args &&... args)
typename SocketAcceptor::SocketAddress SocketAddress
SocketServer(const std::string &name, Args &&... args)
SocketServer(const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, Args &&... args)
core::socket::Socket< typename SocketAcceptor::Config > Super
std::function< void(SocketConnection *)> & getOnDisconnect() const
const SocketServer & realListen(const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, unsigned int tries, double retryTimeoutScale) const
std::function< void(SocketConnection *)> & getOnConnected() const
std::function< void(core::eventreceiver::AcceptEventReceiver *)> & getOnInitState() const
const SocketServer & setOnConnected(const std::function< void(SocketConnection *)> &onConnected, bool initialize=false) const
const SocketServer & setOnConnect(const std::function< void(SocketConnection *)> &onConnect, bool initialize=false) const
const SocketServer & listen(const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
std::shared_ptr< Context > sharedContext
typename SocketAcceptor::SocketConnection SocketConnection
SocketServer & setOnDisconnect(const std::function< void(SocketConnection *)> &onDisconnect, bool initialize=false)
std::function< void(SocketConnection *)> & getOnConnect() const
SocketContextFactoryT SocketContextFactory
SocketServer(const std::shared_ptr< Config > &config, const std::shared_ptr< SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> onConnect, const std::function< void(SocketConnection *)> onConnected, const std::function< void(SocketConnection *)> onDisconnect)
const SocketServer & listen(const SocketAddress &localAddress, int backlog, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const SocketServer & setOnInitState(const std::function< void(core::eventreceiver::AcceptEventReceiver *)> &onInitState, bool initialize=false) const
const SocketServer & setOnAutoConnectControl(const std::function< void(const std::shared_ptr< AutoConnectControl > &)> &onAutoConnectControl, bool initialize=false) const
typename SocketAcceptor::Config Config
std::function< void(const std::shared_ptr< AutoConnectControl > &)> & getOnAutoConnectControl()
virtual void doWriteShutdown(const std::function< void()> &onShutdown)=0
utils::Timeval terminateTimeout
std::function< void(int)> onStatus
void setBlockSize(std::size_t writeBlockSize)
void sendToPeer(const char *chunk, std::size_t chunkLen)
core::pipe::Source * source
std::vector< char > writePuffer
void signalEvent(int sigNum) final
std::function< void()> onShutdown
std::size_t getTotalSent() const
virtual bool onSignal(int sigNum)=0
void shutdownWrite(const std::function< void()> &onShutdown)
std::size_t getTotalQueued() const
bool streamToPeer(core::pipe::Source *source)
virtual ssize_t write(const char *chunk, std::size_t chunkLen)
SocketWriter(const std::string &instanceName, const std::function< void(int)> &onStatus, const utils::Timeval &timeout, std::size_t blockSize, const utils::Timeval &terminateTimeout)
SocketAcceptor(const std::shared_ptr< core::socket::stream::SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, const std::function< void(core::eventreceiver::AcceptEventReceiver *)> &onInitState, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus, const std::shared_ptr< Config > &config)
void useNextSocketAddress() override
typename Super::Config Config
typename Super::SocketAddress SocketAddress
typename Super::SocketConnection SocketConnection
core::socket::stream::SocketAcceptor< PhysicalServerSocketT, ConfigT, core::socket::stream::legacy::SocketConnection > Super
SocketAcceptor(const SocketAcceptor &socketAcceptor)
PhysicalSocketT PhysicalSocket
SocketConnection(PhysicalSocket &&physicalSocket, const std::function< void(SocketConnection *)> &onDisconnect, const std::shared_ptr< Config > &config)
typename Super::SocketWriter SocketWriter
typename Super::SocketReader SocketReader
core::socket::stream::SocketConnectionT< PhysicalSocketT, core::socket::stream::legacy::SocketReader, core::socket::stream::legacy::SocketWriter, ConfigT > Super
typename Super::SocketAddress SocketAddress
core::socket::stream::SocketReader Super
core::socket::stream::SocketWriter Super
void next(const std::string &how) const
bool dispatchNext(bool strictRouting, bool caseInsensitiveRouting, bool mergeParams)
Controller(const std::shared_ptr< web::http::server::Request > &request, const std::shared_ptr< web::http::server::Response > &response)
const std::shared_ptr< Request > & getRequest() const
const std::shared_ptr< Response > & getResponse() const
std::shared_ptr< Response > response
Controller(const Controller &controller)
void setCurrentRoute(Route *currentRoute)
bool nextRouterCalled() const
void setRootRoute(RootRoute *rootRoute)
std::shared_ptr< Request > request
Controller & operator=(const Controller &controller) noexcept
void operator()(const std::string &how="") const
Next(Controller &controller)
web::http::CiStringMap< std::string > cookies
Request(Request &&) noexcept=delete
const std::string & cookie(const std::string &key) const
Request & operator=(Request &&) noexcept=delete
std::map< std::string, std::string > params
const std::string & get(const std::string &key, int i=0) const
Request(const std::shared_ptr< web::http::server::Request > &request) noexcept
std::shared_ptr< web::http::server::Request > requestBase
Request(Request &)=delete
const std::string & query(const std::string &key) const
web::http::CiStringMap< std::string > headers
const std::string & param(const std::string &id, const std::string &fallBack="")
std::map< std::string, std::string > queries
web::http::CiStringMap< std::string > trailer
Request & operator=(Request &)=delete
void download(const std::string &file, const std::string &fileName, const std::function< void(int)> &onError)
void redirect(const std::string &loc, const std::string &html={})
std::shared_ptr< web::http::server::Response > responseBase
Response & attachment(const std::string &fileName="")
Response & cookie(const std::string &name, const std::string &value, const std::map< std::string, std::string > &options={})
void redirect(int state, const std::string &loc, const std::string &html={})
Response & clearCookie(const std::string &name, const std::map< std::string, std::string > &options={})
Response(Response &&) noexcept=delete
Response & operator=(Response &&) noexcept=delete
void sendFile(const std::string &file, const std::function< void(int)> &callback)
void sendStatus(int state, const std::string &html={})
void download(const std::string &file, const std::function< void(int)> &onError)
Response & set(const std::string &field, const std::string &value, bool overwrite=true)
Response & setTrailer(const std::string &field, const std::string &value, bool overwrite=true)
Response & sendFragment(const char *chunk, std::size_t chunkLen)
Response & append(const std::string &field, const std::string &value)
Response & sendFragment(const std::string &chunk="")
void send(const std::string &chunk)
Response(const std::shared_ptr< web::http::server::Response > &response) noexcept
Response & status(int status)
Response(Response &)=delete
void send(const char *chunk, std::size_t chunkLen)
Response & vary(const std::string &field)
Response & operator=(Response &)=delete
Response & type(const std::string &type)
Response & set(const std::map< std::string, std::string > &headers, bool overwrite=true)
web::http::server::SocketContext * getSocketContext() const
const std::string & header(const std::string &field)
void json(const nlohmann::json &json)
void upgrade(const std::shared_ptr< Request > &request, const std::function< void(const std::string)> &status)
Response & location(const std::string &loc)
RootRoute & setMergeParams(bool mergeParams)
void dispatch(Controller &&controller)
void dispatch(Controller &controller)
Route & head(const RootRoute &rootRoute) const
Route & del(const RootRoute &rootRoute) const
bool getStrictRouting() const
Route & connect(const RootRoute &rootRoute) const
std::list< std::string > getRoutes() const
std::list< Route > & routes() const
Route & get(const RootRoute &rootRoute) const
Route & trace(const RootRoute &rootRoute) const
Route & use(const RootRoute &rootRoute) const
Route & post(const RootRoute &rootRoute) const
Route & put(const RootRoute &rootRoute) const
bool getMergeParams() const
bool getCaseInsensitiveRouting() const
RootRoute & setCaseInsensitiveRouting(bool caseInsensitiveRouting)
Route & options(const RootRoute &rootRoute) const
Route & all(const RootRoute &rootRoute) const
std::shared_ptr< dispatcher::RouterDispatcher > getDispatcher() const
Route & patch(const RootRoute &rootRoute) const
RootRoute & setStrictRouting(bool strictRouting)
Route & patch(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
std::shared_ptr< Dispatcher > dispatcher
Route & put(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & head(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
bool dispatchNext(Controller &controller, bool strictRouting, bool caseInsensitiveRouting, bool mergeParams)
Route & use(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & connect(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route(const std::string &method, const std::string &relativeMountPath, const std::shared_ptr< Dispatcher > &dispatcher)
Route & options(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & all(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & del(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & get(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & post(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
std::list< std::string > getRoute(const std::string &parentMountPath, bool strictRouting) const
bool dispatch(Controller &controller, bool strictRouting, bool caseInsensitiveRouting, bool mergeParams)
Route & trace(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &lambda) const
Route & head(const Router &router) const
Route & all(const Router &router) const
const Router & setCaseInsensitiveRouting(bool caseInsensitiveRouting=true) const
const Router & setStrictRouting(bool strictRouting=true) const
Route & options(const Router &router) const
Route & connect(const Router &router) const
Route & post(const Router &router) const
Route & del(const Router &router) const
Router(const Router &)=default
Route & use(const Router &router) const
Route & get(const Router &router) const
Route & trace(const Router &router) const
Route & patch(const Router &router) const
const Router & setMergeParams(bool mergeParams=true) const
std::list< std::string > getRoutes() const
Route & put(const Router &router) const
std::shared_ptr< RootRoute > rootRoute
WebAppT(const std::string &name, const Router &router)
typename Server::SocketConnection SocketConnection
express::Response Response
typename Server::SocketAddress SocketAddress
WebAppT(const std::string &name)
static void init(int argc, char *argv[])
static core::TickStatus tick(const utils::Timeval &timeOut=0)
static core::State state()
static int start(const utils::Timeval &timeOut={LONG_MAX, 0})
WebApp(const Router &router)
LogMessage(Level level, int verboseLevel=-1, bool withErrno=false)
SocketAddress(const SockAddr &sockAddr, SockLen sockAddrLen)
const SockLen & getSockAddrLen() const
SocketAddress & operator=(const SocketAddress &socketAddress)
SocketAddress(const SocketAddress &socketAddress)
SocketAddress(sa_family_t af, SockLen sockAddrLen=sizeof(SockAddr))
const sockaddr & getSockAddr()
sa_family_t getAddressFamily() const
virtual ~ConfigAddressBase()=default
ConfigAddressBase(net::config::ConfigSection *section)
ConfigAddressBase(ConfigInstance *instance, const std::string &addressOptionName="", const std::string &addressOptionDescription="")
SocketAddressT getSocketAddress(const typename SocketAddressT::SockAddr &sockAddr, typename SocketAddressT::SockLen sockAddrLen)
static constexpr std::string_view DESCRIPTION
net::config::ConfigAddress< SocketAddressT > Super
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
net::config::ConfigAddress< SocketAddressT > Super
static constexpr std::string_view NAME
static constexpr std::string_view DESCRIPTION
static constexpr std::string_view NAME
net::config::ConfigAddressBase< SocketAddressT > Super
SocketAddress * socketAddress
virtual void configurable(bool configurable)=0
SocketAddressT SocketAddress
ConfigAddress(net::config::ConfigSection *section)
ConfigAddressBase< SocketAddressT > Super
SocketAddress & getSocketAddress()
ConfigAddress(ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
~ConfigAddress() override
virtual SocketAddress * init()=0
ConfigConnection & setWriteBlockSize(std::size_t newWriteBlockSize)
std::size_t getWriteBlockSize() const
static constexpr std::string_view NAME
ConfigConnection & setWriteTimeout(const utils::Timeval &newWriteTimeoutSet)
ConfigConnection(ConfigInstance *instance)
CLI::Option * terminateTimeoutOpt
CLI::Option * readBlockSizeOpt
CLI::Option * readTimeoutOpt
CLI::Option * writeTimeoutOpt
utils::Timeval getWriteTimeout() const
CLI::Option * writeBlockSizeOpt
ConfigConnection & setTerminateTimeout(const utils::Timeval &newTerminateTimeout)
~ConfigConnection() override
ConfigConnection & setReadBlockSize(std::size_t newReadBlockSize)
static constexpr std::string_view DESCRIPTION
ConfigConnection & setReadTimeout(const utils::Timeval &newReadTimeoutSet)
utils::Timeval getTerminateTimeout() const
std::size_t getReadBlockSize() const
utils::Timeval getReadTimeout() const
static CLI::App * getCommandlineTriggerApp()
ConfigInstance(ConfigInstance &&)=delete
static CLI::App * getShowConfigTriggerApp()
~ConfigInstance() override
ConfigInstance(ConfigInstance &)=delete
ConfigInstance(const std::string &instanceName, Role role)
static const std::string nameAnonymous
ConfigInstance & operator=(ConfigInstance &)=delete
ConfigInstance & configurable(bool configurable)
static CLI::App * getHelpTriggerApp()
ConfigInstance & setInstanceName(const std::string &instanceName)
const std::string & getInstanceName() const
ConfigInstance & operator=(ConfigInstance &&)=delete
ConfigInstance & setDisabled(bool disabled=true)
static constexpr std::string_view NAME
ConfigLegacy(ConfigInstance *instance)
static constexpr std::string_view DESCRIPTION
ConfigPhysicalSocketServer(ConfigInstance *instance)
utils::Timeval getAcceptTimeout() const
CLI::Option * acceptTimeoutOpt
ConfigPhysicalSocketServer & setAcceptTimeout(const utils::Timeval &acceptTimeout)
CLI::Option * acceptsPerTickOpt
ConfigPhysicalSocketServer & setBacklog(int newBacklog)
int getAcceptsPerTick() const
ConfigPhysicalSocket Super
~ConfigPhysicalSocketServer() override
ConfigPhysicalSocketServer & setAcceptsPerTick(int acceptsPerTickSet)
static constexpr std::string_view DESCRIPTION
static uint16_t retryTries
ConfigPhysicalSocket & setRetryTimeout(double sec)
static constexpr std::string_view NAME
double getRetryTimeout() const
unsigned int getRetryTries() const
static float retryTimeout
ConfigPhysicalSocket & setRetryJitter(double percent)
CLI::Option * retryJitterOpt
double getRetryJitter() const
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, int optValue)
unsigned int getRetryLimit() const
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, const std::string &optValue)
CLI::Option * retryBaseOpt
std::map< int, std::map< int, net::phy::PhysicalSocketOption > > socketOptionsMapMap
bool getRetryOnFatal() const
ConfigPhysicalSocket & removeSocketOption(int optLevel, int optName)
CLI::Option * retryTriesOpt
static const std::string retry
ConfigPhysicalSocket & setRetryOnFatal(bool retry=true)
ConfigPhysicalSocket & addSocketOption(int optLevel, int optName, const std::vector< char > &optValue)
ConfigPhysicalSocket & setRetryLimit(unsigned int limit)
double getRetryBase() const
ConfigPhysicalSocket(ConfigInstance *instance, ConcretConfigPhysicalSocketT *section)
ConfigPhysicalSocket & setRetry(bool retry=true)
~ConfigPhysicalSocket() override
const std::map< int, std::map< int, net::phy::PhysicalSocketOption > > & getSocketOptions() const
ConfigPhysicalSocket & setRetryBase(double base)
CLI::Option * addSocketOption(const std::string &name, int optLevel, int optName, const std::string &description, const std::string &typeName, const std::string &defaultValue, const CLI::Validator &validator)
CLI::Option * retryOnFatalOpt
CLI::Option * retryTimeoutOpt
CLI::Option * retryLimitOpt
static const std::string retryOnFatal
ConfigPhysicalSocket & setRetryTries(unsigned int tries=0)
~ConfigSection() override
ConfigSection(const ConfigSection &)=delete
ConfigSection(ConfigInstance *instance, T *sectionPtr, const std::string &group="Sections")
ConfigSection(ConfigSection &&)=delete
ConfigSection & operator=(const ConfigSection &)=delete
ConfigAddressRemoteT< net::config::ConfigAddressReverse > Remote
net::config::ConfigConnection Connection
ConfigSocketServer(net::config::ConfigInstance *instance)
net::config::ConfigPhysicalSocketServer Socket
ConfigAddressLocalT< net::config::ConfigAddressLocal > Local
ConfigSocketServer(const std::string &name)
net::config::ConfigLegacy Legacy
net::config::ConfigInstance Instance
SocketAddress & setPort(uint16_t port)
SocketAddress(const std::string &ipOrHostname, uint16_t port)
SocketAddress & setHost(const std::string &ipOrHostname)
SocketAddress(uint16_t port)
SocketAddress(const std::string &ipOrHostname)
std::string getHost() const
net::SocketAddress< sockaddr_in > Super
std::string getCanonName() const
std::shared_ptr< SocketAddrInfo > socketAddrInfo
SocketAddress(const SockAddr &sockAddr, SockLen sockAddrLen, bool numeric=true)
std::string getEndpoint(const std::string_view &format={}) const override
std::string toString(bool expanded=true) const override
void init(const Hints &hints={.aiFlags=0,.aiSockType=0,.aiProtocol=0})
ConfigAddressReverse(net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddressReverse & setNumericReverse(bool numeric=true)
bool getNumericReverse() const
ConfigAddressTypeT< SocketAddress > Super
CLI::Option * numericReverseOpt
SocketAddress getSocketAddress(const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
int getAiProtocol() const
SocketAddress getSocketAddress(const SocketAddress::SockAddr &sockAddr, SocketAddress::SockLen sockAddrLen)
ConfigAddress & setAiSockType(int aiSockType)
ConfigAddress & setPortRequired(bool required=true)
ConfigAddress & setSocketAddress(const SocketAddress &socketAddress)
ConfigAddressTypeT< net::in::SocketAddress > Super
ConfigAddress(net::config::ConfigInstance *instance, const std::string &addressOptionName, const std::string &addressOptionDescription)
ConfigAddress & setHostRequired(bool required=true)
ConfigAddress & setHost(const std::string &ipOrHostname)
SocketAddress * init() final
ConfigAddress & setAiFlags(int aiFlags)
int getAiSockType() const
ConfigAddress & setNumeric(bool numeric=true)
bool getNumericReverse() const
ConfigAddress & setAiProtocol(int aiProtocol)
void configurable(bool configurable=true) final
ConfigAddress & setNumericReverse(bool numeric=true)
ConfigAddress & setPort(uint16_t port)
std::string getHost() const
CLI::Option * numericReverseOpt
~PhysicalSocket() override
PhysicalSocket(PhysicalSocket &&) noexcept=default
PhysicalSocket(int type, int protocol)
PhysicalPeerSocketT< net::in::SocketAddress > Super
PhysicalSocketServer(PhysicalSocketServer &&) noexcept=default
net::in::phy::stream::PhysicalSocket< net::phy::stream::PhysicalSocketServer > Super
~PhysicalSocketServer() override
~PhysicalSocket() override
PhysicalSocket(PhysicalSocket &&) noexcept=default
net::in::phy::PhysicalSocket< PhysicalPeerSocketT > Super
const Super & listen(const std::string &ipOrHostname, uint16_t port, int backlog, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const Super & listen(uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const Super & listen(uint16_t port, int backlog, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
const Super & listen(const std::string &ipOrHostname, uint16_t port, const std::function< void(const SocketAddress &, core::socket::State)> &onStatus) const
core::socket::stream:: SocketServer< SocketAcceptorT< net::in::phy::stream::PhysicalSocketServer, ConfigSocketServerT >, SocketContextFactoryT, Args... > Super
~ConfigSocketServer() override
CLI::Option * disableNagleAlgorithmOpt
bool getReusePort() const
ConfigSocketServer & setReusePort(bool reusePort=true)
bool getReuseAddress() const
bool getDisableNagleAlgorithm() const
ConfigSocketServer & setReuseAddress(bool reuseAddress=true)
ConfigSocketServer(net::config::ConfigInstance *instance)
CLI::Option * reusePortOpt
ConfigSocketServer & setDisableNagleAlgorithm(bool disableNagleAlgorithm=true)
CLI::Option * reuseAddressOpt
~ConfigSocketServer() override
ConfigSocketServer(const std::string &name)
PhysicalSocketOption()=default
socklen_t getOptLen() const
const void * getOptValue() const
PhysicalSocketOption(int optLevel, int optName, int optValue)
std::vector< char > optValue
PhysicalSocketOption(int optLevel, int optName, const std::vector< char > &optValue)
PhysicalSocketOption(int optLevel, int optName, const std::string &optValue)
int open(const std::map< int, std::map< int, PhysicalSocketOption > > &socketOptionsMapMap, Flags flags)
int getPeerName(typename SocketAddress::SockAddr &remoteSockAddr, typename SocketAddress::SockLen &remoteSockAddrLen)
PhysicalSocket(const PhysicalSocket &)=delete
PhysicalSocket(int domain, int type, int protocol)
SocketAddressT SocketAddress
int setSockopt(int level, int optname, const void *optval, typename SocketAddress::SockLen optlen) const
int getSockError(int &cErrno) const
PhysicalSocket(PhysicalSocket &&physicalSocket) noexcept=default
PhysicalSocket & operator=(PhysicalSocket &)=delete
PhysicalSocket & operator=(const PhysicalSocket &)=delete
~PhysicalSocket() override
PhysicalSocket(PhysicalSocket &)=delete
int bind(SocketAddress &bindAddress)
PhysicalSocket & operator=(PhysicalSocket &&) noexcept=default
PhysicalSocket(int fd, const SocketAddress &bindAddress)
int getSockName(typename SocketAddress::SockAddr &localSockAddr, typename SocketAddress::SockLen &localSockAddrLen)
SocketAddress bindAddress
const SocketAddress & getBindAddress() const
int getSockopt(int level, int optname, void *optval, typename SocketAddress::SockLen *optlen) const
net::phy::stream::PhysicalSocket< SocketAddressT > Super
SocketAddressT SocketAddress
SocketAddressT SocketAddress
net::phy::PhysicalSocket< SocketAddressT > Super
constexpr AttributeProxy(const Attribute &attribute)
constexpr Attribute & operator*()
constexpr bool setAttribute(const Attribute &&attribute, const std::string &subKey="", bool overwrite=false)
constexpr bool hasAttribute(const std::string &subKey="") const
constexpr bool delAttribute(const std::string &subKey="")
bool getAttribute(const std::function< void(Attribute &)> &onFound, const std::string &subKey="") const
std::map< std::string, std::shared_ptr< void > > attributes
void getAttribute(const std::function< void(Attribute &)> &onFound, const std::function< void(const std::string &)> &onNotFound, const std::string &subKey="") const
constexpr bool setAttribute(const Attribute &attribute, const std::string &subKey="", bool overwrite=false)
static double getInRange(double ll, double ul)
constexpr void getAttribute(const std::function< void(Attribute &)> &onFound, const std::function< void(const std::string &)> &onNotFound) const
std::string attributeType
constexpr bool setAttribute(const Attribute &attribute, bool overwrite=false)
constexpr bool setAttribute(const Attribute &&attribute, bool overwrite=false)
std::shared_ptr< void > attribute
constexpr bool getAttribute(const std::function< void(Attribute &)> &onFound) const
const timeval * operator&() const
bool operator>(const Timeval &timeVal) const
friend Timeval operator*(double mul, const Timeval &timeVal)
bool operator<(const Timeval &timeVal) const
Timeval operator*(double mul) const
Timeval(const std::initializer_list< time_t > &initList) noexcept
Timeval operator-() const
static Timeval currentTime()
bool operator<=(const Timeval &timeVal) const
bool operator!=(const Timeval &timeVal) const
timespec getTimespec() const
Timeval operator-(const Timeval &timeVal) const
Timeval & operator=(const timeval &timeVal)
Timeval & operator+=(const Timeval &timeVal)
bool operator==(const Timeval &timeVal) const
Timeval & operator-=(const Timeval &timeVal)
Timeval operator+(const Timeval &timeVal) const
Timeval & operator=(const Timeval &timeVal)
Timeval & operator*=(double mul)
bool operator>=(const Timeval &timeVal) const
Timeval(double time) noexcept
Timeval(const Timeval &timeVal) noexcept=default
Timeval(const timeval &timeVal) noexcept
const Timeval & normalize()
friend enum HTTPCompliance operator&(const enum HTTPCompliance &c1, const enum HTTPCompliance &c2)
virtual void parseError(int code, const std::string &reason)=0
Parser(core::socket::stream::SocketContext *socketContext, const enum HTTPCompliance &compliance=HTTPCompliance::RFC2616|HTTPCompliance::RFC7230)
static const std::regex httpVersionRegex
friend enum HTTPCompliance operator|(const enum HTTPCompliance &c1, const enum HTTPCompliance &c2)
std::size_t contentLength
virtual void parseStartLine(const std::string &line)=0
std::size_t contentLengthRead
web::http::decoder::Fields headerDecoder
core::socket::stream::SocketContext * socketContext
CiStringMap< std::string > headers
std::size_t readContent()
std::list< web::http::ContentDecoder * > decoderQueue
virtual void parsingFinished()=0
TransferEncoding transferEncoding
std::size_t readTrailer()
std::vector< char > content
std::size_t readStartLine()
virtual void analyzeHeader()
std::set< std::string > trailerFieldsExpected
web::http::decoder::Fields trailerDecoder
std::string getErrorReason() const
Fields(core::socket::stream::SocketContext *socketContext, std::set< std::string > fieldsExpected={})
core::socket::stream::SocketContext * socketContext
web::http::CiStringMap< std::string > fields
Fields & operator=(Fields &)=delete
void splitLine(const std::string &line)
std::size_t maxLineLength
void setFieldsExpected(std::set< std::string > fieldsExpected)
std::set< std::string > fieldsExpected
Fields & operator=(Fields &&)=delete
web::http::CiStringMap< std::string > && getHeader()
RequestParser & operator=(const RequestParser &)=delete
void parsingFinished() override
void parseStartLine(const std::string &line) override
void parseError(int code, const std::string &reason) override
std::function< void(int, const std::string &)> onRequestParseError
std::function< void(Request &&)> onRequestParsed
std::set< std::string > supportedMethods
virtual bool methodSupported(const std::string &method) const
void analyzeHeader() override
RequestParser(const RequestParser &)=delete
std::function< void()> onRequestStart
RequestParser(core::socket::stream::SocketContext *socketContext, const std::function< void()> &onRequestStart, const std::function< void(Request &&)> &onRequestParsed, const std::function< void(int, const std::string &)> &onRequestParseError)
Request & operator=(Request &&) noexcept=delete
CiStringMap< std::string > cookies
const std::string & query(const std::string &key) const
CiStringMap< std::string > headers
std::map< std::string, std::string > queries
Request(Request &&) noexcept=default
Request(int status, const std::string &reason="")
const std::string & cookie(const std::string &key) const
const std::string & get(const std::string &key, int i=0) const
Request(Request &)=delete
ConnectionState connectionState
Request & operator=(Request &)=delete
Server(const std::string &name, std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &&onRequestReady)
Server(const std::string &name, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &&onRequestReady)
SocketServerT< web::http::server::SocketContextFactory, std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> > Super
typename SocketConnection::SocketAddress SocketAddress
Server(const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect, std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &&onRequestReady)
Server(const std::function< void(const std::shared_ptr< Request > &, std::shared_ptr< Response > &)> &&onRequestReady)
web::http::server::Request Request
web::http::server::Response Response
typename Super::SocketConnection SocketConnection
std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> onRequestReady
core::socket::stream::SocketContext * create(core::socket::stream::SocketConnection *socketConnection) override
web::http::server::Request Request
web::http::server::Response Response
SocketContextFactory(const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onRequestReady)
bool onSignal(int signum) override
std::list< std::function< void()> > onDisconnectEventReceiverList
void onConnected() override
void onDisconnected() override
void responseCompleted(const Response &response, bool success)
std::shared_ptr< Response > masterResponse
core::socket::stream::SocketContext Super
web::http::server::Response Response
std::size_t onReceivedFromPeer() override
void onWriteError(int errnum) override
std::list< std::function< void()> > onConnectEventReceiverList
void responseStarted(const Response &response)
void requestCompleted(const Response &response)
SocketContext(core::socket::stream::SocketConnection *socketConnection, const std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> &onRequestReady)
std::function< void(const std::shared_ptr< Request > &, const std::shared_ptr< Response > &)> onRequestReady
web::http::server::Request Request
SocketContext * onConnected(std::function< void()> onConnectEventReceiver)
SocketContext * onDisconnected(std::function< void()> onDisconnectEventReceiver)
std::list< std::shared_ptr< Request > > pendingRequests
int main(int argc, char *argv[])
std::vector< json > Trace
static void ensureTrace(const std::shared_ptr< express::Request > &req)
static void tracePush(const std::shared_ptr< express::Request > &req, const std::string &label)
static json snapshot(const std::shared_ptr< express::Request > &req, const std::string &label)
static json traceGet(const std::shared_ptr< express::Request > &req)
SocketServer Server(const std::string &instanceName, const std::function< void(typename SocketServer::Config &)> &configurator, Args &&... socketContextFactoryArgs)
SocketServer Server(const std::string &instanceName, Args &&... socketContextFactoryArgs)
SocketServer< SocketContextFactory, SocketContextFactoryArgs... > Server(const std::string &instanceName, const std::function< void(net::in::stream::legacy::config::ConfigSocketServer &)> &configurator, SocketContextFactoryArgs &&... socketContextFactoryArgs)
SocketServer< SocketContextFactory, SocketContextFactoryArgs... > Server(const std::string &instanceName, SocketContextFactoryArgs &&... socketContextFactoryArgs)
net::in::stream::SocketServer< core::socket::stream::legacy::SocketAcceptor, net::in::stream::legacy::config::ConfigSocketServer, SocketContextFactoryT, Args... > SocketServer
fixed_string(char const (&)[N]) -> fixed_string< N - 1 >
web::http::server::Server< net::in::stream::legacy::SocketServer > Server
static const utils::Timeval MAX
static const utils::Timeval DISABLE
static const utils::Timeval DEFAULT
std::shared_ptr< SocketContextFactory > socketContextFactory
std::function< void(SocketConnection *)> onConnected
std::function< void(SocketConnection *)> onConnect
std::function< void(core::eventreceiver::AcceptEventReceiver *)> onInitState
Context(const std::shared_ptr< SocketContextFactory > &socketContextFactory, const std::function< void(SocketConnection *)> &onConnect, const std::function< void(SocketConnection *)> &onConnected, const std::function< void(SocketConnection *)> &onDisconnect)
std::function< void(const std::shared_ptr< AutoConnectControl > &)> onAutoConnectControl
std::shared_ptr< AutoConnectControl > autoConnectControl
std::function< void(SocketConnection *)> onDisconnect
MountPoint(const std::string &method, const std::string &relativeMountPath)
std::string relativeMountPath
auto operator<=>(const fixed_string &) const =default
constexpr fixed_string(char const *s)
constexpr operator char const *() const