Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
HttpConnection.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 *
11 ****************************************************************************
12 * HEADER
13 *
14 * $Id: HttpConnection.h 5978 2026-09-11 16:13:48Z 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
41#ifndef __HttpConnection_h
42#define __HttpConnection_h
43
44#include <SoDispCon.h>
45
46struct HttpServer;
47struct HttpConnection;
48
49
50/*===========================================================================
51 *
52 * HttpConnection
53 *---------------------------------------------------------------------------
54 */
55
56
59typedef enum
60{
61 HttpConnection_Free=0, /* Resource not in use */
62 HttpConnection_Connected, /* connected, but no data */
63 HttpConnection_Ready, /* Data on socket */
64 HttpConnection_Running, /* Executing HTTP request/response */
65 HttpConnection_Moved, /* Moved to EventHandler */
66 HttpConnection_Terminated, /* Temporary state. Failed reading/writing */
67 /* Not a valid state, but can be used in method HttpConnection_setState to
68 do a hard (abortive) socket close. */
69 HttpConnection_HardClose
71
72
73
78#ifdef __cplusplus
79typedef struct HttpConnection : public SoDispCon
80{
81 void *operator new(size_t, void *place) { return place; }
82 void operator delete(void*, void *) { }
85
88 struct HttpServer* getServer();
89
91 void setKeepAlive();
92
96 void clearKeepAlive();
97#else
98typedef struct HttpConnection
99{
100 SoDispCon super;
101#if 0
102}
103#endif
104#endif
105 struct HttpServer* server;
106 struct HttpCommand* cmd;
107 void* pushBackData;
108 int pushBackDataSize;
109 U8 state; /* HttpConnection_State */
110 U8 keepAlive;
112
115#define HttpConnection_setKeepAlive(o) (o)->keepAlive=TRUE
118#define HttpConnection_clearKeepAlive(o) (o)->keepAlive=FALSE
121#define HttpConnection_keepAlive(o) (o)->keepAlive
124#define HttpConnection_getState(o) (o)->state
127#define HttpConnection_getServer(o) (o)->server
130#define HttpConnection_getDispatcher(o) SoDispCon_getDispatcher((SoDispCon*)o)
131#define HttpConnection_dispRecEvent(o) SoDispCon_dispRecEvent((SoDispCon*)o)
132#define HttpConnection_newConnectionIsReady(con) \
133 SoDispCon_newConnectionIsReady(con)
134
135#ifdef __cplusplus
136extern "C" {
137#endif
145 struct HttpServer* server,
146 struct SoDisp* dispatcher,
164int HttpConnection_sendChunkData6bOffs(
165 HttpConnection* o,const void* data,int len);
178BA_API int HttpConnection_pushBack(HttpConnection* o, const void* d, int s);
180#define HttpConnection_isSecure(o)\
181 SoDispCon_isSecure((SoDispCon*)o)
183#define HttpConnection_isValid(o)\
184 SoDispCon_isValid((SoDispCon*)o)
186#define HttpConnection_sendData(o, data, len)\
187 SoDispCon_sendData((SoDispCon*)o, data, len)
189#define HttpConnection_sendDataNT(o, data, len)\
190 SoDispCon_sendDataNT((SoDispCon*)o, data, len)
192#define HttpConnection_sendChunkData(o,data, len)\
193 SoDispCon_sendChunkData((SoDispCon*)o,data, len)
198#define HttpConnection_allocAsynchBuf(o, sizePtr)\
199 SoDispCon_allocAsynchBuf((SoDispCon*)o, sizePtr)
201#define HttpConnection_asyncSend(o,len) SoDispCon_asyncSend((SoDispCon*)o,len)
203#define HttpConnection_asyncReady(o) SoDispCon_asyncReady((SoDispCon*)o)
211BA_API int HttpConnection_readData(HttpConnection* con, void* data, int len);
220BA_API int HttpConnection_blockRead(HttpConnection* con, void* data, int len);
222#define HttpConnection_setNonblocking(o)\
223 SoDispCon_setNonblocking((SoDispCon*)o)
225#define HttpConnection_setBlocking(o)\
226 SoDispCon_setBlocking((SoDispCon*)o)
227#define HttpConnection_peek(o)\
228 SoDispCon_peek((SoDispCon*)o)
230#define HttpConnection_setTCPNoDelay(o, enable)\
231 SoDispCon_setTCPNoDelay((SoDispCon*)o, enable)
233#define HttpConnection_getPeerName(o, addr,port)\
234 SoDispCon_getPeerName((SoDispCon*)o, addr,port)
236#define HttpConnection_getSockName(o, addr,port)\
237 SoDispCon_getSockName((SoDispCon*)o, addr,port)
239#define HttpConnection_addr2String(o, addr, buf, len)\
240 SoDispCon_addr2String((SoDispCon*)o, addr, buf, len)
242#define HttpConnection_cmpAddr(o, addr2)\
243 SoDispCon_cmpAddr((SoDispCon*)o, addr2)
245#define HttpConnection_recEvActive(o)\
246 SoDispCon_recEvActive((SoDispCon*)o)
248#define HttpConnection_sendEvActive(o)\
249 SoDispCon_sendEvActive((SoDispCon*)o)
252#define HttpConnection_hasMoreData(o)\
253 (SoDispCon_hasMoreData((SoDispCon*)o) || (o)->pushBackData)
255#define HttpConnection_dispatcherHasCon(o)\
256 SoDispCon_dispatcherHasCon((SoDispCon*)o)
258#define HttpConnection_setDispSendEvent(o, dispSendEvFp)\
259 SoDispCon_setDispSendEvent((SoDispCon*)o, dispSendEvFp)
260#ifdef __cplusplus
261}
264}
267}
268#endif
269
270
271#endif
BA_API int HttpConnection_blockRead(HttpConnection *con, void *data, int len)
Read buffered bytes or wait for socket data.
BA_API int HttpConnection_pushBack(HttpConnection *o, const void *d, int s)
Prepend copied bytes to the input returned by subsequent reads.
BA_API void HttpConnection_setState(HttpConnection *o, HttpConnection_State state)
Change lifecycle state, performing the associated cleanup.
#define HttpConnection_setKeepAlive(o)
Enable persistent reuse after a completed HTTP request.
Definition: HttpConnection.h:115
BA_API int HttpConnection_readData(HttpConnection *con, void *data, int len)
Read pending pushback bytes first, otherwise perform an event-oriented read.
BA_API int HttpConnection_moveCon(HttpConnection *o, HttpConnection *newCon)
Move the socket, transport state and pending input to another object.
BA_API void HttpConnection_constructor(HttpConnection *o, struct HttpServer *server, struct SoDisp *dispatcher, SoDispCon_DispRecEv e)
Initialize connection storage without opening a socket.
HttpConnection HttpConnection
Contains information about the physical socket connection.
#define HttpConnection_clearKeepAlive(o)
Disable persistent reuse without immediately closing the socket.
Definition: HttpConnection.h:118
BA_API void HttpConnection_destructor(HttpConnection *o)
Release pushback storage, unregister events, and close the connection.
HttpConnection_State
Server connection lifecycle states.
Definition: HttpConnection.h:60
void(* SoDispCon_DispRecEv)(struct SoDispCon *con)
Dispatcher receive notification, invoked with its mutex held.
Definition: SoDispCon.h:108
struct HttpServer * getServer()
Definition: HttpServer.h:3745
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
Definition: HttpServer.h:2151
Contains information about the physical socket connection.
Definition: HttpConnection.h:80
void clearKeepAlive()
Disable persistent connection reuse after the request completes.
Definition: HttpConnection.h:265
HttpConnection()
Uninitialized storage; use HttpConnection_constructor before use.
Definition: HttpConnection.h:84
void setKeepAlive()
Enable persistent connection reuse after a completed HTTP request.
Definition: HttpConnection.h:262
The Web Server.
Definition: HttpServer.h:3393
Contains information about the physical socket connection.
Definition: SoDispCon.h:120
The SoDisp dispatches any socket connection that contains data by calling the SoDispCon::execute memb...
Definition: SoDisp.h:91