- if (url_proxy.IsNull()) {
- g_proxy->Close();
- delete g_proxy;
- g_proxy = NULL;
- return;
- }
-
- wxString tmp_str = url_proxy;
- int pos = tmp_str.Find(_T(':'));
- if (pos == -1)
- return;
-
- wxString hostname = tmp_str(0, pos),
- port = tmp_str(pos+1, tmp_str.Length()-pos);
- wxIPV4address addr;
-
- if (!addr.Hostname(hostname))
- return;
- if (!addr.Service(port))
- return;
-
- if (g_proxy)
- // Finally, when all is right, we connect the new proxy.
- g_proxy->Close();
- else
- g_proxy = new wxHTTP();
- g_proxy->Connect(addr, TRUE); // Watcom needs the 2nd arg for some reason
-}
-
-void wxURL::SetProxy(const wxString& url_proxy)
-{
- if (url_proxy.IsNull()) {
- if (m_proxy) {
- m_proxy->Close();
- delete m_proxy;
- }
- m_useProxy = FALSE;
- return;
- }
-
- wxString tmp_str;
- wxString hostname, port;
- int pos;
- wxIPV4address addr;
-
- tmp_str = url_proxy;
- pos = tmp_str.Find(_T(':'));
- // This is an invalid proxy name.
- if (pos == -1)
- return;
-
- hostname = tmp_str(0, pos);
- port = tmp_str(pos, tmp_str.Length()-pos);
-
- addr.Hostname(hostname);
- addr.Service(port);
-
- // Finally, create the whole stuff.
- if (m_proxy && m_proxy != g_proxy)
- delete m_proxy;
- m_proxy = new wxHTTP();
- m_proxy->Connect(addr, TRUE); // Watcom needs the 2nd arg for some reason
-
- CleanData();
- // Reparse url.
- m_useProxy = TRUE;
- ParseURL();