ZFFramework
Loading...
Searching...
No Matches
ZFHttpServer.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFHttpServer_h_
7#define _ZFI_ZFHttpServer_h_
8
9#include "ZFHttpRequest.h"
11
13zfabstract ZFLIB_ZFNet ZFHttpServerTask : zfextend ZFObject {
14 ZFOBJECT_DECLARE_ABSTRACT(ZFHttpServerTask, ZFObject)
15
16 // ============================================================
17 // recv
18public:
23
24public:
29 , ZFMP_IN(const zfstring &, key)
30 )
31
32
36 , ZFMP_IN(const zfiter &, it)
37 )
40 , ZFMP_IN(const zfiter &, it)
41 )
42
43public:
48 , ZFMP_IN(const zfstring &, key)
49 )
50
55 , ZFMP_IN(const zfiter &, it)
56 )
59 , ZFMP_IN(const zfiter &, it)
60 )
61
62public:
75
76 // ============================================================
77 // resp
78public:
81 , ZFMP_IN(zfuint, code)
82 )
83
86 , ZFMP_IN(const zfstring &, value)
87 , ZFMP_IN(const zfstring &, contentType)
88 )
91 , ZFMP_IN(const ZFInput &, value)
92 , ZFMP_IN(const zfstring &, contentType)
93 )
94
95public:
100 , ZFMP_IN(const zfstring &, key)
102
107 , ZFMP_IN(const zfiter &, it)
111 , ZFMP_IN(const zfiter &, it)
113
116 , ZFMP_IN(const zfstring &, key)
117 , ZFMP_IN(const zfstring &, value)
121 , ZFMP_IN(const zfstring &, key)
125 , ZFMP_IN(const zfstring &, key)
129 , ZFMP_IN_OUT(zfiter &, it)
130 , ZFMP_IN(const zfstring &, value)
134 , ZFMP_IN_OUT(zfiter &, it)
136
137 // ============================================================
138 // util
139public:
144
145protected:
148};
149
150// ============================================================
164zfclass ZFLIB_ZFNet ZFHttpServer : zfextend ZFObject, zfimplement ZFTaskId {
165 ZFOBJECT_DECLARE(ZFHttpServer, ZFObject)
166 ZFIMPLEMENT_DECLARE(ZFTaskId)
167
168
174 ZFEVENT(OnRequest)
175
179 ZFEVENT(OnStart)
183 ZFEVENT(OnStop)
190 ZFEVENT(OnError)
191
192public:
203 ZFMP_IN(const zfstring &, addr)
206
209
212
215
222
227
232
237 , ZFMP_IN(const ZFListener &, impl)
239
240public:
241 zffinal void _ZFP_ZFHttpServer_onError(ZF_IN const zfstring &errorHint);
242
243protected:
245 virtual void objectOnInit(void);
247 virtual void objectOnDeallocPrepare(void);
248protected:
251
252private:
253 void *d;
254};
255
259zfclass ZFLIB_ZFNet ZFHttpServerThreadPool : zfextend ZFThreadPool {
260 ZFOBJECT_DECLARE(ZFHttpServerThreadPool, ZFThreadPool)
261 ZFOBJECT_SINGLETON_DECLARE(ZFHttpServerThreadPool, instance)
262};
263
265#endif // #ifndef _ZFI_ZFHttpServer_h_
266
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:198
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:214
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
_zft_zftimet zftimet
time unit, ensured at least 64 bit, ensured signed
Definition ZFCoreTypeDef_CoreType.h:203
_ZFT_t_zfuint zfuint
same as unsigned int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:169
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
http operation
v_ZFHttpMethod::ZFEnumType ZFHttpMethod
see v_ZFHttpMethod
Definition ZFHttpRequest.h:35
#define ZFMP_IN_OUT(ParamType, paramName)
see ZFMP_IN
Definition ZFMethod.h:117
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:692
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:853
#define ZFMETHOD_INTERFACE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodInterfaceDeclare.h:145
#define ZFMETHOD_INTERFACE_2(ReturnType, MethodName, ZFMP_0, ZFMP_1)
see ZFMethod
Definition ZFMethodInterfaceDeclare.h:227
#define ZFMETHOD_INTERFACE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodInterfaceDeclare.h:68
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define ZFLIB_ZFNet
used to export symbols
Definition ZFNetDef.h:15
#define zfabstract
typename for class showing that its abstract
Definition ZFObjectClassTypeFwd.h:42
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_ON_INIT_DECLARE_2(ZFMP_0, ZFMP_1)
see ZFOBJECT_ON_INIT_INLINE_1
Definition ZFObjectDeclare.h:286
#define ZFOBJECT_DECLARE_ABSTRACT(ChildClass, SuperClass,...)
necessary for every abstract class inherit from ZFObject
Definition ZFObjectDeclare.h:148
#define ZFOBJECT_ON_INIT_DECLARE_1(ZFMP_0)
see ZFOBJECT_ON_INIT_INLINE_1
Definition ZFObjectDeclare.h:259
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:122
#define ZFOBJECT_SINGLETON_DECLARE(AccessTypeName, accessMethodName)
util macro to declare a singleton instance access for ZFObject type
Definition ZFObjectGlobalInstance.h:243
#define ZFIMPLEMENT_DECLARE(ImplementedInterfaces,...)
see ZFINTERFACE_DECLARE
Definition ZFObjectInterface.h:168
#define zfimplement
shows class implement from interface, see ZFInterface
Definition ZFObjectInterface.h:24
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:312
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:120
virtual zfstring & addr()
the addr of the server, typically "0.0.0.0"
Definition ZFHttpServer.h:208
virtual zfuint & port()
the port of the server
Definition ZFHttpServer.h:211
virtual void start()
start the server
virtual zftimet & timeout()
timeout
Definition ZFHttpServer.h:214
virtual void stop()
stop the server
virtual zfbool started()
whether the server started
virtual void onRequest(const ZFListener &impl)
util for impl
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
virtual void objectOnInit(zfuint port)
init with port
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
virtual zfstring recvParamIterValue(const zfiter &it)=0
recv header access
virtual void respCode(zfuint code)=0
resp status code
virtual zfstring recvHeaderIterKey(const zfiter &it)=0
recv header access
virtual zfindex recvParamCount()=0
recv header count
virtual void respHeaderRemove(const zfstring &key)=0
resp header modify
virtual zfstring contentInfo()
print all content info, usually for debug use only
virtual zfiter recvParamIter()=0
recv header access
virtual void respBody(const zfstring &value, const zfstring &contentType)=0
resp body
virtual zfstring recvParam(const zfstring &key)=0
recv header access
virtual zfstring respHeaderIterValue(const zfiter &it)=0
resp header access
virtual zfstring headerInfo()
print all header, usually for debug use only
virtual zfstring respHeader(const zfstring &key)=0
resp header access
virtual zfstring recvServerAddr()=0
the addr of the server
virtual zfiter respHeaderIter()=0
resp header access
virtual zfstring recvBody()=0
recv body
virtual zfstring recvHeader(const zfstring &key)=0
recv header access
virtual zfstring recvClientAddr()=0
the addr of the client
virtual zfstring recvParamIterKey(const zfiter &it)=0
recv header access
virtual zfindex respHeaderCount()=0
resp header count
virtual zfuint recvServerPort()=0
the addr of the server
virtual zfiter respHeaderIterFind(const zfstring &key)=0
resp header modify
virtual ZFHttpMethod recvMethod()=0
recv http method
virtual zfiter recvHeaderIter()=0
recv header access
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
virtual zfstring recvPath()=0
recv url path
virtual zfindex recvHeaderCount()=0
recv header count
virtual zfuint recvClientPort()=0
the addr of the client
virtual zfstring recvHeaderIterValue(const zfiter &it)=0
recv header access
virtual zfstring respHeaderIterKey(const zfiter &it)=0
resp header access
virtual void respHeaderIterRemove(zfiter &it)=0
resp header modify
static ZFHttpServerThreadPool * instance()
general input callback
Definition ZFIOCallback_input.h:36
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
iterator for ZFFramework
Definition zfiter.h:40
#define zftext(s,...)
util macro for zfstring::shared
Definition zfstring.h:785