- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# 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.

## 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")
  | Parameters:
  | contentType | "Content-Type:" passed to post.
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)
| Returns: true when all data from one Post() has been read.
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.
## Classes
struct | BadResponse
| Encapsulates a raw HTTP response and response code. More...

## 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

enum HTTPConnection::ResponseCodes

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"` |
| ) |  |  |

Parameters:

  | contentType | "Content-Type:" passed to post.

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

RakString HTTPConnection::Read | ( | void |  | ) |

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

bool HTTPConnection::ProcessFinalTCPPacket | ( | Packet * | packet | ) |

Returns:
  true when all data from one Post() has been read.

Parameters:

  | packet | NULL or a packet associated with our host and port

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

- C:/RakNet/Source/HTTPConnection.h
- C:/RakNet/Source/HTTPConnection.cpp