Implement Cancel for WinHTTP backend

This commit is contained in:
Tobias Taschner
2018-11-01 11:54:30 +01:00
parent 6bafed4ceb
commit 56af6cbdee
3 changed files with 25 additions and 12 deletions

View File

@@ -176,14 +176,12 @@ void wxWebRequestWinHTTP::HandleCallback(DWORD dwInternetStatus,
case WINHTTP_CALLBACK_STATUS_READ_COMPLETE:
if ( dwStatusInformationLength > 0 )
{
if ( !m_response->ReportAvailableData(dwStatusInformationLength) )
if ( !m_response->ReportAvailableData(dwStatusInformationLength) &&
GetState() != State_Cancelled )
SetFailedWithLastError();
}
else
{
m_response->ReportDataCompleted();
SetState(State_Completed);
}
break;
case WINHTTP_CALLBACK_STATUS_WRITE_COMPLETE:
WriteData();
@@ -340,7 +338,12 @@ void wxWebRequestWinHTTP::SendRequest()
void wxWebRequestWinHTTP::Cancel()
{
wxFAIL_MSG("not implemented");
SetState(State_Cancelled);
if ( m_request != NULL )
{
::WinHttpCloseHandle(m_request);
m_request = NULL;
}
}
wxWebResponse* wxWebRequestWinHTTP::GetResponse()