Classes | Public Types | Public Member Functions | Public Attributes

HTTPConnection Class Reference

Use HTTPConnection to communicate with a web server. More...

#include <HTTPConnection.h>

Collaboration diagram for HTTPConnection:
Collaboration graph
[legend]

List of all members.

Classes

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

Public Types

enum  ResponseCodes { NoBody = 1001, OK = 200, Deleted = 1002 }

Public Member Functions

 HTTPConnection ()
 Returns a HTTP object associated with this tcp connection.
virtual ~HTTPConnection ()
void Init (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")
bool HasRead (void) const
 Is there a Read result ready?
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.
void ProcessTCPPacket (Packet *packet)
HTTPConnectionoperator= (const HTTPConnection &rhs)
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.
int GetState (void) const

Public Attributes

DataStructures::Queue
< OutgoingPost
outgoingPosts
OutgoingPost currentProcessingRequest

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.

Definition at line 40 of file HTTPConnection.h.


Member Enumeration Documentation

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

Enumerator:
NoBody 
OK 
Deleted 

Definition at line 81 of file HTTPConnection.h.


Constructor & Destructor Documentation

HTTPConnection::HTTPConnection (  ) 

Returns a HTTP object associated with this tcp connection.

Definition at line 33 of file HTTPConnection.cpp.

HTTPConnection::~HTTPConnection ( void   )  [virtual]

Definition at line 269 of file HTTPConnection.cpp.

Here is the call graph for this function:


Member Function Documentation

SystemAddress HTTPConnection::GetServerAddress ( void   )  const

Returns the address of the server we are connected to.

Definition at line 192 of file HTTPConnection.cpp.

int HTTPConnection::GetState ( void   )  const

Definition at line 263 of file HTTPConnection.cpp.

bool HTTPConnection::HasBadResponse ( int *  code,
RakNet::RakString data 
)

Queued events of failed exchanges with the HTTP server.

Definition at line 55 of file HTTPConnection.cpp.

Here is the call graph for this function:

bool HTTPConnection::HasRead ( void   )  const

Is there a Read result ready?

Definition at line 170 of file HTTPConnection.cpp.

Here is the call graph for this function:

void HTTPConnection::Init ( TCPInterface _tcp,
const char *  host,
unsigned short  port = 80 
)
Precondition:
tcp should already be started

Definition at line 38 of file HTTPConnection.cpp.

bool HTTPConnection::IsBusy ( void   )  const

Returns false if the connection is not doing anything else.

Definition at line 258 of file HTTPConnection.cpp.

HTTPConnection& HTTPConnection::operator= ( const HTTPConnection rhs  )  [inline]

Definition at line 83 of file HTTPConnection.h.

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.

Definition at line 45 of file HTTPConnection.cpp.

Here is the call graph for this function:

void HTTPConnection::ProcessTCPPacket ( 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

Definition at line 196 of file HTTPConnection.cpp.

Here is the call graph for this function:

RakString HTTPConnection::Read ( void   ) 

Get one result from the server

Precondition:
HasResult must return true

Definition at line 174 of file HTTPConnection.cpp.

Here is the call graph for this function:

void HTTPConnection::Update ( void   ) 

Call periodically to do time-based updates.

Definition at line 70 of file HTTPConnection.cpp.

Here is the call graph for this function:


Member Data Documentation

Definition at line 120 of file HTTPConnection.h.

Definition at line 119 of file HTTPConnection.h.


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