HTTPConnection Class Reference

Use HTTPConnection to communicate with a web server. Start an instance of TCPInterface via the Start() command. Instantiate a new instance of HTTPConnection, and associate TCPInterface with the class in the constructor. Use Post() to send commands to the web server, and ProcessDataPacket() to update the connection with packets returned from TCPInterface that have the system address of the web server This class will handle connecting and reconnecting as necessary. More...

#include <HTTPConnection.h>

List of all members.

Classes

struct  BadResponse
 Encapsulates a raw HTTP response and response code. More...

Public Types

enum  ResponseCodes

Public Member Functions

 HTTPConnection (TCPInterface &tcp, const char *host, unsigned short port=80)
void Post (const char *path, const char *data, const char *_contentType="application/x-www-form-urlencoded")
RakNet::RakString Read (void)
void Update (void)
 Call periodically to do time-based updates.
SystemAddress GetServerAddress (void) const
 Returns the address of the server we are connected to.
bool ProcessFinalTCPPacket (Packet *packet)
bool HasBadResponse (int *code, RakNet::RakString *data)
 Queued events of failed exchanges with the HTTP server.
bool IsBusy (void) const
 Returns false if the connection is not doing anything else.


Detailed Description

Use HTTPConnection to communicate with a web server. Start an instance of TCPInterface via the Start() command. Instantiate a new instance of HTTPConnection, and associate TCPInterface with the class in the constructor. Use Post() to send commands to the web server, and ProcessDataPacket() to update the connection with packets returned from TCPInterface that have the system address of the web server This class will handle connecting and reconnecting as necessary.

Note that only one Post() can be handled at a time.


Member Enumeration Documentation

Results of HTTP requests. Standard response codes are < 999 ( define HTTP codes and our internal codes as needed )


Constructor & Destructor Documentation

HTTPConnection::HTTPConnection ( TCPInterface &  tcp,
const char *  host,
unsigned short  port = 80 
)

Returns a HTTP object associated with this tcp connection

Precondition:
tcp should already be started


Member Function Documentation

void HTTPConnection::Post ( const char *  path,
const char *  data,
const char *  _contentType = "application/x-www-form-urlencoded" 
)

Submit data to the HTTP server HTTP only allows one request at a time per connection

Precondition:
IsBusy()==false
Parameters:
path the path on the remote server you want to POST to. For example "mywebpage/index.html"
data A NULL terminated string to submit to the server
contentType "Content-Type:" passed to post.

bool HTTPConnection::ProcessFinalTCPPacket ( Packet packet  ) 

Process an HTTP data packet returned from TCPInterface Returns true when we have gotten all the data from the HTTP server. If this returns true then it's safe to Post() another request Deallocate the packet as usual via TCPInterface

Parameters:
packet NULL or a packet associated with our host and port
Returns:
true when all data from one Post() has been read.

RakString HTTPConnection::Read ( void   ) 

Get data returned by the HTTP server If IsFinished()==false then this may be empty or a partial response.


The documentation for this class was generated from the following files:

Generated on Tue Feb 10 08:44:07 2009 for RakNet by  doxygen 1.5.7.1