diff --git a/include/wx/webrequest.h b/include/wx/webrequest.h index 68b785b9e9..2f9ffb51e1 100644 --- a/include/wx/webrequest.h +++ b/include/wx/webrequest.h @@ -193,7 +193,6 @@ private: wxWebRequestImplPtr m_impl; }; -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[]; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[]; @@ -213,7 +212,7 @@ public: // factory functions to get access to them. static wxWebSession& GetDefault(); - static wxWebSession New(const wxString& backend = wxWebSessionBackendDefault); + static wxWebSession New(const wxString& backend = wxString()); // Can be used to check if the given backend is available without actually // creating a session using it. diff --git a/src/common/webrequest.cpp b/src/common/webrequest.cpp index eb3ce57102..d5380b48be 100644 --- a/src/common/webrequest.cpp +++ b/src/common/webrequest.cpp @@ -43,14 +43,6 @@ extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendWinHTTP[] = "wxWebSes extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendURLSession[] = "wxWebSessionBackendURLSession"; extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendCURL[] = "wxWebSessionBackendCURL"; -#if wxUSE_WEBREQUEST_WINHTTP -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendWinHTTP"; -#elif wxUSE_WEBREQUEST_URLSESSION -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendURLSession"; -#elif wxUSE_WEBREQUEST_CURL -extern WXDLLIMPEXP_DATA_NET(const char) wxWebSessionBackendDefault[] = "wxWebSessionBackendCURL"; -#endif - wxDEFINE_EVENT(wxEVT_WEBREQUEST_STATE, wxWebRequestEvent); wxDEFINE_EVENT(wxEVT_WEBREQUEST_DATA, wxWebRequestEvent); @@ -824,11 +816,23 @@ wxWebSession& wxWebSession::GetDefault() } // static -wxWebSession wxWebSession::New(const wxString& backend) +wxWebSession wxWebSession::New(const wxString& backendOrig) { if ( gs_factoryMap.empty() ) InitFactoryMap(); + wxString backend = backendOrig; + if ( backend.empty() ) + { +#if wxUSE_WEBREQUEST_WINHTTP + backend = wxWebSessionBackendWinHTTP; +#elif wxUSE_WEBREQUEST_URLSESSION + backend = wxWebSessionBackendURLSession; +#elif wxUSE_WEBREQUEST_CURL + backend = wxWebSessionBackendCURL; +#endif + } + wxStringWebSessionFactoryMap::iterator factory = gs_factoryMap.find(backend); wxWebSessionImplPtr impl;