| 1860 | } |
| 1861 | |
| 1862 | void WebRequestWinHTTP::HandleCallback(DWORD dwInternetStatus, LPVOID lpvStatusInformation, DWORD dwStatusInformationLength) |
| 1863 | { |
| 1864 | switch (dwInternetStatus) { |
| 1865 | case WINHTTP_CALLBACK_STATUS_SENDREQUEST_COMPLETE: { |
| 1866 | WriteData(); |
| 1867 | break; |
| 1868 | } |
| 1869 | case WINHTTP_CALLBACK_STATUS_READ_COMPLETE: { |
| 1870 | if (dwStatusInformationLength > 0) { |
| 1871 | _response->ReportDataReceived(dwStatusInformationLength); |
| 1872 | if (!_response->ReadData() && !WasCancelled()) { |
| 1873 | SetFailedWithLastError("Reading data"_s); |
| 1874 | } |
| 1875 | } else { |
| 1876 | SetFinalStateFromStatus(); |
| 1877 | } |
| 1878 | break; |
| 1879 | } |
| 1880 | case WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE: { |
| 1881 | DWORD bytesWritten = *(reinterpret_cast<LPDWORD>(lpvStatusInformation)); |
| 1882 | _dataWritten += bytesWritten; |
| 1883 | WriteData(); |
| 1884 | break; |
| 1885 | } |
| 1886 | case WINHTTP_CALLBACK_STATUS_REQUEST_ERROR: { |
| 1887 | LPWINHTTP_ASYNC_RESULT asyncResult = reinterpret_cast<LPWINHTTP_ASYNC_RESULT>(lpvStatusInformation); |
| 1888 | if (asyncResult->dwError == ERROR_WINHTTP_OPERATION_CANCELLED && WasCancelled()) { |
| 1889 | SetState(WebRequest::State::Cancelled); |
| 1890 | } else { |
| 1891 | SetFailed("Async request"_s, asyncResult->dwError); |
| 1892 | } |
| 1893 | break; |
| 1894 | } |
| 1895 | } |
| 1896 | } |
| 1897 | |
| 1898 | void WebRequestWinHTTP::WriteData() |
| 1899 | { |
no test coverage detected