Barracuda Application Server C/C++ Reference
NO
HttpConnection.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: HttpConnection.h 4915 2021-12-01 18:26:55Z wini $
15 *
16 * COPYRIGHT: Real Time Logic LLC, 2003 - 2017
17 *
18 * This software is copyrighted by and is the sole property of Real
19 * Time Logic LLC. All rights, title, ownership, or other interests in
20 * the software remain the property of Real Time Logic LLC. This
21 * software may only be used in accordance with the terms and
22 * conditions stipulated in the corresponding license agreement under
23 * which the software has been supplied. Any unauthorized use,
24 * duplication, transmission, distribution, or disclosure of this
25 * software is expressly forbidden.
26 *
27 * This Copyright notice may not be removed or modified without prior
28 * written consent of Real Time Logic LLC.
29 *
30 * Real Time Logic LLC. reserves the right to modify this software
31 * without notice.
32 *
33 * http://www.realtimelogic.com
34 ****************************************************************************
35 *
36 *
37 */
38
39#ifndef __HttpConnection_h
40#define __HttpConnection_h
41
42#include <SoDispCon.h>
43
44struct HttpServer;
45struct HttpConnection;
46
47
48/*===========================================================================
49 *
50 * HttpConnection
51 *---------------------------------------------------------------------------
52 */
53
54
55typedef enum
56{
57 HttpConnection_Free=0, /* Resource not in use */
58 HttpConnection_Connected, /* connected, but no data */
59 HttpConnection_Ready, /* Data on socket */
60 HttpConnection_Running, /* Executing HTTP request/response */
61 HttpConnection_Moved, /* Moved to EventHandler */
62 HttpConnection_Terminated, /* Temporary state. Failed reading/writing */
63 /* Not a valid state, but can be used in method HttpConnection_setState to
64 do a hard (abortive) socket close. */
65 HttpConnection_HardClose
66} HttpConnection_State;
67
68
69
74#ifdef __cplusplus
75typedef struct HttpConnection : public SoDispCon
76{
77 void *operator new(size_t, void *place) { return place; }
78 void operator delete(void*, void *) { }
80
83 struct HttpServer* getServer();
84
86 void setKeepAlive();
87
91 void clearKeepAlive();
92#else
93typedef struct HttpConnection
94{
95 SoDispCon super;
96#if 0
97}
98#endif
99#endif
100 struct HttpServer* server;
101 struct HttpCommand* cmd;
102 void* pushBackData;
103 int pushBackDataSize;
104 U8 state; /* HttpConnection_State */
105 U8 keepAlive;
107
108#define HttpConnection_setKeepAlive(o) (o)->keepAlive=TRUE
109#define HttpConnection_clearKeepAlive(o) (o)->keepAlive=FALSE
110#define HttpConnection_keepAlive(o) (o)->keepAlive
111#define HttpConnection_getState(o) (o)->state
112#define HttpConnection_getServer(o) (o)->server
113#define HttpConnection_getDispatcher(o) SoDispCon_getDispatcher((SoDispCon*)o)
114#define HttpConnection_dispRecEvent(o) SoDispCon_dispRecEvent((SoDispCon*)o)
115#define HttpConnection_newConnectionIsReady(con) \
116 SoDispCon_newConnectionIsReady(con)
117
118#ifdef __cplusplus
119extern "C" {
120#endif
121BA_API void HttpConnection_constructor(HttpConnection* o,
122 struct HttpServer* server,
123 struct SoDisp* dispatcher,
124 SoDispCon_DispRecEv e);
125BA_API void HttpConnection_setState(
126 HttpConnection* o, HttpConnection_State state);
127BA_API int HttpConnection_moveCon(HttpConnection* o, HttpConnection* newCon);
128int HttpConnection_sendChunkData6bOffs(
129 HttpConnection* o,const void* data,int len);
130BA_API void HttpConnection_destructor(HttpConnection* o);
131BA_API int HttpConnection_pushBack(HttpConnection* o, const void* d, int s);
132#define HttpConnection_isSecure(o)\
133 SoDispCon_isSecure((SoDispCon*)o)
134#define HttpConnection_isValid(o)\
135 SoDispCon_isValid((SoDispCon*)o)
136#define HttpConnection_sendData(o, data, len)\
137 SoDispCon_sendData((SoDispCon*)o, data, len)
138#define HttpConnection_sendDataNT(o, data, len)\
139 SoDispCon_sendDataNT((SoDispCon*)o, data, len)
140#define HttpConnection_sendChunkData(o,data, len)\
141 SoDispCon_sendChunkData((SoDispCon*)o,data, len)
142#define HttpConnection_allocAsynchBuf(o, sizePtr)\
143 SoDispCon_allocAsynchBuf((SoDispCon*)o, sizePtr)
144#define HttpConnection_asyncSend(o,len) SoDispCon_asyncSend((SoDispCon*)o,len)
145#define HttpConnection_asyncReady(o) SoDispCon_asyncReady((SoDispCon*)o)
146BA_API int HttpConnection_readData(HttpConnection* con, void* data, int len);
147BA_API int HttpConnection_blockRead(HttpConnection* con, void* data, int len);
148#define HttpConnection_setNonblocking(o)\
149 SoDispCon_setNonblocking((SoDispCon*)o)
150#define HttpConnection_setBlocking(o)\
151 SoDispCon_setBlocking((SoDispCon*)o)
152#define HttpConnection_peek(o)\
153 SoDispCon_peek((SoDispCon*)o)
154#define HttpConnection_setTCPNoDelay(o, enable)\
155 SoDispCon_setTCPNoDelay((SoDispCon*)o, enable)
156#define HttpConnection_getPeerName(o, addr,port)\
157 SoDispCon_getPeerName((SoDispCon*)o, addr,port)
158#define HttpConnection_getSockName(o, addr,port)\
159 SoDispCon_getSockName((SoDispCon*)o, addr,port)
160#define HttpConnection_addr2String(o, addr, buf, len)\
161 SoDispCon_addr2String((SoDispCon*)o, addr, buf, len)
162#define HttpConnection_cmpAddr(o, addr2)\
163 SoDispCon_cmpAddr((SoDispCon*)o, addr2)
164#define HttpConnection_recEvActive(o)\
165 SoDispCon_recEvActive((SoDispCon*)o)
166#define HttpConnection_sendEvActive(o)\
167 SoDispCon_sendEvActive((SoDispCon*)o)
168#define HttpConnection_hasMoreData(o)\
169 (SoDispCon_hasMoreData((SoDispCon*)o) || (o)->pushBackData)
170#define HttpConnection_dispatcherHasCon(o)\
171 SoDispCon_dispatcherHasCon((SoDispCon*)o)
172#define HttpConnection_setDispSendEvent(o, dispSendEvFp)\
173 SoDispCon_setDispSendEvent((SoDispCon*)o, dispSendEvFp)
174#ifdef __cplusplus
175}
177 HttpConnection_setKeepAlive(this);
178}
180 HttpConnection_clearKeepAlive(this);
181}
182#endif
183
184
185#endif
struct HttpServer * getServer()
Fetch the HttpServer object.
Definition: HttpServer.h:3164
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
Definition: HttpServer.h:1818
Contains information about the physical socket connection.
Definition: HttpConnection.h:76
void clearKeepAlive()
Keep connection after request completed, i.e.
Definition: HttpConnection.h:179
void setKeepAlive()
Close connection after request completed.
Definition: HttpConnection.h:176
The Web Server.
Definition: HttpServer.h:2864
Contains information about the physical socket connection.
Definition: SoDispCon.h:112
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:86