+/* $BEGIN_LICENSE
+
+This file is part of Minitube.
+Copyright 2009, Flavio Tordini <flavio.tordini@gmail.com>
+
+Minitube is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 3 of the License, or
+(at your option) any later version.
+
+Minitube is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Minitube. If not, see <http://www.gnu.org/licenses/>.
+
+$END_LICENSE */
+
#include "networkaccess.h"
#include "constants.h"
#include <QtGui>
+#if QT_VERSION >= 0x050000
+#include <QtWidgets>
+#endif
namespace The {
NetworkAccess* http();
+ " (" + Constants::WEBSITE + ")";
*/
-const QString USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11";
+const QString USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36";
NetworkReply::NetworkReply(QNetworkReply *networkReply) :
QObject(networkReply),
setupReply();
readTimeoutTimer = new QTimer(this);
- readTimeoutTimer->setInterval(10000);
+ readTimeoutTimer->setInterval(25000);
readTimeoutTimer->setSingleShot(true);
connect(readTimeoutTimer, SIGNAL(timeout()), SLOT(readTimeout()), Qt::UniqueConnection);
readTimeoutTimer->start();
}
void NetworkReply::requestError(QNetworkReply::NetworkError code) {
- qDebug() << networkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()
+ qWarning() << networkReply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt()
<< networkReply->errorString() << code;
emit error(networkReply);
}
return request;
}
-QNetworkReply* NetworkAccess::request(QUrl url, int operation, const QByteArray& body) {
+QNetworkReply* NetworkAccess::request(QUrl url, int operation, const QByteArray& body, uint offset) {
QNetworkAccessManager *manager = The::networkAccessManager();
QNetworkRequest request = buildRequest(url);
+ if (offset > 0)
+ request.setRawHeader("Range", QString("bytes=%1-").arg(offset).toUtf8());
+
QNetworkReply *networkReply;
switch (operation) {