ReactOS 0.4.16-dev-1946-g52006dd
CWebServiceWinInet Class Reference

#include <CWebServiceWinInet.h>

Inheritance diagram for CWebServiceWinInet:
Collaboration diagram for CWebServiceWinInet:

Public Member Functions

 CWebServiceWinInet ()
 
virtual ~CWebServiceWinInet ()
 
- Public Member Functions inherited from CWebService
 CWebService ()
 
virtual ~CWebService ()
 
void Finish (const char *TestType)
 
void Submit (const char *TestType, CTestInfo *TestInfo)
 

Private Member Functions

PCHAR DoRequest (const char *Hostname, INTERNET_PORT Port, const char *ServerFile, const string &InputData) override
 

Private Attributes

HINTERNET m_hInet
 
HINTERNET m_hHTTP
 
HINTERNET m_hHTTPRequest
 

Detailed Description

Definition at line 9 of file CWebServiceWinInet.h.

Constructor & Destructor Documentation

◆ CWebServiceWinInet()

CWebServiceWinInet::CWebServiceWinInet ( )

Constructs a CWebService object and immediately establishes a connection to the "testman" Web Service.

Definition at line 14 of file CWebServiceWinInet.cpp.

15{
16 /* Zero-initialize variables */
17 m_hHTTP = NULL;
19
20 /* Establish an internet connection to the "testman" server */
22
23 if(!m_hInet)
24 FATAL("InternetOpenW failed\n");
25}
#define NULL
Definition: types.h:112
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
Definition: internet.c:979
#define L(x)
Definition: resources.c:13
#define FATAL(Message)
Definition: precomp.h:59
#define INTERNET_OPEN_TYPE_PRECONFIG
Definition: wininet.h:521

◆ ~CWebServiceWinInet()

CWebServiceWinInet::~CWebServiceWinInet ( )
virtual

Destructs a CWebService object and closes all connections to the Web Service.

Definition at line 30 of file CWebServiceWinInet.cpp.

31{
32 if(m_hInet)
34
35 if(m_hHTTP)
37
40}
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
Definition: internet.c:1414

Member Function Documentation

◆ DoRequest()

PCHAR CWebServiceWinInet::DoRequest ( const char Hostname,
INTERNET_PORT  Port,
const char ServerFile,
const string InputData 
)
overrideprivatevirtual

Sends data to the Web Service.

Parameters
InputDataA std::string containing all the data, which is going to be submitted as HTTP POST data.
Returns
Returns a pointer to a char array containing the data received from the Web Service. The caller needs to free that pointer.

Implements CWebService.

Definition at line 53 of file CWebServiceWinInet.cpp.

54{
55 const WCHAR szHeaders[] = L"Content-Type: application/x-www-form-urlencoded";
56
59
60 if (!m_hHTTP)
61 {
63
64 if (!m_hHTTP)
65 FATAL("InternetConnectW failed\n");
66
67 }
68
69 /* Post our test results to the web service */
71
73 FATAL("HttpOpenRequestW failed\n");
74
75 Data.reset(new char[InputData.size() + 1]);
76 strcpy(Data, InputData.c_str());
77
78 if(!HttpSendRequestW(m_hHTTPRequest, szHeaders, lstrlenW(szHeaders), Data, (DWORD)InputData.size()))
79 FATAL("HttpSendRequestW failed\n");
80
81 /* Get the response */
83 FATAL("InternetQueryDataAvailable failed\n");
84
85 Data.reset(new char[DataLength + 1]);
86
88 FATAL("InternetReadFile failed\n");
89
90 Data[DataLength] = 0;
91
92 return Data.release();
93}
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
Definition: cdrom.h:1444
const _CharT * c_str() const
Definition: _string.h:949
size_type size() const
Definition: _string.h:400
#define lstrlenW
Definition: compat.h:750
HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession, LPCSTR lpszVerb, LPCSTR lpszObjectName, LPCSTR lpszVersion, LPCSTR lpszReferrer, LPCSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
Definition: http.c:1410
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
Definition: http.c:5595
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
Definition: internet.c:2154
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:3959
HINTERNET WINAPI InternetConnectA(HINTERNET hInternet, LPCSTR lpszServerName, INTERNET_PORT nServerPort, LPCSTR lpszUserName, LPCSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
Definition: internet.c:1321
unsigned long DWORD
Definition: ntddk_ex.h:95
CPPORT Port[4]
Definition: headless.c:35
strcpy
Definition: string.h:131
#define INTERNET_FLAG_RELOAD
Definition: wininet.h:61
#define INTERNET_FLAG_NO_COOKIES
Definition: wininet.h:75
#define INTERNET_FLAG_NO_CACHE_WRITE
Definition: wininet.h:66
#define INTERNET_FLAG_SECURE
Definition: wininet.h:71
#define INTERNET_SERVICE_HTTP
Definition: wininet.h:562
__wchar_t WCHAR
Definition: xmlstorage.h:180

Member Data Documentation

◆ m_hHTTP

HINTERNET CWebServiceWinInet::m_hHTTP
private

Definition at line 13 of file CWebServiceWinInet.h.

Referenced by CWebServiceWinInet(), DoRequest(), and ~CWebServiceWinInet().

◆ m_hHTTPRequest

HINTERNET CWebServiceWinInet::m_hHTTPRequest
private

Definition at line 14 of file CWebServiceWinInet.h.

Referenced by CWebServiceWinInet(), DoRequest(), and ~CWebServiceWinInet().

◆ m_hInet

HINTERNET CWebServiceWinInet::m_hInet
private

Definition at line 12 of file CWebServiceWinInet.h.

Referenced by CWebServiceWinInet(), DoRequest(), and ~CWebServiceWinInet().


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