|
|
|
@ -31,6 +31,7 @@
@@ -31,6 +31,7 @@
|
|
|
|
|
|
|
|
|
|
#include <QTcpSocket> |
|
|
|
|
#include <QDebug> |
|
|
|
|
#include <QRegExp> |
|
|
|
|
#include "types.h" |
|
|
|
|
#include "requestparser.h" |
|
|
|
|
#include "responsegenerator.h" |
|
|
|
@ -85,26 +86,13 @@ void Connection::sendResponse(const Response &response)
@@ -85,26 +86,13 @@ void Connection::sendResponse(const Response &response)
|
|
|
|
|
|
|
|
|
|
bool Connection::acceptsGzipEncoding(const QString &encoding) |
|
|
|
|
{ |
|
|
|
|
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
|
|
|
|
|
QRegExp rx("(gzip)(;q=([^,]+))?"); |
|
|
|
|
if (rx.indexIn(encoding) >= 0) { |
|
|
|
|
if (rx.cap(2).size() > 0) |
|
|
|
|
// check if quality factor > 0
|
|
|
|
|
return (rx.cap(3).toDouble() > 0); |
|
|
|
|
// if quality factor is not specified, then it's 1
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
|
|
//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; |
|
|
|
|
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|