Single instance HTTP Server using WiFly Interface.

Dependents:   WiFlyHTTPServerSample MultiThreadingHTTPServer

Embed: (wiki syntax)

« Back to documentation index

HTTPRequestHandler Class Reference

HTTPRequestHandler Class Reference

class HTTPRequestHandler is the base class for HTTP Handler request implementations. More...

#include <HTTPRequestHandler.h>

Inherited by HTTPFsRequestHandler, and HTTPRpcRequestHandler.

Public Member Functions

 HTTPRequestHandler (HTTPConnection::HTTPMessage &)
 Constructor for HTTPRequestHandler objects.
virtual ~HTTPRequestHandler ()
 Destructor for HTTPRequestHandler objects.
virtual void handleRequest ()
 Handler function which will be used by the HTTPServer to serve requests.
virtual void handleError (int errorCode, HTTPHeaders *header=NULL)
 Handler function which will handle errors and return errors correctly.
void startResponse (int returnCode, long nLen, HTTPHeaders *header=NULL)
 Function sends the response header which consists of the return code and the headers section the response header also contains the length (in bytes) of the body.

Protected Member Functions

virtual int handleGetRequest ()=0
 Handler function to serve GET requests.
virtual int handlePutRequest ()=0
 Handler function to serve PUT requests.
virtual int handlePostRequest ()=0
 Handler function to serve POST requests.

Detailed Description

class HTTPRequestHandler is the base class for HTTP Handler request implementations.

Definition at line 79 of file HTTPRequestHandler.h.


Constructor & Destructor Documentation

Constructor for HTTPRequestHandler objects.

Definition at line 53 of file HTTPRequestHandler.cpp.

~HTTPRequestHandler (  ) [virtual]

Destructor for HTTPRequestHandler objects.

Definition at line 60 of file HTTPRequestHandler.cpp.


Member Function Documentation

void handleError ( int  errorCode,
HTTPHeaders *  header = NULL 
) [virtual]

Handler function which will handle errors and return errors correctly.

Parameters:
errorCode: The error code returned by the HTTP Server to represent the error condition.
msg: Request Message information.
tcp: The socket which represents the active connection to the client.

Definition at line 118 of file HTTPRequestHandler.cpp.

virtual int handleGetRequest (  ) [protected, pure virtual]

Handler function to serve GET requests.

Download ressource from server from uri location.

Implemented in HTTPFsRequestHandler.

virtual int handlePostRequest (  ) [protected, pure virtual]

Handler function to serve POST requests.

Send data to webserver. Can also be appended to uri.

Implemented in HTTPFsRequestHandler.

virtual int handlePutRequest (  ) [protected, pure virtual]

Handler function to serve PUT requests.

Upload ressource to server to uri location.

Implemented in HTTPFsRequestHandler.

void handleRequest (  ) [virtual]

Handler function which will be used by the HTTPServer to serve requests.

The default version of this function will dispatch respective handler member functions according to the request type given in the HTTPMessage object. The list of possible functions dispatched is : * handleGetRequest * handlePostRequest * handlePutRequest

Definition at line 84 of file HTTPRequestHandler.cpp.

void startResponse ( int  returnCode,
long  nLen,
HTTPHeaders *  header = NULL 
)

Function sends the response header which consists of the return code and the headers section the response header also contains the length (in bytes) of the body.

You need to send the body right after calling this function. Please note that you do not need to consider the terminating CR+LF after your last CR+LF. This will be sent automatically once endResponse is called. Also the Length given in nLen does not need to consider this additional chars. It will also be automatically added in startResponse. if you need to change the headers, please do NOT specify the Content-Length Header. This is done automatically be the function.

Definition at line 142 of file HTTPRequestHandler.cpp.