#include <string.h>
#include <ctype.h>
-IMPLEMENT_CLASS(wxProtoInfo, wxObject)
IMPLEMENT_CLASS(wxURL, wxURI)
// Protocols list
ParseURL();
}
-wxURL::wxURL(const wxURI& url) : wxURI(url)
+wxURL::wxURL(const wxURI& uri) : wxURI(uri)
{
- Init(url.BuildURI());
+ Init(uri.BuildURI());
+ ParseURL();
+}
+
+wxURL::wxURL(const wxURL& url) : wxURI(url)
+{
+ Init(url.GetURL());
ParseURL();
}
// Assignment
// --------------------------------------------------------------
-wxURL& wxURL::operator = (const wxURI& url)
+wxURL& wxURL::operator = (const wxString& url)
{
wxURI::operator = (url);
- Init(url.BuildURI());
+ Free();
+ Init(url);
ParseURL();
+
return *this;
}
-wxURL& wxURL::operator = (const wxString& url)
+
+wxURL& wxURL::operator = (const wxURI& uri)
{
- wxURI::operator = (url);
- Init(url);
- ParseURL();
+ if (&uri != this)
+ {
+ wxURI::operator = (uri);
+ Free();
+ Init(uri.BuildURI());
+ ParseURL();
+ }
+
+ return *this;
+}
+
+wxURL& wxURL::operator = (const wxURL& url)
+{
+ if (&url != this)
+ {
+ wxURI::operator = (url);
+ Free();
+ Init(url.GetURL());
+ ParseURL();
+ }
+
return *this;
}
m_url = m_url + wxT("//") + m_server;
// We initialize specific variables.
+ if (m_protocol)
+ m_protocol->Destroy();
m_protocol = m_proxy; // FIXME: we should clone the protocol
}
#endif // wxUSE_PROTOCOL_HTTP
#if wxUSE_PROTOCOL_HTTP
if (!m_useProxy)
#endif // wxUSE_PROTOCOL_HTTP
+ {
if (m_protocol)
+ {
// Need to safely delete the socket (pending events)
m_protocol->Destroy();
+ m_protocol = NULL;
+ }
+ }
}
-wxURL::~wxURL()
+void wxURL::Free()
{
CleanData();
#if wxUSE_PROTOCOL_HTTP
#endif
}
+wxURL::~wxURL()
+{
+ Free();
+}
+
// --------------------------------------------------------------
// FetchProtocol
// --------------------------------------------------------------
wxIPV4address addr;
// m_protoinfo is NULL when we use a proxy
- if (!m_useProxy && m_protoinfo->m_needhost)
+ if (
+#if wxUSE_PROTOCOL_HTTP
+ !m_useProxy &&
+#endif // wxUSE_PROTOCOL_HTTP
+ m_protoinfo->m_needhost )
{
if (!addr.Hostname(m_server))
{
return NULL;
}
}
-#endif
+#endif // wxUSE_SOCKETS
wxString fullPath;
+#if wxUSE_PROTOCOL_HTTP
// When we use a proxy, we have to pass the whole URL to it.
if (m_useProxy)
fullPath += m_url;
+#endif // wxUSE_PROTOCOL_HTTP
if(m_path.empty())
fullPath += wxT("/");
if ( ms_proxyDefault )
{
ms_proxyDefault->Close();
- delete ms_proxyDefault;
- ms_proxyDefault = NULL;
+ wxDELETE(ms_proxyDefault);
}
}
else
{
// we must be cleaned up before wxSocketModule as otherwise deleting
// ms_proxyDefault from our OnExit() won't work (and can actually crash)
- AddDependency(wxClassInfo::FindClass(_T("wxSocketModule")));
+ AddDependency(wxClassInfo::FindClass(wxT("wxSocketModule")));
}
bool wxURLModule::OnInit()
// down the program startup (especially if there is no DNS server
// available, in which case it may take up to 1 minute)
- if ( wxGetenv(_T("HTTP_PROXY")) )
+ if ( wxGetenv(wxT("HTTP_PROXY")) )
{
wxURL::ms_useDefaultProxy = true;
}
void wxURLModule::OnExit()
{
#if wxUSE_PROTOCOL_HTTP
- delete wxURL::ms_proxyDefault;
- wxURL::ms_proxyDefault = NULL;
+ wxDELETE(wxURL::ms_proxyDefault);
#endif // wxUSE_PROTOCOL_HTTP
}