Ensure wxWebRequest is in idle state before starting it
Check that current state is State_Idle in wxWebRequest itself only once instead of doing it in 2 (out of 3) wxWebRequestImpl implementations. Also assert if this is not the case instead of silently doing nothing which would surely be more difficult to debug.
This commit is contained in:
@@ -64,6 +64,7 @@ public:
|
|||||||
|
|
||||||
wxWebRequest::Storage GetStorage() const { return m_storage; }
|
wxWebRequest::Storage GetStorage() const { return m_storage; }
|
||||||
|
|
||||||
|
// Precondition for this method checked by caller: current state is idle.
|
||||||
virtual void Start() = 0;
|
virtual void Start() = 0;
|
||||||
|
|
||||||
virtual void Cancel() = 0;
|
virtual void Cancel() = 0;
|
||||||
|
@@ -187,6 +187,9 @@ public:
|
|||||||
|
|
||||||
Events will be triggered on success or failure.
|
Events will be triggered on success or failure.
|
||||||
|
|
||||||
|
The current state must be @c State_Idle, already started requests can't
|
||||||
|
be started again.
|
||||||
|
|
||||||
@see Cancel()
|
@see Cancel()
|
||||||
*/
|
*/
|
||||||
void Start();
|
void Start();
|
||||||
|
@@ -391,6 +391,9 @@ void wxWebRequest::Start()
|
|||||||
{
|
{
|
||||||
wxCHECK_IMPL_VOID();
|
wxCHECK_IMPL_VOID();
|
||||||
|
|
||||||
|
wxCHECK_RET( m_impl->GetState() == wxWebRequest::State_Idle,
|
||||||
|
"Completed requests can not be restarted" );
|
||||||
|
|
||||||
m_impl->Start();
|
m_impl->Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -187,9 +187,6 @@ wxWebRequestCURL::~wxWebRequestCURL()
|
|||||||
|
|
||||||
void wxWebRequestCURL::Start()
|
void wxWebRequestCURL::Start()
|
||||||
{
|
{
|
||||||
if ( GetState() != wxWebRequest::State_Idle )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_response.reset(new wxWebResponseCURL(*this));
|
m_response.reset(new wxWebResponseCURL(*this));
|
||||||
|
|
||||||
if ( m_dataSize )
|
if ( m_dataSize )
|
||||||
|
@@ -237,9 +237,6 @@ void wxWebRequestWinHTTP::SetFailed(DWORD errorCode)
|
|||||||
|
|
||||||
void wxWebRequestWinHTTP::Start()
|
void wxWebRequestWinHTTP::Start()
|
||||||
{
|
{
|
||||||
if ( GetState() != wxWebRequest::State_Idle ) // Completed requests can not be restarted
|
|
||||||
return;
|
|
||||||
|
|
||||||
// Parse the URL
|
// Parse the URL
|
||||||
wxURI uri(m_url);
|
wxURI uri(m_url);
|
||||||
bool isSecure = uri.GetScheme().IsSameAs("HTTPS", false);
|
bool isSecure = uri.GetScheme().IsSameAs("HTTPS", false);
|
||||||
|
Reference in New Issue
Block a user