Barracuda Application Server C/C++ Reference
Native APIs, integration guides, and platform interfaces
HttpAsynchReq.h
Go to the documentation of this file.
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 ****************************************************************************
11 * HEADER
12 *
13 * $Id: HttpAsynchReq.h 6056 2026-09-20 05:09:33Z wini $
14 *
15 * COPYRIGHT: Real Time Logic LLC, 2004 - 2026
16 *
17 * This software is copyrighted by and is the sole property of Real
18 * Time Logic LLC. All rights, title, ownership, or other interests in
19 * the software remain the property of Real Time Logic LLC. This
20 * software may only be used in accordance with the terms and
21 * conditions stipulated in the corresponding license agreement under
22 * which the software has been supplied. Any unauthorized use,
23 * duplication, transmission, distribution, or disclosure of this
24 * software is expressly forbidden.
25 *
26 * This Copyright notice may not be removed or modified without prior
27 * written consent of Real Time Logic LLC.
28 *
29 * Real Time Logic LLC. reserves the right to modify this software
30 * without notice.
31 *
32 * http://www.realtimelogic.com
33 ****************************************************************************
34 *
35 */
36
39#ifndef __HttpAsynchReq_h
40#define __HttpAsynchReq_h
41
42#include <HttpAsynchResp.h>
43
44#ifndef __DOXYGEN__
45struct HttpAsynchReq;
46#endif
47
69typedef void (*HttpAsynchReq_OnData)(struct HttpAsynchReq* super,
70 void* data, S32 size);
71
94typedef struct HttpAsynchReq
95{
96#ifdef __cplusplus
97 void *operator new(size_t s) { return ::baMalloc(s); }
98 void operator delete(void* d) { if(d) ::baFree(d); }
99 void *operator new(size_t, void *place) { return place; }
100 void operator delete(void*, void *) { }
101
104
111
116
124
131 void* getBuffer();
132
135
136
138 bool isChunkEncoding();
139
150
168 int start(HttpRequest* req,void* buffer, S32 bufferSize);
169
174 void stop();
175
195#endif
196 HttpConnection super; /* Inherits from HttpConnection */
197 SBaFileSize bufferSize;
198 SBaFileSize packetSizeLeft;
199 SBaFileSize offset;
201 BaBool* isTerminatedPtr;
202 U8* buffer;
203 BaBool chunkEncoding;
205
206#ifdef __cplusplus
207extern "C" {
208#endif
212 HttpServer* server,
220#define HttpAsynchReq_getPacketSizeLeft(o) (o)->packetSizeLeft
223#define HttpAsynchReq_getBuffer(o) (o)->buffer
226#define HttpAsynchReq_getBufferSize(o) (o)->bufferSize
229#define HttpAsynchReq_isChunkEncoding(o) (o)->chunkEncoding
232#define HttpAsynchReq_getServer(o) \
233 HttpConnection_getServer((HttpConnection*)(o))
239 HttpAsynchReq* o,HttpRequest* req, void* buffer, S32 bufferSize);
240/* Internal function used by HttpFiber */
249#ifdef __cplusplus
250}
253 HttpAsynchReq_constructor(this, server, data);
254}
257}
260}
262 return HttpAsynchReq_getBuffer(this);
263}
265 return HttpAsynchReq_getBufferSize(this);
266}
268 return HttpAsynchReq_isChunkEncoding(this) ? true : false;
269}
272}
273inline int HttpAsynchReq::start(HttpRequest* req,void* buffer, S32 bufferSize){
274 return HttpAsynchReq_start(this,req,buffer,bufferSize);
275}
276inline void HttpAsynchReq::stop() {
277 HttpAsynchReq_stop(this);
278}
279
281 return HttpAsynchReq_getCon(this); }
282#endif
283
284
285
294typedef struct HttpAsynchReqResp
295#ifdef __cplusplus
296 :public HttpAsynchReq
297{
300
310
328 int start(HttpRequest* req,void* recBuf,S32 recBufSize,
329 void* sendBuf,S32 sendBufSize);
342 int startResp(HttpRequest* req,void* sendBuf,S32 sendBufSize);
343
344#if 0
349 void disableRecEv();
350
355 void enableRecEv();
356#endif
357
362
366
371#else
372#if 0
373}
374#endif
375{
376 HttpAsynchReq super;
377#endif
378 HttpAsynchResp resp;
380
381#ifdef __cplusplus
382extern "C" {
383#endif
389 HttpServer* server,
391#if 0
392void HttpAsynchReqResp_disableRecEv(HttpAsynchReqResp* o);
393void HttpAsynchReqResp_enableRecEv(HttpAsynchReqResp* o);
394#endif
398 HttpRequest* req,
399 void* recBuf,
400 S32 recBufSize,
401 void* sendBuf,
402 S32 sendBufSize);
406 HttpRequest* req,
407 void* sendBuf,
408 S32 sendBufSize);
411#define HttpAsynchReqResp_destructor(o) do {\
412 HttpAsynchResp_destructor(&(o)->resp);\
413 HttpAsynchReq_destructor((HttpAsynchReq*)(o));\
414}while(0)
416#define HttpAsynchReqResp_getPacketSizeLeft(o)\
417 HttpAsynchReq_getPacketSizeLeft((HttpAsynchReq*)o)
419#define HttpAsynchReqResp_getBuffer(o)\
420 HttpAsynchReq_getBuffer((HttpAsynchReq*)o)
422#define HttpAsynchReqResp_getBufferSize(o)\
423 HttpAsynchReq_getBufferSize((HttpAsynchReq*)o)
425#define HttpAsynchReqResp_isChunkEncoding(o)\
426 HttpAsynchReq_isChunkEncoding((HttpAsynchReq*)o)
428#define HttpAsynchReqResp_calcPacketSize(req)\
429 HttpAsynchReq_calcPacketSize(req)
430
433#define HttpAsynchReqResp_getCon(o) ((o))->resp.con
436#define HttpAsynchReqResp_getMutex(o) \
437 SoDisp_getMutex(HttpConnection_getDispatcher( \
438 HttpAsynchReqResp_getCon(o)))
441#define HttpAsynchReqResp_getServer(o) \
442 HttpConnection_getServer(HttpAsynchReqResp_getCon(o))
445#define HttpAsynchReqResp_getResponse(o) (&(o)->resp)
446#ifdef __cplusplus
447}
450 HttpAsynchReqResp_constructor(this, server, data);
451}
453 void* recBuf,
454 S32 recBufSize,
455 void* sendBuf,
456 S32 sendBufSize) {
458 this,req,recBuf,recBufSize,sendBuf,sendBufSize); }
460 void* sendBuf,
461 S32 sendBufSize) {
462 return HttpAsynchReqResp_startResp(this,req,sendBuf,sendBufSize); }
463#if 0
464inline void HttpAsynchReqResp::disableRecEv() {
465 HttpAsynchReqResp_disableRecEv(this); }
466inline void HttpAsynchReqResp::enableRecEv() {
467 HttpAsynchReqResp_enableRecEv(this); }
468#endif
470 return HttpAsynchReqResp_getMutex(this);
471}
473 return HttpAsynchReqResp_getServer(this);
474}
477}
478#endif
479
480 /* end of HttpStack */
482
483
484#endif
void * baMalloc(size_t size)
Allocate uninitialized storage using the target's configured allocator.
void baFree(void *p)
Release storage using the target's configured allocator.
BA_API int HttpAsynchReqResp_startResp(HttpAsynchReqResp *o, HttpRequest *req, void *sendBuf, S32 sendBufSize)
Start response if you know that all data was received by the web-server.
int startResp(HttpRequest *req, void *sendBuf, S32 sendBufSize)
Start response if you know that all data was received by the web-server.
Definition: HttpAsynchReq.h:459
SBaFileSize getBufferSize()
Definition: HttpAsynchReq.h:264
#define HttpAsynchReqResp_getMutex(o)
Definition: HttpAsynchReq.h:436
BA_API void HttpAsynchReq_constructor(HttpAsynchReq *o, HttpServer *server, HttpAsynchReq_OnData data)
Create an instance of HttpAsynchReq.
#define HttpAsynchReqResp_getServer(o)
Definition: HttpAsynchReq.h:441
BA_API int HttpAsynchReq_start(HttpAsynchReq *o, HttpRequest *req, void *buffer, S32 bufferSize)
Take over the request connection and start asynchronous reception.
#define HttpAsynchReq_getBufferSize(o)
Definition: HttpAsynchReq.h:226
BA_API int HttpAsynchReqResp_start(HttpAsynchReqResp *o, HttpRequest *req, void *recBuf, S32 recBufSize, void *sendBuf, S32 sendBufSize)
Start the HttpAsynchReqResp object.
BA_API SBaFileSize HttpAsynchReq_calcPacketSize(HttpRequest *req)
Inspect the request's body framing without consuming it.
struct HttpAsynchReq HttpAsynchReq
Asynchronously receive data in a resource such as HttpDir or HttpPage.
int start(HttpRequest *req, void *buffer, S32 bufferSize)
Take over the request connection and start asynchronous reception.
Definition: HttpAsynchReq.h:273
BA_API HttpConnection * HttpAsynchReq_getCon(HttpAsynchReq *o)
Stop receiving and expose the embedded connection for handoff.
void * getBuffer()
Returns a pointer to the internal buffer where the received data is stored.
Definition: HttpAsynchReq.h:261
#define HttpAsynchReq_getPacketSizeLeft(o)
Definition: HttpAsynchReq.h:220
HttpConnection * getCon(HttpAsynchReq *o)
Stop dispatcher reception and obtain the connection for handoff.
Definition: HttpAsynchReq.h:280
static SBaFileSize calcPacketSize(HttpRequest *req)
Inspect the request's body framing without consuming it.
Definition: HttpAsynchReq.h:270
#define HttpAsynchReq_isChunkEncoding(o)
Definition: HttpAsynchReq.h:229
BA_API void HttpAsynchReqResp_constructor(HttpAsynchReqResp *o, HttpServer *server, HttpAsynchReq_OnData data)
Initialize combined receive/response state.
bool isChunkEncoding()
Definition: HttpAsynchReq.h:267
BA_API void HttpAsynchReq_stop(HttpAsynchReq *o)
#define HttpAsynchReqResp_getResponse(o)
Definition: HttpAsynchReq.h:445
~HttpAsynchReq()
Stop dispatcher reception and destroy the owned connection.
Definition: HttpAsynchReq.h:255
int start(HttpRequest *req, void *recBuf, S32 recBufSize, void *sendBuf, S32 sendBufSize)
Start the HttpAsynchReqResp object.
Definition: HttpAsynchReq.h:452
HttpServer * getServer()
Definition: HttpAsynchReq.h:472
HttpAsynchResp * getResponse()
Definition: HttpAsynchReq.h:475
ThreadMutex * getMutex()
Definition: HttpAsynchReq.h:469
SBaFileSize getPacketSizeLeft()
Inspect receive progress after successful start.
Definition: HttpAsynchReq.h:258
#define HttpAsynchReq_getBuffer(o)
Definition: HttpAsynchReq.h:223
HttpAsynchReqResp HttpAsynchReqResp
Simultaneously receive and send a stream of data.
void(* HttpAsynchReq_OnData)(struct HttpAsynchReq *super, void *data, S32 size)
Receive data, completion, or an error.
Definition: HttpAsynchReq.h:69
BA_API void HttpAsynchReq_destructor(HttpAsynchReq *o)
void stop()
Remove active dispatcher reception, mark an active connection terminated, and clear receive-buffer st...
Definition: HttpAsynchReq.h:276
S32 SBaFileSize
Signed file-size value in bytes; 32 bits without BA_FILESIZE64.
Definition: GenPrimT.h:138
int32_t S32
Signed 32-bit integer.
Definition: GenPrimT.h:85
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
Simultaneously receive and send a stream of data.
Definition: HttpAsynchReq.h:297
HttpAsynchReqResp()
Uninitialized storage; initialize before use or destruction.
Definition: HttpAsynchReq.h:299
Asynchronously receive data in a resource such as HttpDir or HttpPage.
Definition: HttpAsynchReq.h:95
HttpAsynchReq()
Uninitialized storage; initialize before use or destruction.
Definition: HttpAsynchReq.h:103
Send data asynchronously to a client.
Definition: HttpAsynchResp.h:114
Contains information about the physical socket connection.
Definition: HttpConnection.h:80
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:950
The Web Server.
Definition: HttpServer.h:3393
A mutual exclusion class.
Definition: ThreadLib.h:196