#ifndef _WININET_HTTPCONNECTION_HPP_ #define _WININET_HTTPCONNECTION_HPP_ #ifndef _COMMON_STRING_HPP_ #include #endif #ifndef _COMMON_BLOCK_HPP_ #include #endif #ifndef _COMMON_ARRAY_HPP_ #include #endif #ifndef _WININET_INTERNET_HPP_ #include #endif #ifndef _WININET_CONNECTION_HPP_ #include #endif #ifndef _WININET_HTTPHEADER_HPP_ #include #endif #ifndef _WININET_HTTPDATA_HPP_ #include #endif class HTTPConnection : private Connection { public: HTTPConnection(void); HTTPConnection(const Internet &internet,const String &strServer,int port=INTERNET_DEFAULT_HTTP_PORT); virtual ~HTTPConnection(); bool connect(const Internet &internet,const String &strServer,int port=INTERNET_DEFAULT_HTTP_PORT); bool get(HTTPHeader &httpHeader,HTTPData &httpData); bool get(const String &action,HTTPHeader &httpHeader,HTTPData &httpData); bool post(const String &action,HTTPHeader &httpHeader,HTTPData &httpData); void close(void); private: HTTPConnection(const HTTPConnection &httpConnection); HTTPConnection &operator=(const HTTPConnection &httpConnection); void closeRequest(void); void createHeaderLines(String &strLines,Block &headerLines); HINTERNET mhRequest; }; inline HTTPConnection::HTTPConnection() : mhRequest(0) { } inline HTTPConnection::HTTPConnection(const HTTPConnection &httpConnection) { // private } inline HTTPConnection &HTTPConnection::operator=(const HTTPConnection &httpConnection) { // private return *this; } inline HTTPConnection::HTTPConnection(const Internet &internet,const String &strServer,int port) { connect(internet,strServer,port); } inline HTTPConnection::~HTTPConnection() { close(); } inline bool HTTPConnection::connect(const Internet &internet,const String &strServer,int port) { if(!internet.isOkay())return false; return Connection::connect(internet,strServer,INTERNET_SERVICE_HTTP,port); } inline bool HTTPConnection::get(HTTPHeader &httpHeader,HTTPData &httpData) { return get(String(),httpHeader,httpData); } inline void HTTPConnection::close(void) { Connection::close(); closeRequest(); } inline void HTTPConnection::closeRequest(void) { if(!mhRequest)return; ::InternetCloseHandle(mhRequest); mhRequest=0; } #endif