#pragma hdrstop
#endif
-#if wxUSE_SOCKETS
-
#include <string.h>
#include <ctype.h>
// Protocols list
wxProtoInfo *wxURL::g_protocols = NULL;
+
+#if wxUSE_SOCKETS
wxHTTP *wxURL::g_proxy = NULL;
+#endif
// --------------------------------------------------------------
// wxURL
m_protocol = NULL;
m_error = wxURL_NOERR;
m_url = url;
+#if wxUSE_SOCKETS
m_useProxy = (g_proxy != NULL);
m_proxy = g_proxy;
+#endif
ParseURL();
}
}
// URL parse finished.
+#if wxUSE_SOCKETS
if (m_useProxy) {
// We destroy the newly created protocol.
CleanData();
// We initialize specific variables.
m_protocol = m_proxy; // FIXME: we should clone the protocol
}
+#endif
m_error = wxURL_NOERR;
return TRUE;
void wxURL::CleanData()
{
+#if wxUSE_SOCKETS
if (!m_useProxy)
+#endif
delete m_protocol;
}
wxURL::~wxURL()
{
CleanData();
+#if wxUSE_SOCKETS
if (m_proxy && m_proxy != g_proxy)
delete m_proxy;
+#endif
}
// --------------------------------------------------------------
wxInputStream *wxURL::GetInputStream(void)
{
- wxIPV4address addr;
wxInputStream *the_i_stream = NULL;
if (!m_protocol) {
m_protocol->SetPassword(m_password);
}
+#if wxUSE_SOCKETS
+ wxIPV4address addr;
+
// m_protoinfo is NULL when we use a proxy
if (!m_useProxy && m_protoinfo->m_needhost) {
if (!addr.Hostname(m_hostname)) {
return NULL;
}
}
+#endif
// When we use a proxy, we have to pass the whole URL to it.
if (m_useProxy)
return the_i_stream;
}
+#if wxUSE_SOCKETS
void wxURL::SetDefaultProxy(const wxString& url_proxy)
{
if (url_proxy.IsNull()) {
m_useProxy = TRUE;
ParseURL();
}
+#endif
wxString wxURL::ConvertToValidURI(const wxString& uri)
{
if (c == _T(' '))
out_str += _T('+');
else {
- if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('/')) {
+ if (!isalpha(c) && c != _T('.') && c != _T('+') && c != _T('/')) {
hexa_code.Printf(_T("%%%02X"), c);
out_str += hexa_code;
} else
out_str += c;
}
}
-
+
return out_str;
}
-#endif
- // wxUSE_SOCKETS