Barracuda Application Server C/C++ Reference
NO
HttpStack

Detailed Description

Collaboration diagram for HttpStack:

Modules

 HttpUpload
 

Classes

struct  MultipartUpload
 The MultipartUpload, which is an abstract base class, implements the functionality as specified in RFC 1867. More...
 
struct  HttpRecData
 The HttpRecData class makes it easy to upload packets or large data chunks when using Barracuda in multithread mode. More...
 
struct  HttpAsynchReq
 Asynchronously receive data in a resource such as HttpDir or HttpPage. More...
 
struct  HttpAsynchReqResp
 Simultaneously receive and send a stream of data. More...
 
struct  HttpAsynchResp
 Send data asynchronously to a client. More...
 

Typedefs

typedef void(* MultipartUpload_EndOfReq) (struct MultipartUpload *o)
 Executed by MultipartUpload when a multipart upload is completed. More...
 
typedef int(* MultipartUpload_FormData) (struct MultipartUpload *o, const char *name, const char *value)
 Executed by MultipartUpload every time a form data element such as "text" is found in the multipart data stream. More...
 
typedef int(* MultipartUpload_FileBegin) (struct MultipartUpload *o, const char *name, const char *fileName, const char *contentType, const char *contentTransferEncoding)
 Executed by MultipartUpload when a file is found in the multipart data stream. More...
 
typedef int(* MultipartUpload_FileData) (struct MultipartUpload *o, const U8 *data, U16 len)
 Executed by MultipartUpload when a data chunk is available. More...
 
typedef void(* MultipartUpload_Error) (struct MultipartUpload *o, MultipartUpload_ErrorType e)
 Executed by MultipartUpload if any errors are detected during parsing of the multipart data stream. More...
 
typedef struct MultipartUpload MultipartUpload
 The MultipartUpload, which is an abstract base class, implements the functionality as specified in RFC 1867. More...
 
typedef struct HttpRecData HttpRecData
 The HttpRecData class makes it easy to upload packets or large data chunks when using Barracuda in multithread mode. More...
 
typedef void(* HttpAsynchReq_OnData) (struct HttpAsynchReq *super, void *data, S32 size)
 Prototype for the HttpAsynchReq OnRequest callback. More...
 
typedef struct HttpAsynchReq HttpAsynchReq
 Asynchronously receive data in a resource such as HttpDir or HttpPage. More...
 
typedef HttpAsynchReqResp HttpAsynchReqResp
 Simultaneously receive and send a stream of data. More...
 
typedef HttpAsynchResp HttpAsynchResp
 Send data asynchronously to a client. More...
 

Enumerations

enum  MultipartUpload_ErrorType
 Error codes used by the callback function MultipartUpload_Error in interface class MultipartUpload.
 

Functions

 MultipartUpload::MultipartUpload (HttpServer *server, MultipartUpload_EndOfReq onEndOfReq, MultipartUpload_FormData onFormData, MultipartUpload_FileBegin onFileBegin, MultipartUpload_FileData onFileData, MultipartUpload_Error onError, U32 bufferSize, AllocatorIntf *allocator=0)
 
 MultipartUpload::~MultipartUpload ()
 Release buffers used during parsing the multipart stream.
 
int MultipartUpload::start (HttpRequest *req)
 Start receiving data asynchronously. More...
 
HttpConnectionMultipartUpload::getCon (MultipartUpload *o)
 Returns the internal active connection object. More...
 
HttpServerMultipartUpload::getServer ()
 Get the HttpServer instance.
 
static SBaFileSize HttpRecData::valid (HttpRequest *req)
 This method validates the client HTTP request. More...
 
 HttpRecData::HttpRecData (HttpRequest *req)
 The constructor is typically run by creating an object on the stack. More...
 
S32 HttpRecData::read (void *buf, S32 bufSize)
 Read data from socket. More...
 
 HttpRecData::~HttpRecData ()
 Destructor.
 
 HttpAsynchReq::HttpAsynchReq (HttpServer *server, HttpAsynchReq_OnData data)
 Create an instance of HttpAsynchReq. More...
 
 HttpAsynchReq::~HttpAsynchReq ()
 Terminate a HttpAsynchReq object.
 
SBaFileSize HttpAsynchReq::getPacketSizeLeft ()
 Returns the remaining packet size if the packet size is known – i.e., if the initial HTTP header had a Content-Length header. More...
 
void * HttpAsynchReq::getBuffer ()
 Returns a pointer to the internal buffer where the received data is stored. More...
 
SBaFileSize HttpAsynchReq::getBufferSize ()
 Returns the lenght of the internal buffer.
 
static SBaFileSize HttpAsynchReq::calcPacketSize (HttpRequest *req)
 Returns the packet size if the length is known. More...
 
int HttpAsynchReq::start (HttpRequest *req, void *buffer, S32 bufferSize)
 Start receiving data asynchronously. More...
 
void HttpAsynchReq::stop ()
 Aborts the operation and terminates the active socket connection.
 
HttpConnectionHttpAsynchReq::getCon (HttpAsynchReq *o)
 Returns the internal active connection object. More...
 
 HttpAsynchReqResp::HttpAsynchReqResp (HttpServer *server, HttpAsynchReq_OnData onData)
 Create a HttpAsynchReqResp instance. More...
 
int HttpAsynchReqResp::start (HttpRequest *req, void *recBuf, S32 recBufSize, void *sendBuf, S32 sendBufSize)
 Start the HttpAsynchReqResp object. More...
 
int HttpAsynchReqResp::startResp (HttpRequest *req, void *sendBuf, S32 sendBufSize)
 Start response if you know that all data was received by the web-server. More...
 
ThreadMutexHttpAsynchReqResp::getMutex ()
 Get the dispatcher lock.
 
HttpServerHttpAsynchReqResp::getServer ()
 Get the HttpServer object.
 
HttpAsynchRespHttpAsynchReqResp::getResponse ()
 Get the response object. More...
 
 HttpAsynchResp::HttpAsynchResp (char *buf, int size, HttpRequest *req)
 Initiate a HttpAsynchResp from a HttpRequest object. More...
 
 HttpAsynchResp::HttpAsynchResp (char *buf, int size, HttpConnection *con)
 Initiate a HttpAsynchResp from a HttpConnection object. More...
 
bool HttpAsynchResp::isValid ()
 Returns true if the HttpConnection object is valid – i.e., if the socket connection is alive.
 
 HttpAsynchResp::~HttpAsynchResp ()
 Calls method close.
 
void HttpAsynchResp::close ()
 Flushes the response, if any, and checks the connection object: A valid and persistent HTTP 1.1 socket connection object is moved back into the Web-server's HTTP 1.1 HttpConnection pool such that the connection can be recycled. More...
 
void HttpAsynchResp::asynchThreadMode ()
 Set in asynchronous thread mode so you can call the methods in this class without having to lock the dispatcher mutex. More...
 
ThreadMutexHttpAsynchResp::getMutex ()
 Get the dispatcher lock. More...
 
int HttpAsynchResp::setConClose ()
 Close connection when the HttpAsynchResp object is done. More...
 
int HttpAsynchResp::setLingeringClose ()
 Used if a resource must close an active HttpAsynchReq and data is pending. More...
 
int HttpAsynchResp::setStatus (int statusCode, const char *protocol=0)
 Set the response status code. More...
 
int HttpAsynchResp::setHeader (const char *name, const char *value)
 Sets a HTTP response header with the given name and value. More...
 
int HttpAsynchResp::sendData (const void *data, int pktSize, int chunkSize)
 Send data of known size to client. More...
 
int HttpAsynchResp::sendNextChunk (const void *data, int chunkSize)
 Send next chunk if not all data was sent with sendData. More...
 
BufPrintHttpAsynchResp::getWriter ()
 BufPrint is used when sending data of unknown length. More...
 

Typedef Documentation

◆ HttpAsynchReq

typedef struct HttpAsynchReq HttpAsynchReq

Asynchronously receive data in a resource such as HttpDir or HttpPage.


An instance of the HttpAsynchReq class can be used as a method to receive any kind of data from a client as long as the client does not send the data as a multipart/form-data. A resource receiving multipart/form-data must use the MultipartUpload class.

You typically create an instance of this class in a resource when receiving a request. You can optionally keep instances of this class in a pool. The object is started by calling method start.

HttpAsynchReq is an abstract base class; thus, you must inherit and implement the socket event method. See constructor for how to install the event function.

The detached socket object is installed directly into the SoDisp object, and any socket event is directed to this object. The callback method specified in HttpAsynchReq::start is triggered when the buffer is full.

See also
HttpRecData

◆ HttpAsynchReq_OnData

typedef void(* HttpAsynchReq_OnData) (struct HttpAsynchReq *super, void *data, S32 size)

Prototype for the HttpAsynchReq OnRequest callback.

The callback is called when the internal buffer is full and at end of stream. End of stream is signaled by setting data = NULL and size=0.

If a HTTP client sends a 100-continue message, the function is initially called with a non NULL data pointer, but with size set to zero. The callback should create the resource and manage the error if creating the resource fails.

Parameters
superThe object pointer, which you must upcast to your class implementation, i.e. MyAsynchReq* o = (MyAsynchReq*)super;
datapointer to received data.
sizeis the size of the received data.

◆ HttpAsynchReqResp

Simultaneously receive and send a stream of data.

The HttpAsynchReqResp class makes it possible to asynchronously receive and send data at the same time. The HttpAsynchReqResp can also be used as a replacement for using a HttpAsynchReq and HttpAsynchResp object. An HttpAsynchReqResp instance is easier to use than first using a HttpAsynchReq object for receiving data and then later using a HttpAsynchResp for sending a response message.

◆ HttpAsynchResp

Send data asynchronously to a client.

Please see the HTTP protocol stack for an introduction to the HttpAsynchResp class.

You must lock the dispatcher prior to calling any methods in the HttpAsynchResp class unless the object is used from within a Barracuda event callback or you have called method HttpAsynchResp::asynchThreadMode. See using multiple threads in the Barracuda introduction for more information on protecting the Barracuda code.

There is one exception to the above. You can call method HttpAsynchResp::getMutex without locking the dispatcher first. You cannot lock the dispatcher unless you first have a reference to the dispatcher object.

example code

while(sendData)
{
ThreadLock(myAsynchResp->getMutex());
myAsynchResp->getWriter()->printf("Hi client");
}

Certain restrictions apply to how you can use this object. This is, after all, a lightweight version of HttpResponse. The HttpAsynchResp object does not have large buffers for storing out data. Thus, the methods must be called in the following order:

Calling methods setConClose, setStatus, and setHeader are optional.

Calling method setHeader implicitly calls method setStatus with status code 200 unless you already called setStatus.

Sending data using method sendData or the methods in BufPrint flushes the HTTP header. Thus, you cannot call method setHeader after the HTTP header is flushed.

You must use one of BufPrint or ( HttpAsynchResp::sendData [ & HttpAsynchResp::sendNextChunk ] ) when sending response data.

◆ HttpRecData

typedef struct HttpRecData HttpRecData

The HttpRecData class makes it easy to upload packets or large data chunks when using Barracuda in multithread mode.

This class gives similar functionality to HttpAsynchReq and makes it possible to receive any kind of data sent from a client in a CSP page or in a HttpDir/HttpPage.

CSP example

<%p
if(HttpRecData::valid(req) >=0)
{
HttpRecData rd(request); //Create on stack inside a CSP page.
char buf[1500];
S32 len;
while( (len = rd.read(buf, sizeof(buf))) > 0)
{
//Save buf
}
if(len < 0)
response->printf("failed");
else
response->printf("OK");
}
else
{
response->printf("Bugger off");
}
%>

◆ MultipartUpload

The MultipartUpload, which is an abstract base class, implements the functionality as specified in RFC 1867.

A HTTP POST in multipart mode uses a rather complex scheme for transferring data, and we do not recommend using this class unless you use a browser for uploading data or need to send a stream of binary files and application/x-www-form-urlencoded data to the server. Transferring files from a client to the server is easier with HTTP PUT, but a browser can, unfortunately, not upload data using HTTP PUT.

You must subclass the MultipartUpload class and implement a number of 'onEvent' callback methods. The 'onEvent' methods are called as the MultipartUpload decodes the stream of data uploaded from the client.

The MultipartUpload class is designed such that any error detected in the 'onEvent' methods must make sure the MultipartUpload destructor or call MultipartUpload::getCon is called before returning a non-zero value. You may also have to release the memory associated with the MultipartUpload instance – i.e. with the instance of the class sub-classing MultipartUpload. The MultipartUpload class is designed such that it allows the callback to destroy the object itself; that is, the MultipartUpload logic makes sure no data, except for stack variables, are used when the callback returns an error code.

◆ MultipartUpload_EndOfReq

typedef void(* MultipartUpload_EndOfReq) (struct MultipartUpload *o)

Executed by MultipartUpload when a multipart upload is completed.

Returns
This function must return 0 on success. Any other value signals an error condition to the MultiPartUpload class. This method must call the MultipartUpload destructor or call MultipartUpload::getCon

◆ MultipartUpload_Error

typedef void(* MultipartUpload_Error) (struct MultipartUpload *o, MultipartUpload_ErrorType e)

Executed by MultipartUpload if any errors are detected during parsing of the multipart data stream.

This method must call the MultipartUpload destructor or call MultipartUpload::getCon.

Parameters
eis the error code.

◆ MultipartUpload_FileBegin

typedef int(* MultipartUpload_FileBegin) (struct MultipartUpload *o, const char *name, const char *fileName, const char *contentType, const char *contentTransferEncoding)

Executed by MultipartUpload when a file is found in the multipart data stream.

Parameters
namethe name as specified in the HTML "input" type.
fileNameis the name and possible path of the file entered by the user. The path separator is platform dependent.
contentTypeis the content mime type such as "text/plain". This parameter is NULL if not specified in the multipart data stream.
contentTransferEncodingis the transfer encoding such as "gzip". This parameter is NULL if not specified in the multipart data stream.
Returns
This function must return 0 on success. Any other value signals an error condition to the MultiPartUpload class. This method must call the MultipartUpload destructor or call MultipartUpload::getCon if returning a non zero value.

◆ MultipartUpload_FileData

typedef int(* MultipartUpload_FileData) (struct MultipartUpload *o, const U8 *data, U16 len)

Executed by MultipartUpload when a data chunk is available.

The servlet first calls MultipartUpload_FileBegin and thereafter calls this method repeatedly until all data is received. End of file is signalled by setting the two input parameters to 0.

Parameters
dataa pointer to the received data.
lenlength of the data chunk.
Returns
This function must return 0 on success. Any other value signals an error condition to the MultiPartUpload class. This method must call the MultipartUpload destructor or call MultipartUpload::getCon if returning a non zero value.

◆ MultipartUpload_FormData

typedef int(* MultipartUpload_FormData) (struct MultipartUpload *o, const char *name, const char *value)

Executed by MultipartUpload every time a form data element such as "text" is found in the multipart data stream.

The browser bundles all data into the multipart stream sent to the server. The MultipartUpload servlet calls the formData callback function when it detects form data.

Parameters
namethe name as specified in the HTML "input" type.
valuethe text entered by the user.
Returns
This function must return 0 on success. Any other value signals an error condition to the MultiPartUpload class. This method must call the MultipartUpload destructor or call MultipartUpload::getCon if returning a non zero value.

Function Documentation

◆ asynchThreadMode()

void HttpAsynchResp::asynchThreadMode ( )

Set in asynchronous thread mode so you can call the methods in this class without having to lock the dispatcher mutex.

You must not call this method if you are calling the methods in this class from within a callback originating from the socket dispatcher SoDisp – i.e., if the mutex is already locked.

◆ calcPacketSize()

SBaFileSize HttpAsynchReq::calcPacketSize ( HttpRequest req)
static

Returns the packet size if the length is known.

This method is typically used before calling method HttpAsynchReq::start. You can calculate the length of the required buffer such that the entire data being received fits into the buffer. The OnData event method fires when the buffer is full. Thus, it is possible to make the OnData event method fire one time only if the buffer is large enough to contain all data being received.

  • Returns 0 if data is URL-encoded. URL-encoded data is handled directly by the web-server.
  • Returns -1 if payload data is of type "chunk transfer encoding". The size is unknown. When the OnData event method "signals end of data", we know that this is the end of the data stream.
  • Returns -2 if payload data is of type "multipart/form-data". This is an error. A resource receiving multipart/form-data must use the MultipartUpload class

◆ close()

void HttpAsynchResp::close ( )

Flushes the response, if any, and checks the connection object: A valid and persistent HTTP 1.1 socket connection object is moved back into the Web-server's HTTP 1.1 HttpConnection pool such that the connection can be recycled.

A non-persistent HTTP connection such as a HTTP 1.0 connection is terminated.

◆ getBuffer()

void * HttpAsynchReq::getBuffer ( )

Returns a pointer to the internal buffer where the received data is stored.

The buffer is set in method HttpAsynchReq::start.

◆ getCon() [1/2]

HttpConnection * HttpAsynchReq::getCon ( HttpAsynchReq o)

Returns the internal active connection object.

This method is typically called from within the OnData event method when all data is received and you are moving the active connection object to an HttpAsynchResp object.

C code example:

HttpAsynchResp_constructor2(
resp, buf, bufSize, HttpAsynchReq_ getCon(req));

◆ getCon() [2/2]

HttpConnection * MultipartUpload::getCon ( MultipartUpload o)

Returns the internal active connection object.

This method is typically called from within the onEndOfReq event method when all data is received and you are moving the active connection object to an HttpAsynchResp object.

C code example:

HttpAsynchResp_constructor2(
resp, buf, bufSize, MultipartUpload_getCon(req));

◆ getMutex()

ThreadMutex * HttpAsynchResp::getMutex ( )

Get the dispatcher lock.

This is the only method in this class that can be called without locking the dispatcher.

◆ getPacketSizeLeft()

SBaFileSize HttpAsynchReq::getPacketSizeLeft ( )

Returns the remaining packet size if the packet size is known – i.e., if the initial HTTP header had a Content-Length header.

This method is typically used in the OnData callback method. The method initially returns the same length as returned by HttpAsynchReq::calcPacketSize.

Returns
  • A value > 0 if the packet size is known.
  • -1: data is of type "chunk transfer encoding". This is OK, but application/callbacks cannot use method getPacketSizeLeft.
  • -2: Error: Payload data is of type "multipart/form-data".
  • -3: Error: Data is x-www-form-urlencoded. The data was consumed by the web-server.

◆ getResponse()

HttpAsynchResp * HttpAsynchReqResp::getResponse ( )

Get the response object.

The object used when sending response data.

◆ getWriter()

BufPrint * HttpAsynchResp::getWriter ( )

BufPrint is used when sending data of unknown length.

For a HTTP/1.1. connection, the data is sent in chunk transfer mode.

This method returns NULL if HttpAsynchResp::sendData was called prior to this method.

◆ HttpAsynchReq()

HttpAsynchReq::HttpAsynchReq ( HttpServer server,
HttpAsynchReq_OnData  data 
)

Create an instance of HttpAsynchReq.

Parameters
serveris a pointer to the HttpServer object.
datais a pointer to the socket event function. HttpAsynchReq is an abstract class and you must, therefore, implement the OnData socket event method.

◆ HttpAsynchReqResp()

HttpAsynchReqResp::HttpAsynchReqResp ( HttpServer server,
HttpAsynchReq_OnData  onData 
)

Create a HttpAsynchReqResp instance.

Parameters
serverthe HttpServer instance.
onDatathe asynchronous receive callback method. HttpAsynchReqResp inherits from HttpAsynchReq and it is the HttpAsynchReq object which calls the callback method when the internal buffer is full. End of stream is signaled by setting the two parameters to the callback to null.

◆ HttpAsynchResp() [1/2]

HttpAsynchResp::HttpAsynchResp ( char *  buf,
int  size,
HttpConnection con 
)

Initiate a HttpAsynchResp from a HttpConnection object.

Parameters
bufthe output buffer. Minimum value is 255 bytes.
sizethe output buffer size.
conthe active connection object is moved from HttpConnection to this object.

◆ HttpAsynchResp() [2/2]

HttpAsynchResp::HttpAsynchResp ( char *  buf,
int  size,
HttpRequest req 
)

Initiate a HttpAsynchResp from a HttpRequest object.

Parameters
bufthe output buffer. Minimum value is 255 bytes.
sizethe output buffer size.
reqthe active connection object is moved from HttpRequest to this object.

◆ HttpRecData()

HttpRecData::HttpRecData ( HttpRequest req)

The constructor is typically run by creating an object on the stack.

Parameters
reqis the page HttpRequest object.

◆ MultipartUpload()

MultipartUpload::MultipartUpload ( HttpServer server,
MultipartUpload_EndOfReq  onEndOfReq,
MultipartUpload_FormData  onFormData,
MultipartUpload_FileBegin  onFileBegin,
MultipartUpload_FileData  onFileData,
MultipartUpload_Error  onError,
U32  bufferSize,
AllocatorIntf allocator = 0 
)
Parameters
serveris the Web-Server object.
onEndOfReqis called when the multipart upload is completed. See MultipartUpload_EndOfReq.
onFormDatathe function where you process form data. See MultipartUpload_FormData.
onFileBeginis called when a file is found in the input stream. See MultipartUpload_FileBegin.
onFileDatais repeatedly called until end of file. See MultipartUpload_FileData.
onErroris called if an error is encountered when processing the input stream. See MultipartUpload_Error.
bufferSizeis the size of the internal buffer used when parsing the received data stream. This size must be, at a minimum, the size of the largest form submitted. This size should probably be > 10K.
allocatorAn allocator used for various small string allocations needed when parsing the incomming data stream and for allocating the internal buffer. The size of the internal buffer is set with parameter 'bufferSize'.

◆ read()

S32 HttpRecData::read ( void *  buf,
S32  bufSize 
)

Read data from socket.

Parameters
bufis the buffer to where the data is saved.
bufSizeis the size of the buffer.
Returns
the length received. The method returns 0 when all data is received. The method returns a negative value if the socket connection fails.

◆ sendData()

int HttpAsynchResp::sendData ( const void *  data,
int  pktSize,
int  chunkSize 
)

Send data of known size to client.

Parameters
datathe data to send.
pktSizeThe size of the data to send.
chunkSizethe size of parameter 'data'. Set this parameter to pktSize if all data is sent in the sendData call. Otherwise, set chunkSize to the size of the chunk being sent, and then call method sendNextChunk.

◆ sendNextChunk()

int HttpAsynchResp::sendNextChunk ( const void *  data,
int  chunkSize 
)

Send next chunk if not all data was sent with sendData.

Parameters
datathe data to send.
chunkSizethe size of parameter 'data'.

◆ setConClose()

int HttpAsynchResp::setConClose ( )

Close connection when the HttpAsynchResp object is done.

A persistent HTTP 1.1 connection is recycled and sent back to the connection pool in the web-server when the HttpAsynchResp object is done. Calling this method makes sure the connection closes when the HttpAsynchResp object is done. You should call this method if you stream data such as audio.

◆ setHeader()

int HttpAsynchResp::setHeader ( const char *  name,
const char *  value 
)

Sets a HTTP response header with the given name and value.

Parameters
namethe name of the header to set.
valuethe header value.

◆ setLingeringClose()

int HttpAsynchResp::setLingeringClose ( )

Used if a resource must close an active HttpAsynchReq and data is pending.

If a server closes the input side of the connection while the client is sending data (or is planning to send data), then the server's TCP stack will signal an RST (reset) back to the client. This forces a disconnect before client can read response data.

See Appendix 4 in the Apache lingering close doc for more information.

Please note that Barracuda is not implementing this by using SO_LINGER, but is instead using a lingering close queue.

◆ setStatus()

int HttpAsynchResp::setStatus ( int  statusCode,
const char *  protocol = 0 
)

Set the response status code.

The default return code is 200.

Parameters
statusCodeThe HTTP status code
protocolset the protocol version. The protocol is set to "1.1" if this parameter is NULL.

◆ start() [1/3]

int MultipartUpload::start ( HttpRequest req)

Start receiving data asynchronously.

The active socket object is detached from the web-server and moved into the MultipartUpload object. The MultipartUpload object is inserted into the SoDisp object, thus causing the socket dispatcher to fire receive events directly to the MultipartUpload object. The event methods are called: when the buffer is full, receiving form data, etc.

◆ start() [2/3]

int HttpAsynchReq::start ( HttpRequest req,
void *  buffer,
S32  bufferSize 
)

Start receiving data asynchronously.

The active socket object is detached from the web-server and moved into the HttpAsynchReq object. The HttpAsynchReq object is inserted into the SoDisp object, thus causing the socket dispatcher to fire receive events directly to the HttpAsynchReq object. The event method OnData is called when the buffer is full. Thus, the OnData event method can be called a number of times if the buffer is not large enough to contain the data being received.

◆ start() [3/3]

int HttpAsynchReqResp::start ( HttpRequest req,
void *  recBuf,
S32  recBufSize,
void *  sendBuf,
S32  sendBufSize 
)

Start the HttpAsynchReqResp object.

The onData callback method is called directly if all data was received by the client; otherwise, the HttpAsynchReq object is installed into the SoDisp. The method returns a negative value if the HttpAsynchReq object failed to start. The method returns 0 if the object started successfully or if the destructor was called from within the onData callback.

Parameters
reqthe HttpRequest object.
recBufthe receive buffer. The onData callback is called when the buffer is full.
recBufSizesize of recBuf.
sendBufsend buffer used by HttpAsynchResp.
sendBufSizethe size of the send buffer. Min size is 256.

◆ startResp()

int HttpAsynchReqResp::startResp ( HttpRequest req,
void *  sendBuf,
S32  sendBufSize 
)

Start response if you know that all data was received by the web-server.

This is a faster method than calling start if you know that the web-server received all data in its internal buffer before delegating the request to the requested service.

◆ valid()

SBaFileSize HttpRecData::valid ( HttpRequest req)
static

This method validates the client HTTP request.

The data received from the client must have a content-length or be chunk encoded.

Returns
the content length if this is a valid request. The return value can be zero if the client sends chunk encoded data. This method returns the following error codes:
  • -1: Missing content-length and not chunk encoding.
  • -2: URL encoded data consumed by web-server.
  • -3: Received multipart/form-data. Use MultipartUpload.
HttpResponse::printf
int printf(const char *fmt,...)
printf is used for sending formatted data to the client.
Definition: HttpServer.h:1810
HttpAsynchReq::getCon
HttpConnection * getCon(HttpAsynchReq *o)
Returns the internal active connection object.
Definition: HttpAsynchReq.h:251
HttpRecData::valid
static SBaFileSize valid(HttpRequest *req)
This method validates the client HTTP request.
Definition: HttpRecData.h:129
HttpRecData
The HttpRecData class makes it easy to upload packets or large data chunks when using Barracuda in mu...
Definition: HttpRecData.h:78
ThreadLock
This class provides an easy and less error prone way of locking and releasing a mutex.
Definition: ThreadLib.h:116