Fix Host header always having port 65535 when URI does not contain explicit port

This commit is contained in:
Janek Bevendorff 2017-02-15 21:48:58 +01:00
parent 9d5d3081dc
commit a0ebbf997d
2 changed files with 5 additions and 7 deletions

View File

@ -93,9 +93,8 @@ public:
} }
void writeRaw(const QByteArray& data) { void writeRaw(const QByteArray& data) {
if ( itcpSocket ) { if ( itcpSocket )
itcpSocket->write(data); itcpSocket->write(data);
}
else if ( ilocalSocket ) else if ( ilocalSocket )
ilocalSocket->write(data); ilocalSocket->write(data);

View File

@ -82,12 +82,11 @@ void
QHttpRequestPrivate::prepareHeadersToWrite() { QHttpRequestPrivate::prepareHeadersToWrite() {
if ( !iheaders.contains("host") ) { if ( !iheaders.contains("host") ) {
quint16 port = iurl.port(); QString portStr = ( -1 != iurl.port() ) ?
if ( port == 0 ) QString(":%1").arg(iurl.port()) : "";
port = 80;
iheaders.insert("host", iheaders.insert("host",
QString("%1:%2").arg(iurl.host()).arg(port).toLatin1() QString("%1%2").arg(iurl.host()).arg(portStr).toLatin1()
); );
} }
} }