| |
1 |
1 |
|
| |
2 |
2 |
|
| |
3 |
3 |
|
| |
4 |
4 |
|
| |
5 |
5 |
|
| |
6 |
6 |
|
| |
7 |
7 |
|
| |
8 |
8 |
|
| |
9 |
9 |
|
| |
10 |
10 |
|
| |
11 |
11 |
|
| |
12 |
12 |
|
| |
13 |
13 |
|
| |
14 |
14 |
|
| |
15 |
15 |
|
| |
16 |
16 |
|
| |
17 |
17 |
|
| |
18 |
18 |
|
| |
19 |
19 |
#include "stdafx.h" |
| |
20 |
20 |
#include "AsyncHttpFile.h" |
| |
|
21 |
#include "../common/TLogger.h" |
| |
|
22 |
#include "ch.h" |
| |
21 |
23 |
|
| |
22 |
24 |
|
| |
23 |
25 |
#define FORCE_TIMEOUT 60000 |
| |
24 |
26 |
|
| |
25 |
27 |
using details::CONTEXT_REQUEST; |
| |
26 |
28 |
|
| |
27 |
29 |
|
| |
28 |
30 |
|
| |
29 |
31 |
|
| |
30 |
32 |
|
| |
31 |
33 |
|
| |
32 |
34 |
|
| |
33 |
35 |
CAsyncHttpFile::CAsyncHttpFile() : |
| |
34 |
36 |
m_hInternet(nullptr), |
| |
35 |
37 |
m_hOpenUrl(nullptr), |
| |
36 |
38 |
m_hFinishedEvent(nullptr), |
| |
37 |
39 |
m_dwError(ERROR_SUCCESS) |
| |
38 |
40 |
{ |
| |
39 |
41 |
memset(&m_internetBuffers, 0, sizeof(INTERNET_BUFFERSA)); |
| |
40 |
42 |
|
|
| |
338 |
340 |
|
| |
339 |
341 |
|
| |
340 |
342 |
|
| |
341 |
343 |
|
| |
342 |
344 |
|
| |
343 |
345 |
|
| |
344 |
346 |
|
| |
345 |
347 |
|
| |
346 |
348 |
|
| |
347 |
349 |
void CALLBACK CAsyncHttpFile::InternetStatusCallback(HINTERNET hInternet, DWORD_PTR dwContext, DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) |
| |
348 |
350 |
{ |
| |
349 |
351 |
CONTEXT_REQUEST* pRequest = (CONTEXT_REQUEST*)dwContext; |
| |
350 |
352 |
BOOST_ASSERT(pRequest && pRequest->pHttpFile); |
| |
351 |
353 |
if(!pRequest || !pRequest->pHttpFile) |
| |
352 |
354 |
return; |
| |
353 |
355 |
|
| |
354 |
356 |
CString strMsg; |
| |
355 |
357 |
strMsg.Format(_T("[CAsyncHttpFile::InternetStatusCallback] hInternet: %p, dwContext: %Iu (operation: %lu), dwInternetStatus: %lu, lpvStatusInformation: %p, dwStatusInformationLength: %lu\n"), |
| |
356 |
358 |
hInternet, (size_t)dwContext, pRequest->eOperationType, dwInternetStatus, lpvStatusInformation, dwStatusInformationLength); |
| |
357 |
359 |
ATLTRACE(L"%s\n", strMsg); |
| |
358 |
|
LOG_DEBUG(strMsg); |
| |
|
360 |
LOG_DEBUG(GetLogger()) << strMsg; |
| |
359 |
361 |
|
| |
360 |
362 |
switch(dwInternetStatus) |
| |
361 |
363 |
{ |
| |
362 |
364 |
case INTERNET_STATUS_HANDLE_CREATED: |
| |
363 |
365 |
{ |
| |
364 |
366 |
INTERNET_ASYNC_RESULT* pRes = (INTERNET_ASYNC_RESULT*)lpvStatusInformation; |
| |
365 |
367 |
if(pRes) |
| |
366 |
368 |
{ |
| |
367 |
369 |
ATLTRACE(L"INTERNET_STATUS_HANDLE_CREATED error code: %lu\n", pRes->dwError); |
| |
368 |
370 |
pRequest->pHttpFile->SetUrlHandle((HINTERNET)(pRes->dwResult)); |
| |
369 |
371 |
} |
| |
370 |
372 |
break; |
| |
371 |
373 |
} |
| |
372 |
374 |
case INTERNET_STATUS_RESPONSE_RECEIVED: |
| |
373 |
375 |
{ |
| |
374 |
376 |
ATLTRACE(_T("INTERNET_STATUS_RESPONSE_RECEIVED; received %lu bytes."), *(DWORD*)lpvStatusInformation); |
| |
375 |
377 |
break; |
| |
376 |
378 |
} |
| |
377 |
379 |
case INTERNET_STATUS_REQUEST_COMPLETE: |
| |
378 |
380 |
{ |