Initial
This commit is contained in:
101
wininet/HTTPConnection.hpp
Normal file
101
wininet/HTTPConnection.hpp
Normal file
@@ -0,0 +1,101 @@
|
||||
#ifndef _WININET_HTTPCONNECTION_HPP_
|
||||
#define _WININET_HTTPCONNECTION_HPP_
|
||||
#ifndef _COMMON_STRING_HPP_
|
||||
#include <common/string.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_BLOCK_HPP_
|
||||
#include <common/block.hpp>
|
||||
#endif
|
||||
#ifndef _COMMON_ARRAY_HPP_
|
||||
#include <common/array.hpp>
|
||||
#endif
|
||||
#ifndef _WININET_INTERNET_HPP_
|
||||
#include <wininet/internet.hpp>
|
||||
#endif
|
||||
#ifndef _WININET_CONNECTION_HPP_
|
||||
#include <wininet/connection.hpp>
|
||||
#endif
|
||||
#ifndef _WININET_HTTPHEADER_HPP_
|
||||
#include <wininet/HTTPHeader.hpp>
|
||||
#endif
|
||||
#ifndef _WININET_HTTPDATA_HPP_
|
||||
#include <wininet/HTTPData.hpp>
|
||||
#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<String> &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
|
||||
Reference in New Issue
Block a user