39#ifndef __HttpAsynchResp_h
40#define __HttpAsynchResp_h
45#define RESPONSESTATE_IDLE 0
46#define RESPONSESTATE_WRITEMODE 1
47#define RESPONSESTATE_WRITEMODE_CHUNK 2
48#define RESPONSESTATE_BODYSENT 3
49#define RESPONSESTATE_CLOSED 4
116 void operator delete(
void* d) {
if(d)
::baFree(d); }
117 void *
operator new(size_t,
void *place) {
return place; }
118 void operator delete(
void*,
void *) { }
213 int setStatus(
int statusCode,
const char* protocol=0);
224 int setHeader(
const char *name,
const char *value);
238 int sendData(
const void* data,
int pktSize,
int chunkSize);
313#define HttpAsynchResp_asynchThreadMode(o) \
314 ((o)->mutex=HttpAsynchResp_getMutex(o))
321#define HttpAsynchResp_destructor(o) HttpAsynchResp_close(o)
324#define HttpAsynchResp_getMutex(o) \
325 SoDisp_getMutex(HttpConnection_getDispatcher((HttpConnection*)(o)))
329#define HttpAsynchResp_setConClose(o)\
330 HttpConnection_clearKeepAlive((HttpConnection*)(o))
336#define HttpAsynchResp_setLingeringClose(o) (o)->doLingeringClose=TRUE
359#define HttpAsynchResp_isAsynchThreadMode(o) ((o)->mutex ? TRUE : FALSE)
396 const void* data,
int pktSize,
int chunkSize) {
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 void HttpAsynchResp_ReqRespInit(HttpAsynchResp *o, char *buf, int size, HttpConnection *con)
Initialize the response half of a combined request/response object.
BufPrint * getWriter()
BufPrint is used when sending data of unknown length.
Definition: HttpAsynchResp.h:401
int setHeader(const char *name, const char *value)
Append a response header before starting the body.
Definition: HttpAsynchResp.h:392
ThreadMutex * getMutex()
Get the dispatcher lock.
Definition: HttpAsynchResp.h:380
BA_API void HttpAsynchResp_constructor(HttpAsynchResp *o, char *buf, int size, HttpRequest *req)
Initialize from a request and take over its connection.
BA_API int HttpAsynchResp_sendNextChunk(HttpAsynchResp *o, const void *data, int chunkSize)
Continue the fixed-length body begun with sendData.
#define HttpAsynchResp_asynchThreadMode(o)
Select worker-thread send behavior; see HttpAsynchResp::asynchThreadMode.
Definition: HttpAsynchResp.h:313
BA_API BufPrint * HttpAsynchResp_getWriter(HttpAsynchResp *o)
BufPrint is used when sending data of unknown length.
#define HttpAsynchResp_getMutex(o)
Definition: HttpAsynchResp.h:324
BA_API void HttpAsynchResp_constructor2(HttpAsynchResp *o, char *buf, int size, HttpConnection *con)
Initialize from a connection and take over its socket.
#define HttpAsynchResp_setConClose(o)
Disable persistent connection reuse before sending headers.
Definition: HttpAsynchResp.h:329
void asynchThreadMode()
Set in asynchronous thread mode so you can call the methods in this class using its worker-thread sen...
Definition: HttpAsynchResp.h:377
int sendData(const void *data, int pktSize, int chunkSize)
Begin a fixed-length response body.
Definition: HttpAsynchResp.h:395
#define HttpAsynchResp_destructor(o)
Close the response; no status is returned.
Definition: HttpAsynchResp.h:321
~HttpAsynchResp()
Calls method close.
Definition: HttpAsynchResp.h:371
bool isValid()
Check the installed buffer and connection.
Definition: HttpAsynchResp.h:368
int setConClose()
Close connection when the HttpAsynchResp object is done.
Definition: HttpAsynchResp.h:383
int setLingeringClose()
Request connection closure.
Definition: HttpAsynchResp.h:386
int setStatus(int statusCode, const char *protocol=0)
Append the HTTP status line and standard Date/Server headers.
Definition: HttpAsynchResp.h:389
BA_API int HttpAsynchResp_setStatus(HttpAsynchResp *o, int statusCode, const char *protocol)
Append the HTTP status line and standard Date/Server headers.
BA_API BaBool HttpAsynchResp_isValid(HttpAsynchResp *o)
Check the installed buffer and connection.
void close()
Flushes the response, if any, and checks the connection object: A valid and persistent HTTP 1....
Definition: HttpAsynchResp.h:374
BA_API int HttpAsynchResp_sendData(HttpAsynchResp *o, const void *data, int pktSize, int chunkSize)
Begin a fixed-length response body.
int sendNextChunk(const void *data, int chunkSize)
Continue the fixed-length body begun with sendData.
Definition: HttpAsynchResp.h:399
BA_API int HttpAsynchResp_setHeader(HttpAsynchResp *o, const char *name, const char *value)
Append a response header before starting the body.
BA_API void HttpAsynchResp_close(HttpAsynchResp *o)
Flushes the response, if any, and checks the connection object: A valid and persistent HTTP 1....
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
The BufPrint class, which implements a compact printf-style formatter, is a base class used by severa...
Definition: BufPrint.h:132
Send data asynchronously to a client.
Definition: HttpAsynchResp.h:114
HttpAsynchResp()
Uninitialized storage; initialize before use or destruction.
Definition: HttpAsynchResp.h:121
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
A mutual exclusion class.
Definition: ThreadLib.h:196