Barracuda Application Server C/C++ Reference
NO
HttpAsynchReq.h
1/*
2 * ____ _________ __ _
3 * / __ \___ ____ _/ /_ __(_)___ ___ ___ / / ____ ____ _(_)____
4 * / /_/ / _ \/ __ `/ / / / / / __ `__ \/ _ \/ / / __ \/ __ `/ / ___/
5 * / _, _/ __/ /_/ / / / / / / / / / / / __/ /___/ /_/ / /_/ / / /__
6 * /_/ |_|\___/\__,_/_/ /_/ /_/_/ /_/ /_/\___/_____/\____/\__, /_/\___/
7 * /____/
8 *
9 * Barracuda Embedded Web-Server
10 ****************************************************************************
11 * HEADER
12 *
13 * $Id: HttpAsynchReq.h 4915 2021-12-01 18:26:55Z wini $
14 *
15 * COPYRIGHT: Real Time Logic LLC, 2004 - 2012
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
37#ifndef __HttpAsynchReq_h
38#define __HttpAsynchReq_h
39
40#include <HttpAsynchResp.h>
41
42#ifndef __DOXYGEN__
43struct HttpAsynchReq;
44#endif
45
65typedef void (*HttpAsynchReq_OnData)(struct HttpAsynchReq* super,
66 void* data, S32 size);
67
90typedef struct HttpAsynchReq
91{
92#ifdef __cplusplus
93 void *operator new(size_t s) { return ::baMalloc(s); }
94 void operator delete(void* d) { if(d) ::baFree(d); }
95 void *operator new(size_t, void *place) { return place; }
96 void operator delete(void*, void *) { }
97
99
107
110
126 SBaFileSize getPacketSizeLeft();
127
132 void* getBuffer();
133
135 SBaFileSize getBufferSize();
136
137
138 bool isChunkEncoding();
139
159 static SBaFileSize calcPacketSize(HttpRequest* req);
160
171 int start(HttpRequest* req,void* buffer, S32 bufferSize);
172
175 void stop();
176
190#endif
191 HttpConnection super; /* Inherits from HttpConnection */
192 SBaFileSize bufferSize;
193 SBaFileSize packetSizeLeft;
194 SBaFileSize offset;
196 BaBool* isTerminatedPtr;
197 U8* buffer;
198 BaBool chunkEncoding;
200
201#ifdef __cplusplus
202extern "C" {
203#endif
204BA_API void HttpAsynchReq_constructor(HttpAsynchReq* o,
205 HttpServer* server,
207BA_API void HttpAsynchReq_destructor(HttpAsynchReq* o);
208#define HttpAsynchReq_getPacketSizeLeft(o) (o)->packetSizeLeft
209#define HttpAsynchReq_getBuffer(o) (o)->buffer
210#define HttpAsynchReq_getBufferSize(o) (o)->bufferSize
211#define HttpAsynchReq_isChunkEncoding(o) (o)->chunkEncoding
212#define HttpAsynchReq_getServer(o) \
213 HttpConnection_getServer((HttpConnection*)(o))
214BA_API SBaFileSize HttpAsynchReq_calcPacketSize(HttpRequest* req);
215BA_API int HttpAsynchReq_start(
216 HttpAsynchReq* o,HttpRequest* req, void* buffer, S32 bufferSize);
217/* Internal function used by HttpFiber */
218BA_API void HttpAsynchReq_stop(HttpAsynchReq* o);
219BA_API HttpConnection* HttpAsynchReq_getCon(HttpAsynchReq* o);
220#ifdef __cplusplus
221}
222inline HttpAsynchReq::HttpAsynchReq(HttpServer* server,
224 HttpAsynchReq_constructor(this, server, data);
225}
227 HttpAsynchReq_destructor(this);
228}
230 return HttpAsynchReq_getPacketSizeLeft(this);
231}
233 return HttpAsynchReq_getBuffer(this);
234}
235inline SBaFileSize HttpAsynchReq::getBufferSize() {
236 return HttpAsynchReq_getBufferSize(this);
237}
238inline bool HttpAsynchReq::isChunkEncoding() {
239 return HttpAsynchReq_isChunkEncoding(this) ? true : false;
240}
242 return HttpAsynchReq_calcPacketSize(req);
243}
244inline int HttpAsynchReq::start(HttpRequest* req,void* buffer, S32 bufferSize){
245 return HttpAsynchReq_start(this,req,buffer,bufferSize);
246}
247inline void HttpAsynchReq::stop() {
248 HttpAsynchReq_stop(this);
249}
250
252 return HttpAsynchReq_getCon(this); }
253#endif
254
255
256
265typedef struct HttpAsynchReqResp
266#ifdef __cplusplus
267 :public HttpAsynchReq
268{
270
280
295 int start(HttpRequest* req,void* recBuf,S32 recBufSize,
296 void* sendBuf,S32 sendBufSize);
302 int startResp(HttpRequest* req,void* sendBuf,S32 sendBufSize);
303
304#if 0
309 void disableRecEv();
310
315 void enableRecEv();
316#endif
317
321
324
328#else
329#if 0
330}
331#endif
332{
333 HttpAsynchReq super;
334#endif
335 HttpAsynchResp resp;
337
338#ifdef __cplusplus
339extern "C" {
340#endif
341BA_API void HttpAsynchReqResp_constructor(HttpAsynchReqResp* o,
342 HttpServer* server,
344#if 0
345void HttpAsynchReqResp_disableRecEv(HttpAsynchReqResp* o);
346void HttpAsynchReqResp_enableRecEv(HttpAsynchReqResp* o);
347#endif
348BA_API int HttpAsynchReqResp_start(HttpAsynchReqResp* o,
349 HttpRequest* req,
350 void* recBuf,
351 S32 recBufSize,
352 void* sendBuf,
353 S32 sendBufSize);
354BA_API int HttpAsynchReqResp_startResp(HttpAsynchReqResp* o,
355 HttpRequest* req,
356 void* sendBuf,
357 S32 sendBufSize);
358#define HttpAsynchReqResp_destructor(o) do {\
359 HttpAsynchResp_destructor(&(o)->resp);\
360 HttpAsynchReq_destructor((HttpAsynchReq*)(o));\
361}while(0)
362#define HttpAsynchReqResp_getPacketSizeLeft(o)\
363 HttpAsynchReq_getPacketSizeLeft((HttpAsynchReq*)o)
364#define HttpAsynchReqResp_getBuffer(o)\
365 HttpAsynchReq_getBuffer((HttpAsynchReq*)o)
366#define HttpAsynchReqResp_getBufferSize(o)\
367 HttpAsynchReq_getBufferSize((HttpAsynchReq*)o)
368#define HttpAsynchReqResp_isChunkEncoding(o)\
369 HttpAsynchReq_isChunkEncoding((HttpAsynchReq*)o)
370#define HttpAsynchReqResp_calcPacketSize(req)\
371 HttpAsynchReq_calcPacketSize(req)
372
373#define HttpAsynchReqResp_getCon(o) ((o))->resp.con
374#define HttpAsynchReqResp_getMutex(o) \
375 SoDisp_getMutex(HttpConnection_getDispatcher( \
376 HttpAsynchReqResp_getCon(o)))
377#define HttpAsynchReqResp_getServer(o) \
378 HttpConnection_getServer(HttpAsynchReqResp_getCon(o))
379#define HttpAsynchReqResp_getResponse(o) (&(o)->resp)
380#ifdef __cplusplus
381}
382inline HttpAsynchReqResp::HttpAsynchReqResp(HttpServer* server,
384 HttpAsynchReqResp_constructor(this, server, data);
385}
387 void* recBuf,
388 S32 recBufSize,
389 void* sendBuf,
390 S32 sendBufSize) {
391 return HttpAsynchReqResp_start(
392 this,req,recBuf,recBufSize,sendBuf,sendBufSize); }
394 void* sendBuf,
395 S32 sendBufSize) {
396 return HttpAsynchReqResp_startResp(this,req,sendBuf,sendBufSize); }
397#if 0
398inline void HttpAsynchReqResp::disableRecEv() {
399 HttpAsynchReqResp_disableRecEv(this); }
400inline void HttpAsynchReqResp::enableRecEv() {
401 HttpAsynchReqResp_enableRecEv(this); }
402#endif
404 return HttpAsynchReqResp_getMutex(this);
405}
407 return HttpAsynchReqResp_getServer(this);
408}
410 return HttpAsynchReqResp_getResponse(this);
411}
412#endif
413
414 /* end of HttpStack */
416
417
418#endif
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
void baFree(void *p)
Deallocates space to which it points.
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:393
SBaFileSize getBufferSize()
Returns the lenght of the internal buffer.
Definition: HttpAsynchReq.h:235
struct HttpAsynchReq HttpAsynchReq
Asynchronously receive data in a resource such as HttpDir or HttpPage.
int start(HttpRequest *req, void *buffer, S32 bufferSize)
Start receiving data asynchronously.
Definition: HttpAsynchReq.h:244
void * getBuffer()
Returns a pointer to the internal buffer where the received data is stored.
Definition: HttpAsynchReq.h:232
HttpConnection * getCon(HttpAsynchReq *o)
Returns the internal active connection object.
Definition: HttpAsynchReq.h:251
static SBaFileSize calcPacketSize(HttpRequest *req)
Returns the packet size if the length is known.
Definition: HttpAsynchReq.h:241
~HttpAsynchReq()
Terminate a HttpAsynchReq object.
Definition: HttpAsynchReq.h:226
int start(HttpRequest *req, void *recBuf, S32 recBufSize, void *sendBuf, S32 sendBufSize)
Start the HttpAsynchReqResp object.
Definition: HttpAsynchReq.h:386
HttpServer * getServer()
Get the HttpServer object.
Definition: HttpAsynchReq.h:406
HttpAsynchResp * getResponse()
Get the response object.
Definition: HttpAsynchReq.h:409
ThreadMutex * getMutex()
Get the dispatcher lock.
Definition: HttpAsynchReq.h:403
SBaFileSize getPacketSizeLeft()
Returns the remaining packet size if the packet size is known – i.e., if the initial HTTP header had ...
Definition: HttpAsynchReq.h:229
HttpAsynchReqResp HttpAsynchReqResp
Simultaneously receive and send a stream of data.
void(* HttpAsynchReq_OnData)(struct HttpAsynchReq *super, void *data, S32 size)
Prototype for the HttpAsynchReq OnRequest callback.
Definition: HttpAsynchReq.h:65
void stop()
Aborts the operation and terminates the active socket connection.
Definition: HttpAsynchReq.h:247
Simultaneously receive and send a stream of data.
Definition: HttpAsynchReq.h:268
Asynchronously receive data in a resource such as HttpDir or HttpPage.
Definition: HttpAsynchReq.h:91
Send data asynchronously to a client.
Definition: HttpAsynchResp.h:110
Contains information about the physical socket connection.
Definition: HttpConnection.h:76
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:808
The Web Server.
Definition: HttpServer.h:2864
A mutual exclusion class.
Definition: ThreadLib.h:186