123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180 |
- #ifndef NULLSOFT_WAC_NETWORK_WEB_SERVER_H
- #define NULLSOFT_WAC_NETWORK_WEB_SERVER_H
- #include "netinc.h"
- #include "wac_network.h"
- #include "wac_network_web_server_api.h"
- #include "wac_network_page_generator_api.h"
- class WS_ItemList;
- class WS_conInst;
- class WebServerBaseClass : public api_webserv
- {
- public:
- WebServerBaseClass();
- virtual ~WebServerBaseClass();
- void initForFactory();
- void SetConnectionCallback( api_onconncb *_connectionCallback );
- void AllowCompression();
-
- void setMaxConnections( int max_con );
- void setRequestTimeout( int timeout_s );
-
- int addListenPort( int port, unsigned long which_interface = 0 );
- int getListenPort( int idx, int *err = 0 );
- void removeListenPort( int port );
- void removeListenIdx( int idx );
-
- void run( void );
-
-
-
- void attachConnection( WAC_Network_Connection *con, JNL_Listen *listener );
-
-
- void wasabi_url_encode( char *in, char *out, int max_out )
- {
- url_encode( in, out, max_out );
- }
- void wasabi_url_decode( char *in, char *out, int maxlen )
- {
- url_decode( in, out, maxlen );
- }
- void wasabi_base64decode( char *src, char *dest, int destsize )
- {
- base64decode( src, dest, destsize );
- }
- void wasabi_base64encode( char *src, char *dest )
- {
- base64encode( src, dest );
- }
- int wasabi_parseAuth( char *auth_header, char *out, int out_len )
- {
- return parseAuth( auth_header, out, out_len );
- }
-
-
- static void url_encode( char *in, char *out, int max_out );
- static void url_decode( char *in, char *out, int maxlen );
- static void base64decode( char *src, char *dest, int destsize );
- static void base64encode( char *in, char *out );
- static int parseAuth( char *auth_header, char *out, int out_len );
- protected:
- RECVS_DISPATCH;
- private:
- enum
- {
- RUN_CONNECTION_CONTINUE = 0,
- RUN_CONNECTION_DONE = 1,
- RUN_CONNECTION_ERROR = 2,
- RUN_CONNECTION_TIMEOUT = 3,
- };
- int run_connection( WS_conInst *con );
- int m_timeout_s;
- int m_max_con;
- WS_ItemList *m_listeners;
- int m_listener_rot;
- WS_ItemList *m_connections;
- api_onconncb *connectionCallback;
- bool allowCompression;
- char *extraDeflateBuffer;
- int extraDeflateBufferSize;
- int extraDeflateBufferUsed;
- void deflatehelper( WS_conInst *con, char *buf, int l, bool flush );
- };
- #endif
|