#include <HTTPConnection.h>
Classes | |
struct | BadResponse |
Encapsulates a raw HTTP response and response code. More... | |
Public Types | |
enum | ResponseCodes |
Public Member Functions | |
HTTPConnection () | |
Returns a HTTP object associated with this tcp connection. | |
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") |
void | Get (const char *path) |
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) |
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. |
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.
Results of HTTP requests. Standard response codes are < 999 ( define HTTP codes and our internal codes as needed )
void RakNet::HTTPConnection::Get | ( | const char * | path | ) |
Get a file from a webserver
path | the path on the remote server you want to GET from. For example "index.html" |
void RakNet::HTTPConnection::Init | ( | TCPInterface * | _tcp, | |
const char * | host, | |||
unsigned short | port = 80 | |||
) |
void RakNet::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
path | the path on the remote server you want to POST to. For example "index.html" | |
data | A NULL terminated string to submit to the server | |
contentType | "Content-Type:" passed to post. |
void RakNet::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
packet | NULL or a packet associated with our host and port |
RakNet::RakString RakNet::HTTPConnection::Read | ( | void | ) |
Get one result from the server