Browse Source

Follow project coding style. Issue #2192.

adaptive-webui-19844
buinsky 10 years ago
parent
commit
dbc5ffee75
  1. 20
      src/webui/abstractrequesthandler.cpp

20
src/webui/abstractrequesthandler.cpp

@ -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,17 +127,14 @@ 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…
Cancel
Save