mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-12 15:57:57 +00:00
Follow project coding style. Issue #2192.
This commit is contained in:
parent
513f71e000
commit
dbc5ffee75
@ -47,13 +47,11 @@ HttpResponse AbstractRequestHandler::run()
|
|||||||
{
|
{
|
||||||
response_ = HttpResponse();
|
response_ = HttpResponse();
|
||||||
|
|
||||||
if (isBanned())
|
if (isBanned()) {
|
||||||
{
|
|
||||||
status(403, "Forbidden");
|
status(403, "Forbidden");
|
||||||
print(QObject::tr("Your IP address has been banned after too many failed authentication attempts."), CONTENT_TYPE_TXT);
|
print(QObject::tr("Your IP address has been banned after too many failed authentication attempts."), CONTENT_TYPE_TXT);
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
processRequest();
|
processRequest();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -105,8 +103,7 @@ void AbstractRequestHandler::printFile(const QString& path)
|
|||||||
QByteArray data;
|
QByteArray data;
|
||||||
QString type;
|
QString type;
|
||||||
|
|
||||||
if (!app_->readFile(path, data, type))
|
if (!app_->readFile(path, data, type)) {
|
||||||
{
|
|
||||||
status(404, "Not Found");
|
status(404, "Not Found");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -121,8 +118,7 @@ void AbstractRequestHandler::sessionInitialize()
|
|||||||
|
|
||||||
void AbstractRequestHandler::sessionStart()
|
void AbstractRequestHandler::sessionStart()
|
||||||
{
|
{
|
||||||
if (app_->sessionStart(this))
|
if (app_->sessionStart(this)) {
|
||||||
{
|
|
||||||
QNetworkCookie cookie(C_SID.toUtf8(), session_->id.toUtf8());
|
QNetworkCookie cookie(C_SID.toUtf8(), session_->id.toUtf8());
|
||||||
cookie.setPath("/");
|
cookie.setPath("/");
|
||||||
header(HEADER_SET_COOKIE, cookie.toRawForm());
|
header(HEADER_SET_COOKIE, cookie.toRawForm());
|
||||||
@ -131,18 +127,15 @@ void AbstractRequestHandler::sessionStart()
|
|||||||
|
|
||||||
void AbstractRequestHandler::sessionEnd()
|
void AbstractRequestHandler::sessionEnd()
|
||||||
{
|
{
|
||||||
if (sessionActive())
|
if (sessionActive()) {
|
||||||
{
|
|
||||||
QNetworkCookie cookie(C_SID.toUtf8(), session_->id.toUtf8());
|
QNetworkCookie cookie(C_SID.toUtf8(), session_->id.toUtf8());
|
||||||
cookie.setPath("/");
|
cookie.setPath("/");
|
||||||
cookie.setExpirationDate(QDateTime::currentDateTime());
|
cookie.setExpirationDate(QDateTime::currentDateTime());
|
||||||
|
|
||||||
if (app_->sessionEnd(this))
|
if (app_->sessionEnd(this))
|
||||||
{
|
|
||||||
header(HEADER_SET_COOKIE, cookie.toRawForm());
|
header(HEADER_SET_COOKIE, cookie.toRawForm());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
bool AbstractRequestHandler::isBanned() const
|
bool AbstractRequestHandler::isBanned() const
|
||||||
{
|
{
|
||||||
@ -168,8 +161,7 @@ QString AbstractRequestHandler::saveTmpFile(const QByteArray &data)
|
|||||||
{
|
{
|
||||||
QTemporaryFile tmpfile(QDir::temp().absoluteFilePath("qBT-XXXXXX.torrent"));
|
QTemporaryFile tmpfile(QDir::temp().absoluteFilePath("qBT-XXXXXX.torrent"));
|
||||||
tmpfile.setAutoRemove(false);
|
tmpfile.setAutoRemove(false);
|
||||||
if (tmpfile.open())
|
if (tmpfile.open()) {
|
||||||
{
|
|
||||||
tmpfile.write(data);
|
tmpfile.write(data);
|
||||||
tmpfile.close();
|
tmpfile.close();
|
||||||
return tmpfile.fileName();
|
return tmpfile.fileName();
|
||||||
|
Loading…
Reference in New Issue
Block a user