Merge pull request #97 from Xre0uS/fix-connection-handles

Properly close connection handles on WinINet errors
This commit is contained in:
Ralf
2025-07-07 09:39:31 +03:00
committed by GitHub
@@ -229,19 +229,17 @@ void ConnectorHTTP::SendData(BYTE* data, ULONG data_size)
attempt++;
if (!connected) {
if ( dwError == ERROR_INTERNET_CANNOT_CONNECT || dwError == ERROR_INTERNET_TIMEOUT ) {
if (this->hConnect) {
this->functions->InternetCloseHandle(this->hConnect);
this->hConnect = NULL;
}
if (this->hInternet) {
this->functions->InternetCloseHandle(this->hInternet);
this->hInternet = NULL;
}
this->functions->InternetSetOptionA(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
this->functions->InternetSetOptionA(NULL, INTERNET_OPTION_REFRESH, NULL, 0);
if (this->hConnect) {
this->functions->InternetCloseHandle(this->hConnect);
this->hConnect = NULL;
}
if (this->hInternet) {
this->functions->InternetCloseHandle(this->hInternet);
this->hInternet = NULL;
}
this->functions->InternetSetOptionA(NULL, INTERNET_OPTION_SETTINGS_CHANGED, NULL, 0);
this->functions->InternetSetOptionA(NULL, INTERNET_OPTION_REFRESH, NULL, 0);
this->server_index = (this->server_index + 1) % this->server_count;
}
@@ -283,4 +281,4 @@ void ConnectorHTTP::CloseConnector()
this->functions->InternetCloseHandle(this->hInternet);
this->functions->InternetCloseHandle(this->hConnect);
}
}