kdelibs/kdelibs-4.0.4-proxy.patch
Kevin Kofler 2e78f0be82 * Thu May 15 2008 Kevin Kofler <Kevin@tigcc.ticalc.org> - 4.0.4-3
- fix proxy support (#443931, kde#155707)
- move %%{_kde4_appsdir}/ksgmltools2/ from -devel to the main package (#446435)
2008-05-15 02:29:46 +00:00

127 lines
3.8 KiB
Diff

--- kioslave/http/http.cpp.orig 2008-04-30 21:00:26.000000000 +0700
+++ kioslave/http/http.cpp 2008-05-14 16:46:43.000000000 +0700
@@ -43,6 +43,7 @@
#include <QtCore/QDate>
#include <QtDBus/QtDBus>
#include <QtNetwork/QTcpSocket>
+#include <QtNetwork/QNetworkProxy>
#include <QtNetwork/QHostInfo>
#include <kurl.h>
@@ -259,9 +260,11 @@
// Do not reset the URL on redirection if the proxy
// URL, username or password has not changed!
KUrl proxy ( config()->readEntry("UseProxy") );
+ QNetworkProxy::ProxyType proxyType = QNetworkProxy::NoProxy;
if ( m_strProxyRealm.isEmpty() || !proxy.isValid() ||
m_proxyURL.host() != proxy.host() ||
+ m_proxyURL.port() != proxy.port() ||
(!proxy.user().isNull() && proxy.user() != m_proxyURL.user()) ||
(!proxy.pass().isNull() && proxy.pass() != m_proxyURL.pass()) )
{
@@ -272,8 +275,22 @@
kDebug(7113) << "Using proxy:" << m_bUseProxy
<< "URL: " << m_proxyURL.url()
<< "Realm: " << m_strProxyRealm;
+
+ if ( m_bUseProxy )
+ {
+ if ( m_proxyURL.protocol() == "socks" )
+ proxyType = QNetworkProxy::Socks5Proxy;
+ else if ( isAutoSsl() )
+ proxyType = QNetworkProxy::HttpProxy;
+
+ m_request.proxyURL = proxy;
}
+ else
+ m_request.proxyURL = KUrl();
+ QNetworkProxy::setApplicationProxy(QNetworkProxy(proxyType,m_proxyURL.host(),m_proxyURL.port(),m_proxyURL.user(),m_proxyURL.pass()));
+
+ }
m_bPersistentProxyConnection = config()->readEntry("PersistentProxyConnection", false);
kDebug(7113) << "Enable Persistent Proxy Connection: "
<< m_bPersistentProxyConnection;
@@ -1903,7 +1920,7 @@
kDebug(7113) << "Connection lost!";
closeDown = true;
}
- else if ( m_request.method != HTTP_GET )
+ else if ( m_request.method != HTTP_GET && m_request.method != HTTP_POST )
{
closeDown = true;
}
@@ -1915,6 +1932,14 @@
m_state.passwd != m_request.passwd)
closeDown = true;
}
+ else if ( m_state.doProxy || m_request.doProxy )
+ {
+ if (m_state.proxyURL.host() != m_request.proxyURL.host() ||
+ m_state.proxyURL.port() != m_request.proxyURL.port() ||
+ m_state.proxyURL.user() != m_request.proxyURL.user() ||
+ m_state.proxyURL.pass() != m_request.proxyURL.pass())
+ closeDown = true;
+ }
else
{
// Keep the connection to the proxy.
@@ -1933,19 +1958,26 @@
m_state.user = m_request.user;
m_state.passwd = m_request.passwd;
m_state.doProxy = m_request.doProxy;
+ m_state.proxyURL = m_request.proxyURL;
}
bool HTTPProtocol::httpOpenConnection()
{
int errCode;
QString errMsg;
+ bool connResult;
kDebug(7113);
setBlocking( true );
- if ( !connectToHost(m_protocol, m_state.hostname, m_state.port ) )
- return false;
+ if ( m_state.doProxy && !isAutoSsl() && m_proxyURL.protocol() != "socks")
+ connResult = connectToHost(m_proxyURL.protocol(), m_proxyURL.host(), m_proxyURL.port() );
+ else
+ connResult = connectToHost(m_protocol, m_state.hostname, m_state.port );
+
+ if ( connResult )
+ {
#if 0 // QTcpSocket doesn't support this
// Set our special socket option!!
@@ -1955,7 +1987,8 @@
m_bFirstRequest = true;
connected();
- return true;
+ }
+ return connResult;
}
--- kioslave/http/http.h.orig 2008-01-29 15:20:03.000000000 +0600
+++ kioslave/http/http.h 2008-05-07 17:26:45.000000000 +0700
@@ -83,6 +83,7 @@
QString user;
QString passwd;
bool doProxy;
+ KUrl proxyURL;
};
/** DAV-specific request elements for the current connection **/
@@ -145,6 +146,7 @@
QString id;
DAVRequest davData;
bool doProxy;
+ KUrl proxyURL;
bool allowCompressedPage;
bool disablePassDlg;
bool bNoAuth; // Do not authenticate