Class for requesting data from an internet server via HTTP. More...
#include <InternetRequest.h>
Classes | |
| struct | RequestData |
| Structure for holding request information; used mostly for requests on a worker thread. More... | |
Public Member Functions | |
| InternetRequest () | |
| Constructor. | |
| ~InternetRequest () | |
| Destructor. | |
| const std::string & | GetError () |
| Retrieves the last error string. | |
| bool | DoRequest (const std::string &sRequest, InternetRequestBuffer &buffer, LPCTSTR lpServer=NULL, LPCTSTR lpOptional=NULL, LPCTSTR lpHeaders=NULL, ProgressInterface *pProgress=&gpiDefault) |
| Runs an internet request and returns when it is finished. | |
| bool | DoRequestThread (const std::string &sRequest, InternetRequestBuffer &buffer, LPCTSTR lpServer=NULL, LPCTSTR lpOptional=NULL, LPCTSTR lpHeaders=NULL, ProgressInterface *pProgress=&gpiDefault) |
| Runs an internet request in a worker thread and returns immediatly. | |
Protected Member Functions | |
| void | OnInternetCallback (DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) |
| Called when the request changes status. | |
| bool | OpenSession () |
| Opens a wininet session. | |
| void | CloseAll () |
| Closes all wininet handles. | |
| bool | DoRequest (RequestData *pData) |
| Runs the request and calles the progress interface when it is finished. | |
| bool | InnerDoRequest (RequestData *pData) |
| Runs the request (does the actual work). | |
Static Protected Member Functions | |
| static void __stdcall | InternetCallback (HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) |
| Callback for wininet status changes. | |
| static DWORD WINAPI | RequestThreadProc (LPVOID lpData) |
| The request worker thread main function. | |
Protected Attributes | |
| HINTERNET | m_hSession |
| The wininet session object. | |
| HINTERNET | m_hConnection |
| The wininet connection object (reused for each different server). | |
| HINTERNET | m_hRequest |
| The wininet current request (reused for each request). | |
| bool | m_bInRequest |
| true if currently in a request, false if not | |
| bool | m_bInCreation |
| true while creating a connection, false if not | |
| std::string | m_sServer |
| Name of server used for the current connection. | |
| std::string | m_sError |
| Last error for the request. | |
Class for requesting data from an internet server via HTTP.
Definition at line 79 of file InternetRequest.h.
| bool InternetRequest::DoRequest | ( | RequestData * | pData | ) | [protected] |
Runs the request and calles the progress interface when it is finished.
| pData | Pointer to the request data structure |
Definition at line 294 of file InternetRequest.cpp.
References InnerDoRequest(), InternetRequest::RequestData::m_pProgress, and ProgressInterface::OnFinished().
| bool InternetRequest::DoRequest | ( | const std::string & | sRequest, | |
| InternetRequestBuffer & | buffer, | |||
| LPCTSTR | lpServer = NULL, |
|||
| LPCTSTR | lpOptional = NULL, |
|||
| LPCTSTR | lpHeaders = NULL, |
|||
| ProgressInterface * | pProgress = &gpiDefault | |||
| ) |
Runs an internet request and returns when it is finished.
| sRequest | The page requested from the server | |
| buffer | Buffer object to fill with the request response | |
| lpServer | Server name (can be NULL; if so, will use the current connection if any or fail if there is none) | |
| lpOptional | Additional data for POST (can be NULL) | |
| lpHeaders | Additional headers (can be NULL) | |
| pProgress | Pointer to the progress interface (can be NULL) |
Definition at line 239 of file InternetRequest.cpp.
Referenced by RequestThreadProc().
| bool InternetRequest::DoRequestThread | ( | const std::string & | sRequest, | |
| InternetRequestBuffer & | buffer, | |||
| LPCTSTR | lpServer = NULL, |
|||
| LPCTSTR | lpOptional = NULL, |
|||
| LPCTSTR | lpHeaders = NULL, |
|||
| ProgressInterface * | pProgress = &gpiDefault | |||
| ) |
Runs an internet request in a worker thread and returns immediatly.
| sRequest | The page requested from the server | |
| buffer | Buffer object to fill with the request response | |
| lpServer | Server name (can be NULL; if so, will use the current connection if any or fail if there is none) | |
| lpOptional | Additional data for POST (can be NULL) | |
| lpHeaders | Additional headers (can be NULL) | |
| pProgress | Pointer to the progress interface (can be NULL) |
Definition at line 256 of file InternetRequest.cpp.
References m_sError, and RequestThreadProc().
Referenced by RequestProgressDialog::DoRequest().
| const std::string& InternetRequest::GetError | ( | ) | [inline] |
Retrieves the last error string.
Definition at line 149 of file InternetRequest.h.
References m_sError.
| bool InternetRequest::InnerDoRequest | ( | RequestData * | pData | ) | [protected] |
Runs the request (does the actual work).
| pData | Pointer to the request data structure |
Definition at line 310 of file InternetRequest.cpp.
References InternetRequestBuffer::AddData(), ProgressInterface::GetCancel(), m_bInCreation, m_hConnection, m_hRequest, m_hSession, InternetRequest::RequestData::m_pBuffer, InternetRequest::RequestData::m_pProgress, m_sError, InternetRequest::RequestData::m_sHeaders, InternetRequest::RequestData::m_sOptional, InternetRequest::RequestData::m_sRequest, m_sServer, InternetRequest::RequestData::m_sServer, and OpenSession().
Referenced by DoRequest().
| void __stdcall InternetRequest::InternetCallback | ( | HINTERNET | hInternet, | |
| DWORD_PTR | dwContext, | |||
| DWORD | dwInternetStatus, | |||
| LPVOID | lpvStatusInformation, | |||
| DWORD | dwStatusInformationLength | |||
| ) | [static, protected] |
Callback for wininet status changes.
| hInternet | Handle to the wininet object that requested the callback | |
| dwContext | Client-defined data (the pointer to the InternetRequest object, in our case) | |
| dwInternetStatus | Callback stauts | |
| lpvStatusInformation | Pointer to additional callback information | |
| dwStatusInformationLength | Size of information object |
Definition at line 181 of file InternetRequest.cpp.
References OnInternetCallback().
Referenced by OpenSession().
| void InternetRequest::OnInternetCallback | ( | DWORD | dwInternetStatus, | |
| LPVOID | lpvStatusInformation, | |||
| DWORD | dwStatusInformationLength | |||
| ) | [protected] |
Called when the request changes status.
| dwInternetStatus | Callback status | |
| lpvStatusInformation | Pointer to additional callback information | |
| dwStatusInformationLength | Size of information object |
Definition at line 194 of file InternetRequest.cpp.
References m_bInCreation, m_bInRequest, and m_sError.
Referenced by InternetCallback().
| bool InternetRequest::OpenSession | ( | ) | [protected] |
Opens a wininet session.
Definition at line 141 of file InternetRequest.cpp.
References CloseAll(), InternetCallback(), m_hSession, and m_sError.
Referenced by InnerDoRequest().
| DWORD WINAPI InternetRequest::RequestThreadProc | ( | LPVOID | lpData | ) | [static, protected] |
The request worker thread main function.
| lpData | Pointer to the thread data structure (RequestData in this case) |
Definition at line 281 of file InternetRequest.cpp.
References DoRequest(), and InternetRequest::RequestData::m_pThis.
Referenced by DoRequestThread().
1.6.1