Barracuda Application Server C/C++ Reference
NO
|
37 #ifndef __HttpAsynchResp_h
38 #define __HttpAsynchResp_h
40 #include <HttpServer.h>
43 #define RESPONSESTATE_IDLE 0
44 #define RESPONSESTATE_WRITEMODE 1
45 #define RESPONSESTATE_WRITEMODE_CHUNK 2
46 #define RESPONSESTATE_BODYSENT 3
47 #define RESPONSESTATE_CLOSED 4
112 void operator delete(
void* d) {
if(d)
::baFree(d); }
113 void *
operator new(size_t,
void *place) {
return place; }
114 void operator delete(
void*,
void *) { }
199 int setStatus(
int statusCode,
const char* protocol=0);
207 int setHeader(
const char *name,
const char *value);
217 int sendData(
const void* data,
int pktSize,
int chunkSize);
251 BA_API
void HttpAsynchResp_constructor(
253 BA_API
void HttpAsynchResp_constructor2(
255 BA_API
void HttpAsynchResp_ReqRespInit(
258 #define HttpAsynchResp_asynchThreadMode(o) \
259 ((o)->mutex=HttpAsynchResp_getMutex(o))
261 #define HttpAsynchResp_destructor(o) HttpAsynchResp_close(o)
262 #define HttpAsynchResp_getMutex(o) \
263 SoDisp_getMutex(HttpConnection_getDispatcher((HttpConnection*)(o)))
264 #define HttpAsynchResp_setConClose(o)\
265 HttpConnection_clearKeepAlive((HttpConnection*)(o))
266 #define HttpAsynchResp_setLingeringClose(o) (o)->doLingeringClose=TRUE
267 BA_API
int HttpAsynchResp_setStatus(
269 BA_API
int HttpAsynchResp_setHeader(
271 BA_API
int HttpAsynchResp_sendData(
273 BA_API
int HttpAsynchResp_sendNextChunk(
276 #define HttpAsynchResp_isAsynchThreadMode(o) ((o)->mutex ? TRUE : FALSE)
279 inline HttpAsynchResp::HttpAsynchResp(
char* buf,
int size,
HttpRequest* req) {
280 HttpAsynchResp_constructor(
this, buf, size, req);
283 HttpAsynchResp_constructor2(
this, buf, size, con);
286 return HttpAsynchResp_isValid(
this) ? TRUE : FALSE;
289 HttpAsynchResp_destructor(
this);
292 HttpAsynchResp_close(
this);
295 HttpAsynchResp_asynchThreadMode(
this);
298 return HttpAsynchResp_getMutex(
this);
301 return HttpAsynchResp_setConClose(
this);
304 return HttpAsynchResp_setConClose(
this);
307 return HttpAsynchResp_setStatus(
this, statusCode, protocol);
310 return HttpAsynchResp_setHeader(
this, name, value);
313 const void* data,
int pktSize,
int chunkSize) {
314 return HttpAsynchResp_sendData(
this, data, pktSize, chunkSize);
317 return HttpAsynchResp_sendNextChunk(
this,data,chunkSize); }
319 return HttpAsynchResp_getWriter(
this);
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:819
ThreadMutex * getMutex()
Get the dispatcher lock.
Definition: HttpAsynchResp.h:297
int setConClose()
Close connection when the HttpAsynchResp object is done.
Definition: HttpAsynchResp.h:300
bool isValid()
Returns true if the HttpConnection object is valid – i.e., if the socket connection is alive.
Definition: HttpAsynchResp.h:285
void asynchThreadMode()
Set in asynchronous thread mode so you can call the methods in this class without having to lock the ...
Definition: HttpAsynchResp.h:294
Send data asynchronously to a client.
Definition: HttpAsynchResp.h:110
int setHeader(const char *name, const char *value)
Sets a HTTP response header with the given name and value.
Definition: HttpAsynchResp.h:309
int sendNextChunk(const void *data, int chunkSize)
Send next chunk if not all data was sent with sendData.
Definition: HttpAsynchResp.h:316
int setLingeringClose()
Used if a resource must close an active HttpAsynchReq and data is pending.
Definition: HttpAsynchResp.h:303
void baFree(void *p)
Deallocates space to which it points.
Contains information about the physical socket connection.
Definition: HttpConnection.h:76
void * baMalloc(size_t size)
Returns pointer to uninitialized newly-allocated space for an object of size "size",...
void close()
Flushes the response, if any, and checks the connection object: A valid and persistent HTTP 1....
Definition: HttpAsynchResp.h:291
The BufPrint class, which implements an ANSI compatible printf method, is a base class used by severa...
Definition: BufPrint.h:122
BufPrint * getWriter()
BufPrint is used when sending data of unknown length.
Definition: HttpAsynchResp.h:318
~HttpAsynchResp()
Calls method close.
Definition: HttpAsynchResp.h:288
int sendData(const void *data, int pktSize, int chunkSize)
Send data of known size to client.
Definition: HttpAsynchResp.h:312
A mutual exclusion class.
Definition: ThreadLib.h:186
int setStatus(int statusCode, const char *protocol=0)
Set the response status code.
Definition: HttpAsynchResp.h:306