SPDY: use QUrl's logic for determining the correct "Host" header

... and not duplicate part of the logic in the SPDY code. This code was
also existent in QNetworkRequest.
The next step will be to actually respect the header if set via
QNetworkRequest::setRawHeader().

Change-Id: Ifda2658ea826d039c9dad61ed6fa42aaedaee6b6
Reviewed-by: Richard J. Moore <rich@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Peter Hartmann 2014-04-25 15:59:11 +02:00 committed by The Qt Project
parent c281755480
commit 32893fa9c4

View File

@ -506,25 +506,7 @@ QByteArray QSpdyProtocolHandler::composeHeader(const QHttpNetworkRequest &reques
#endif
uncompressedHeader.append(headerField(":version", "HTTP/1.1"));
QHostAddress add; // ### unify with the host parsing from QHttpNetworkConnection
QByteArray host;
QString hostName = m_connection->hostName();
if (add.setAddress(hostName)) {
if (add.protocol() == QAbstractSocket::IPv6Protocol)
host = "[" + hostName.toLatin1() + "]"; //format the ipv6 in the standard way
else
host = hostName.toLatin1();
} else {
host = QUrl::toAce(hostName);
}
int port = request.url().port();
if (port != -1) {
host += ':';
host += QByteArray::number(port);
}
uncompressedHeader.append(headerField(":host", host));
uncompressedHeader.append(headerField(":host", request.url().authority(QUrl::FullyEncoded | QUrl::RemoveUserInfo).toLatin1()));
uncompressedHeader.append(headerField(":scheme", request.url().scheme().toLatin1()));