HTTP.h
Go to the documentation of this file.00001 00015 #ifndef __HTTP_H__ 00016 #define __HTTP_H__ 00017 00018 // Includes 00019 #include "Singleton.h" 00020 #include "StringId.h" 00021 #include "Array.h" 00022 #include "DynamicBuffer.h" 00023 00024 // Forward declares 00025 class HTTP_Resource; 00026 class Platform_Network_Client; 00027 00028 // HTTP 00029 class HTTP : public Singleton<HTTP> 00030 { 00031 public: 00032 HTTP(); 00033 00034 ~HTTP(); 00035 00036 void Update( 00037 float deltaTime 00038 ); 00039 00040 enum RequestStatus 00041 { 00042 Status_Connecting, 00043 Status_Pending, 00044 Status_Completed, 00045 Status_Failed, 00046 Status_TimedOut, 00047 Status_Invalid, 00048 }; 00049 00050 00051 int Request_Get( 00052 const char* url, 00053 float timeOut = 0.0f 00054 ); 00055 00056 int Request_Post( 00057 const char* url, 00058 const void* data, 00059 int size, 00060 float timeOut = 0.0f 00061 ); 00062 00063 RequestStatus GetRequestStatus( 00064 int requestHandle 00065 ); 00066 00067 float GetPercentageReceived( 00068 int requestHandle 00069 ); 00070 00071 HTTP_Resource* GetResource( 00072 int requestHandle 00073 ); 00074 00075 void DiscardRequest( 00076 int requestHandle 00077 ); 00078 00079 private: 00080 struct Request; 00081 00082 void SplitURL( 00083 const char* url, 00084 char*& address, 00085 char*& port, 00086 char*& resource 00087 ); 00088 00089 Request* GetRequest( 00090 int requestHandle 00091 ); 00092 00093 private: 00094 int currentRequestHandle_; 00095 00096 struct Request 00097 { 00098 int handle; 00099 bool usingGetMethod; 00100 DynamicBuffer postData; 00101 RequestStatus status; 00102 float timeOut_; 00103 float elapsedTime_; 00104 Platform_Network_Client* connection; 00105 char* requestString; 00106 DynamicBuffer receivedData; 00107 StringId contentType; 00108 int contentLength; 00109 int headerLength; 00110 HTTP_Resource* resource; 00111 }; 00112 00113 Array<Request*> requests_; 00114 }; 00115 00116 00117 #define siHTTP HTTP::GetInstance() 00118 00119 #endif /* __HTTP_H__ */
Reproduction/republishing of any material on this site without permission is strictly prohibited.
