[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: KDE/kdelibs/kioslave/http
From: Andreas Hartmetz <ahartmetz () gmail ! com>
Date: 2009-03-22 21:49:23
Message-ID: 1237758563.574857.17367.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 942925 by ahartmetz:
This is an extended version of dfaure's patch to remove the irritating port
number e.g. in Konqi's URL lineedit. The default port is implied.
Kill some unnecessary state, namey m_defaultPort, which violated the single
point of truth principle, was redundant and, not to mention, redundant.
Also remove miscellaneous junk, most of it left from my earlier work here.
This time I have not tested all possible variants of connecting to the 'tubes,
so if this patch causes problems ping me on IRC.
M +15 -23 http.cpp
M +1 -18 http.h
--- trunk/KDE/kdelibs/kioslave/http/http.cpp #942924:942925
@@ -248,7 +248,6 @@
HTTPProtocol::HTTPProtocol( const QByteArray &protocol, const QByteArray &pool,
const QByteArray &app )
: TCPSlaveBase(protocol, pool, app, isEncryptedHttpVariety(protocol))
- , m_defaultPort(0)
, m_iSize(NO_SIZE)
, m_isBusy(false)
, m_isFirstRequest(false)
@@ -281,11 +280,6 @@
m_proxyAuth = 0;
m_wwwAuth = 0;
m_request.proxyUrl.clear(); //TODO revisit
-
- if (isEncryptedHttpVariety(m_protocol))
- m_defaultPort = DEFAULT_HTTPS_PORT;
- else
- m_defaultPort = DEFAULT_HTTP_PORT;
}
void HTTPProtocol::resetConnectionSettings()
@@ -294,6 +288,11 @@
m_isError = false;
}
+quint16 HTTPProtocol::defaultPort() const
+{
+ return isEncryptedHttpVariety(m_protocol) ? DEFAULT_HTTPS_PORT : \
DEFAULT_HTTP_PORT; +}
+
void HTTPProtocol::resetResponseParsing()
{
m_isRedirection = false;
@@ -488,7 +487,7 @@
// don't send the scope-id in IPv6 addresses to the server
m_request.encoded_hostname = '[' + host.left(pos) + ']';
}
- m_request.url.setPort((port <= 0) ? m_defaultPort : port);
+ m_request.url.setPort((port > 0 && port != defaultPort()) ? port : -1);
m_request.url.setUser(user);
m_request.url.setPass(pass);
@@ -503,7 +502,7 @@
kDebug (7113) << u.url();
m_request.url = u;
- m_request.url.setPort((u.port() <= 0) ? m_defaultPort : u.port());
+ m_request.url.setPort(u.port(defaultPort()) != defaultPort() ? u.port() : -1);
if (u.host().isEmpty()) {
error( KIO::ERR_UNKNOWN_HOST, i18n("No host specified."));
@@ -518,14 +517,7 @@
return false;
}
- if (m_protocol != u.protocol().toLatin1()) {
- short unsigned int oldDefaultPort = m_defaultPort;
- m_protocol = u.protocol().toLatin1();
- reparseConfiguration();
- if (m_defaultPort != oldDefaultPort && m_request.url.port() == oldDefaultPort) \
{
- m_request.url.setPort(m_defaultPort);
- }
- }
+ Q_ASSERT(m_protocol == u.protocol().toLatin1());
return true;
}
@@ -2002,7 +1994,7 @@
if (isHttpProxy(m_request.proxyUrl) && !isAutoSsl()) {
connectOk = connectToHost(m_request.proxyUrl.protocol(), \
m_request.proxyUrl.host(), m_request.proxyUrl.port()); } else {
- connectOk = connectToHost(m_protocol, m_request.url.host(), \
m_request.url.port()); + connectOk = connectToHost(m_protocol, \
m_request.url.host(), m_request.url.port(defaultPort())); }
if (!connectOk) {
@@ -2092,9 +2084,9 @@
u.setProtocol(protocol);
u.setHost(m_request.url.host());
- if (m_request.url.port() != m_defaultPort) {
- u.setPort(m_request.url.port());
- }
+ // if the URL contained the default port it should have been stripped \
earlier + Q_ASSERT(m_request.url.port() != defaultPort());
+ u.setPort(m_request.url.port());
u.setEncodedPathAndQuery(m_request.url.encodedPathAndQuery(
KUrl::LeaveTrailingSlash, \
KUrl::AvoidEmptyPath)); return u.url();
@@ -2230,15 +2222,15 @@
/* support for virtual hosts and required by HTTP 1.1 */
header += "Host: " + m_request.encoded_hostname;
- if (m_request.url.port() != m_defaultPort) {
+ if (m_request.url.port(defaultPort()) != defaultPort()) {
header += QString(":%1").arg(m_request.url.port());
}
header += "\r\n";
// Support old HTTP/1.0 style keep-alive header for compatibility
// purposes as well as performance improvements while giving end
- // users the ability to disable this feature proxy servers that
- // don't not support such feature, e.g. junkbuster proxy server.
+ // users the ability to disable this feature for proxy servers that
+ // don't support it, e.g. junkbuster proxy server.
if (isHttpProxy(m_request.proxyUrl) && !isAutoSsl()) {
header += "Proxy-Connection: ";
} else {
--- trunk/KDE/kdelibs/kioslave/http/http.h #942924:942925
@@ -286,7 +286,7 @@
*/
void addEncoding(const QString &, QStringList &);
- //void processAuthenticationRequest();
+ quint16 defaultPort() const;
// The methods between here and sendQuery() are helpers for sendQuery().
@@ -445,7 +445,6 @@
HTTPServerState m_server;
HTTPRequest m_request;
QList<HTTPRequest> m_requestQueue;
- quint16 m_defaultPort;
// Processing related
KIO::filesize_t m_iSize; // Expected size of message
@@ -498,24 +497,9 @@
long m_maxCacheSize; // Maximum cache size in Kb.
QString m_strCacheDir; // Location of the cache.
-
-//--- Proxy related members
-
// Operation mode
QByteArray m_protocol;
- //TODO use PrevRequest fully
- //TODO isAuthValid/m_isUnauthorized -> auth.scheme != AUTH_None ?
-#if 0
- struct AuthState
- {
- AUTH_SCHEME scheme;
- QString realm;
- QString authorization;
- int authCount;
- };
-#endif
-
KAbstractHttpAuthentication *m_wwwAuth;
KAbstractHttpAuthentication *m_proxyAuth;
// For proxy auth when it's handled by the Qt/KDE socket classes
@@ -527,7 +511,6 @@
// Values that determine the remote connection timeouts.
int m_remoteRespTimeout;
-
QByteArray m_unreadBuf;
void clearUnreadBuffer();
void unread(char *buf, size_t size);
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic