+wxString wxURL::ConvertFromURI(const wxString& uri)
+{
+ wxString new_uri;
+
+ size_t i = 0;
+ while (i<uri.Len()) {
+ int code;
+ if (uri[i] == wxT('%')) {
+ i++;
+ if (uri[i] >= wxT('A') && uri[i] <= wxT('F'))
+ code = (uri[i] - wxT('A') + 10) * 16;
+ else
+ code = (uri[i] - wxT('0')) * 16;
+ i++;
+ if (uri[i] >= wxT('A') && uri[i] <= wxT('F'))
+ code += (uri[i] - wxT('A')) + 10;
+ else
+ code += (uri[i] - wxT('0'));
+ i++;
+ new_uri += (wxChar)code;
+ continue;
+ }
+ new_uri += uri[i];
+ i++;
+ }
+ return new_uri;
+}
+
+// ----------------------------------------------------------------------
+// A module which deletes the default proxy if we created it
+// ----------------------------------------------------------------------
+
+#if wxUSE_SOCKETS
+
+class wxURLModule : public wxModule
+{
+public:
+ virtual bool OnInit();
+ virtual void OnExit();
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxURLModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxURLModule, wxModule)
+
+bool wxURLModule::OnInit()
+{
+ // env var HTTP_PROXY contains the address of the default proxy to use if
+ // set, but don't try to create this proxy right now because it will slow
+ // down the program startup (especially if there is no DNS server
+ // available, in which case it may take up to 1 minute)
+ if ( getenv("HTTP_PROXY") )
+ {
+ wxURL::ms_useDefaultProxy = TRUE;
+ }
+
+ return TRUE;
+}
+
+void wxURLModule::OnExit()
+{
+ delete wxURL::ms_proxyDefault;
+ wxURL::ms_proxyDefault = NULL;
+}
+
+#endif // wxUSE_SOCKETS