Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include "NativeFeatureIncludes.h"
00019 #if _RAKNET_SUPPORT_HTTPConnection==1
00020
00021 #ifndef __HTTP_CONNECTION
00022 #define __HTTP_CONNECTION
00023
00024 #include "Export.h"
00025 #include "RakString.h"
00026 #include "RakMemoryOverride.h"
00027 #include "RakNetTypes.h"
00028 #include "DS_Queue.h"
00029
00030 class TCPInterface;
00031 struct SystemAddress;
00032
00040 class RAK_DLL_EXPORT HTTPConnection
00041 {
00042 public:
00044 HTTPConnection();
00045 virtual ~HTTPConnection();
00046
00048 void Init(TCPInterface *_tcp, const char *host, unsigned short port=80);
00049
00057 void Post(const char *path, const char *data, const char *_contentType="application/x-www-form-urlencoded");
00058
00060 bool HasRead(void) const;
00061
00064 RakNet::RakString Read(void);
00065
00067 void Update(void);
00068
00070 SystemAddress GetServerAddress(void) const;
00071
00077 void ProcessTCPPacket(Packet *packet);
00078
00081 enum ResponseCodes { NoBody=1001, OK=200, Deleted=1002 };
00082
00083 HTTPConnection& operator=(const HTTPConnection& rhs){(void) rhs; return *this;}
00084
00086 struct BadResponse
00087 {
00088 public:
00089 BadResponse() {code=0;}
00090
00091 BadResponse(const unsigned char *_data, int _code)
00092 : data((const char *)_data), code(_code) {}
00093
00094 BadResponse(const char *_data, int _code)
00095 : data(_data), code(_code) {}
00096
00097 operator int () const { return code; }
00098
00099 RakNet::RakString data;
00100 int code;
00101 };
00102
00104 bool HasBadResponse(int *code, RakNet::RakString *data);
00105
00107 bool IsBusy(void) const;
00108
00110 int GetState(void) const;
00111
00112 struct OutgoingPost
00113 {
00114 RakNet::RakString remotePath;
00115 RakNet::RakString data;
00116 RakNet::RakString contentType;
00117 };
00118
00119 DataStructures::Queue<OutgoingPost> outgoingPosts;
00120 OutgoingPost currentProcessingRequest;
00121
00122 private:
00123 SystemAddress server;
00124 TCPInterface *tcp;
00125 RakNet::RakString host;
00126 unsigned short port;
00127 DataStructures::Queue<BadResponse> badResponses;
00128
00129 enum ConnectionState
00130 {
00131 CS_NONE,
00132 CS_DISCONNECTING,
00133 CS_CONNECTING,
00134 CS_CONNECTED,
00135 CS_PROCESSING,
00136 } connectionState;
00137
00138 RakNet::RakString incomingData;
00139 DataStructures::Queue<RakNet::RakString> results;
00140
00141 void CloseConnection();
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159 };
00160
00161 #endif
00162
00163 #endif // _RAKNET_SUPPORT_*