37#ifndef __HttpAsynchReq_h
38#define __HttpAsynchReq_h
40#include <HttpAsynchResp.h>
66 void* data, S32 size);
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 *) { }
138 bool isChunkEncoding();
192 SBaFileSize bufferSize;
193 SBaFileSize packetSizeLeft;
196 BaBool* isTerminatedPtr;
198 BaBool chunkEncoding;
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(
224 HttpAsynchReq_constructor(
this, server, data);
227 HttpAsynchReq_destructor(
this);
230 return HttpAsynchReq_getPacketSizeLeft(
this);
233 return HttpAsynchReq_getBuffer(
this);
236 return HttpAsynchReq_getBufferSize(
this);
238inline bool HttpAsynchReq::isChunkEncoding() {
239 return HttpAsynchReq_isChunkEncoding(
this) ? true :
false;
242 return HttpAsynchReq_calcPacketSize(req);
245 return HttpAsynchReq_start(
this,req,buffer,bufferSize);
248 HttpAsynchReq_stop(
this);
252 return HttpAsynchReq_getCon(
this); }
296 void* sendBuf,S32 sendBufSize);
358#define HttpAsynchReqResp_destructor(o) do {\
359 HttpAsynchResp_destructor(&(o)->resp);\
360 HttpAsynchReq_destructor((HttpAsynchReq*)(o));\
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)
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)
382inline HttpAsynchReqResp::HttpAsynchReqResp(
HttpServer* server,
384 HttpAsynchReqResp_constructor(
this, server, data);
391 return HttpAsynchReqResp_start(
392 this,req,recBuf,recBufSize,sendBuf,sendBufSize); }
396 return HttpAsynchReqResp_startResp(
this,req,sendBuf,sendBufSize); }
398inline void HttpAsynchReqResp::disableRecEv() {
399 HttpAsynchReqResp_disableRecEv(
this); }
400inline void HttpAsynchReqResp::enableRecEv() {
401 HttpAsynchReqResp_enableRecEv(
this); }
404 return HttpAsynchReqResp_getMutex(
this);
407 return HttpAsynchReqResp_getServer(
this);
410 return HttpAsynchReqResp_getResponse(
this);
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