summaryrefslogtreecommitdiffstats
path: root/src/network/socket/qhttpsocketengine.cpp
diff options
context:
space:
mode:
authorJonas M. Gastal <[email protected]>2011-11-23 15:11:03 -0200
committerQt by Nokia <[email protected]>2011-11-24 18:16:33 +0100
commit4cffc72023876645f3973823cdfd204094ebe097 (patch)
tree953f27fcab14691113fd385e4051954d2eea0724 /src/network/socket/qhttpsocketengine.cpp
parent8f1868e7c36cb890c9d71dcd9d07d7019058cf94 (diff)
Adds support for headers in QNetworkProxy.
The API is the same that is present on QNetworkRequest class. Since these are HTTP headers, this only affects proxies of type HttpProxy and HttpCachingProxy. This was created as a general solution to the problem pointed out in QTBUG-19569(some proxies only accept request with specific User Agents). In the same way that there are cases where setting the User Agent is desired there might be reasons to set other headers, hence the support for any header. Change-Id: Ifd04f34d29eedb6c2a3f0b50708244996b12a123 Task: QTBUG-19569 Reviewed-by: Shane Kearns <[email protected]>
Diffstat (limited to 'src/network/socket/qhttpsocketengine.cpp')
-rw-r--r--src/network/socket/qhttpsocketengine.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/network/socket/qhttpsocketengine.cpp b/src/network/socket/qhttpsocketengine.cpp
index b62bc05d223..428d21dc72c 100644
--- a/src/network/socket/qhttpsocketengine.cpp
+++ b/src/network/socket/qhttpsocketengine.cpp
@@ -502,15 +502,20 @@ void QHttpSocketEngine::slotSocketConnected()
QByteArray data = method;
data += path;
data += " HTTP/1.1\r\n";
- data += "Proxy-Connection: keep-alive\r\n"
- "User-Agent: ";
- QVariant v = property("_q_user-agent");
- if (v.isValid())
- data += v.toByteArray();
- else
- data += "Mozilla/5.0";
- data += "\r\n"
- "Host: " + peerAddress + "\r\n";
+ data += "Proxy-Connection: keep-alive\r\n";
+ data += "Host: " + peerAddress + "\r\n";
+ if (!d->proxy.hasRawHeader("User-Agent")) {
+ data += "User-Agent: ";
+ QVariant v = property("_q_user-agent");
+ if (v.isValid())
+ data += v.toByteArray();
+ else
+ data += "Mozilla/5.0";
+ data += "\r\n";
+ }
+ foreach (const QByteArray &header, d->proxy.rawHeaderList()) {
+ data += header + ": " + d->proxy.rawHeader(header) + "\r\n";
+ }
QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(d->authenticator);
//qDebug() << "slotSocketConnected: priv=" << priv << (priv ? (int)priv->method : -1);
if (priv && priv->method != QAuthenticatorPrivate::None) {