-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();
-}
-#endif
-
-wxString wxURL::ConvertToValidURI(const wxString& uri)
-{
- wxString out_str;
- wxString hexa_code;
- size_t i;
-
- for (i=0;i<uri.Len();i++) {
- wxChar c = uri.GetChar(i);
-
- if (c == _T(' '))
- out_str += _T('+');
- else {
- if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('/')) {
- hexa_code.Printf(_T("%%%02X"), c);
- out_str += hexa_code;
- } else
- out_str += c;
- }
- }