1
0
mirror of https://github.com/d47081/qBittorrent.git synced 2025-02-05 11:24:15 +00:00

Correctly detect if the browser supports gzip compression.

This commit is contained in:
sledgehammer999 2013-11-16 21:48:20 +02:00
parent 35da156ad2
commit 144dd5c2a8

View File

@ -162,8 +162,26 @@ Submit Query
bool HttpRequestParser::acceptsEncoding() {
QString encoding = m_header.value("Accept-Encoding");
if (!encoding.isEmpty() && encoding.contains("gzip", Qt::CaseInsensitive))
int pos = encoding.indexOf("gzip", 0, Qt::CaseInsensitive);
if (pos == -1)
return false;
// Let's see if there's a qvalue of 0.0 following
if (encoding[pos+4] != ';') //there isn't, so it accepts gzip anyway
return true;
return false;
//So let's find = and the next comma
pos = encoding.indexOf("=", pos+4, Qt::CaseInsensitive);
int comma_pos = encoding.indexOf(",", pos, Qt::CaseInsensitive);
QString value;
if (comma_pos == -1)
value = encoding.mid(pos+1, comma_pos);
else
value = encoding.mid(pos+1, comma_pos-(pos+1));
if (value.toDouble() == 0.0)
return false;
else
return true;
}