(For advanced use of the Barracuda server)
Barracuda comes with 6 classes for receiving and transmitting data by using the HTTP protocol:
Please see the HttpResMgr example and the HttpResMgr.c source file for examples using HttpAsynchReq, MultipartUpload, and HttpAsynchResp.
An instance of the HttpAsynchReq class is created in a resource such as an HttpDir or HttpPage when the Web-Server delegates a client request to the resource.
You provide a buffer and an OnData callback function to an instance of a HttpAsynchReq class. The callback function is called N times where N is data size/buffer size. If buffer size >= data size, i.e. greater or equal to the data being received, then the OnData function is called once.
An instance of the HttpAsynchReq class is typically used when receiving large objects such as a file.
An instance of the HttpAsynchReq class cannot send a response message so a HttpAsynchReq object is typically used together with a HttpAsynchResp object.
A resource must always respond to a request and a HttpAsynchReq object must, therefore, use a HttpAsynchResp object when responding to a request. Thus, it is suggested that you use a HttpAsynchReqResp object which implements HttpAsynchReq and HttpAsynchResp, instead of first creating a HttpAsynchReq object and then later creating a HttpAsynchResp object.
An instance of the HttpAsynchResp class is used as a lightweight method for sending response data to a client; thus it can be used as a replacement for the HttpCmdThreadPool.
An instance of the HttpAsynchResp class is also used in combination with an instance of the HttpAsynchReq class. An HttpAsynchReq object cannot send a response object, thus an HttpAsynchResp is needed for the response message.
The HttpAsynchResp class is designed such that it moves the active HttpConnection object (the socket connection) from either a HttpRequest object or from a HttpAsynchReq object. Thus an instance of the HttpAsynchResp class is normally created in a resource service function such as a HttpPage or a HttpDir or in the HttpAsynchReq OnData event method.
The HttpAsynchResp can be used directly from within the HttpAsynchReq OnData event method, but you should not do any lengthy operations in the OnData event method as this method runs in the context of the thread running the SoDisp object.
HttpAsynchResp can assist you in streaming audio or video to a client.
The HttpAsynchResp is designed such that an active instance can be moved to a thread outside of the Barracuda environment. The HttpAsynchResp class has a number of methods you can use from within the thread when sending a response message. Thus an external thread can use the HttpAsynchResp object to respond to lengthy calculations or when streaming content to a client.