#include <CWebService.h>
Definition at line 8 of file CWebService.h.
◆ CWebService()
CWebService::CWebService |
( |
| ) |
|
Constructs a CWebService object and immediately establishes a connection to the "testman" Web Service.
Definition at line 17 of file CWebService.cpp.
18{
19
23
24
26
28 FATAL(
"InternetOpenW failed\n");
29
31
33 FATAL(
"InternetConnectW failed\n");
34}
static const WCHAR szHostname[]
static const INTERNET_PORT ServerPort
HINTERNET WINAPI InternetConnectW(HINTERNET hInternet, LPCWSTR lpszServerName, INTERNET_PORT nServerPort, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwService, DWORD dwFlags, DWORD_PTR dwContext)
HINTERNET WINAPI InternetOpenW(LPCWSTR lpszAgent, DWORD dwAccessType, LPCWSTR lpszProxy, LPCWSTR lpszProxyBypass, DWORD dwFlags)
#define INTERNET_OPEN_TYPE_PRECONFIG
#define INTERNET_SERVICE_HTTP
◆ ~CWebService()
CWebService::~CWebService |
( |
| ) |
|
Destructs a CWebService object and closes all connections to the Web Service.
Definition at line 39 of file CWebService.cpp.
40{
43
46
49
52}
BOOL WINAPI InternetCloseHandle(HINTERNET hInternet)
◆ DoRequest()
Sends data to the Web Service.
- Parameters
-
InputData | A 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.
Definition at line 65 of file CWebService.cpp.
66{
67 const WCHAR szHeaders[] =
L"Content-Type: application/x-www-form-urlencoded";
68
71
72
74
76 FATAL(
"HttpOpenRequestW failed\n");
77
78 Data.reset(
new char[InputData.
size() + 1]);
80
82 FATAL(
"HttpSendRequestW failed\n");
83
84
86 FATAL(
"InternetQueryDataAvailable failed\n");
87
89
91 FATAL(
"InternetReadFile failed\n");
92
94
95 return Data.release();
96}
static const WCHAR szServerFile[]
_In_ ULONG _In_opt_ WDFREQUEST _In_opt_ PVOID _In_ size_t _In_ PVOID _In_ size_t _Out_ size_t * DataLength
const _CharT * c_str() const
BOOL WINAPI HttpSendRequestW(HINTERNET hHttpRequest, LPCWSTR lpszHeaders, DWORD dwHeaderLength, LPVOID lpOptional, DWORD dwOptionalLength)
HINTERNET WINAPI HttpOpenRequestW(HINTERNET hHttpSession, LPCWSTR lpszVerb, LPCWSTR lpszObjectName, LPCWSTR lpszVersion, LPCWSTR lpszReferrer, LPCWSTR *lpszAcceptTypes, DWORD dwFlags, DWORD_PTR dwContext)
BOOL WINAPI InternetReadFile(HINTERNET hFile, LPVOID lpBuffer, DWORD dwNumOfBytesToRead, LPDWORD pdwNumOfBytesRead)
BOOL WINAPI InternetQueryDataAvailable(HINTERNET hFile, LPDWORD lpdwNumberOfBytesAvailable, DWORD dwFlags, DWORD_PTR dwContext)
#define INTERNET_FLAG_RELOAD
#define INTERNET_FLAG_NO_COOKIES
#define INTERNET_FLAG_NO_CACHE_WRITE
#define INTERNET_FLAG_SECURE
Referenced by Finish(), GetSuiteID(), GetTestID(), and Submit().
◆ Finish()
Interface to other classes for finishing this test run
- Parameters
-
TestType | Constant pointer to a char array containing the test type to be run (i.e. "wine") |
Definition at line 105 of file CWebService.cpp.
106{
110
112 EXCEPTION(
"CWebService::Finish was called, but not a single result had been submitted!\n");
113
114 Data =
"action=finish";
116 Data +=
"&testtype=";
120
122
124 {
125 ss <<
"When finishing the test run, the server responded:" <<
endl <<
Response <<
endl;
127 }
128}
basic_ostream< _CharT, _Traits > &_STLP_CALL endl(basic_ostream< _CharT, _Traits > &__os)
int strcmp(const char *String1, const char *String2)
PCHAR DoRequest(const string &InputData)
#define EXCEPTION(Message)
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_INTERRUPT_CONFIG Configuration
◆ GetSuiteID()
Gets a Suite ID from the Web Service for this module/test combination.
- Parameters
-
TestType | Constant pointer to a char array containing the test type to be run (i.e. "wine") |
TestInfo | Pointer to a CTestInfo object containing information about the test |
- Returns
- Returns a pointer to a char array containing the Suite ID received from the Web Service. The caller needs to free that pointer.
Definition at line 179 of file CWebService.cpp.
180{
183
184 Data =
"action=getsuiteid";
186 Data +=
"&testtype=";
192
194
195
197 {
199
200 ss <<
"Expected Suite ID, but received:" <<
endl << SuiteID <<
endl;
202 }
203
205}
bool IsNumber(const char *Input)
Referenced by Submit().
◆ GetTestID()
Requests a Test ID from the Web Service for our test run.
- Parameters
-
TestType | Constant pointer to a char array containing the test type to be run (i.e. "wine") |
Definition at line 137 of file CWebService.cpp.
138{
140
141 Data =
"action=gettestid";
144 Data +=
"&testtype=";
146
148 {
151 }
152
154
155
157 {
159
162 }
163}
Referenced by Submit().
◆ Submit()
Interface to other classes for submitting a result of one test
- Parameters
-
TestType | Constant pointer to a char array containing the test type to be run (i.e. "wine") |
TestInfo | Pointer to a CTestInfo object containing information about the test |
Definition at line 217 of file CWebService.cpp.
218{
223
226
228
229 Data =
"action=submit";
231 Data +=
"&testtype=";
239
241
243 {
244 ss <<
"When submitting the result, the server responded:" <<
endl <<
Response <<
endl;
246 }
247}
void GetTestID(const char *TestType)
PCHAR GetSuiteID(const char *TestType, CTestInfo *TestInfo)
string EscapeString(const char *Input)
◆ m_hHTTP
◆ m_hHTTPRequest
◆ m_hInet
◆ m_TestID
PCHAR CWebService::m_TestID |
|
private |
The documentation for this class was generated from the following files: