QDjango: QDjangoHttpController.h Source File

QDjango

QDjangoHttpController.h
1 /*
2 * Copyright (C) 2010-2015 Jeremy Lainé
3 * Contact: https://github.com/jlaine/qdjango
4 *
5 * This file is part of the QDjango Library.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 */
17
18 #ifndef QDJANGO_HTTP_CONTROLLER_H
19 #define QDJANGO_HTTP_CONTROLLER_H
20
21 #include <QDateTime>
22 #include <QString>
23
24 #include "QDjangoHttp_p.h"
25
26 class QDjangoHttpRequest;
27 class QDjangoHttpResponse;
28 class QUrl;
29
34 class QDJANGO_HTTP_EXPORT QDjangoHttpController
35 {
36 public:
37 // get basic authorization credentials
38 static bool getBasicAuth(const QDjangoHttpRequest &request, QString &username, QString &password);
39
40 // date / time handling
41 static QString httpDateTime(const QDateTime &dt);
42 static QDateTime httpDateTime(const QString &str);
43
44 // common responses
45 static QDjangoHttpResponse *serveAuthorizationRequired(const QDjangoHttpRequest &request, const QString &realm = QLatin1String("Secure Area"));
46 static QDjangoHttpResponse *serveBadRequest(const QDjangoHttpRequest &request);
47 static QDjangoHttpResponse *serveInternalServerError(const QDjangoHttpRequest &request);
48 static QDjangoHttpResponse *serveNotFound(const QDjangoHttpRequest &request);
49 static QDjangoHttpResponse *serveRedirect(const QDjangoHttpRequest &request, const QUrl &url, bool permanent = false);
50 static QDjangoHttpResponse *serveStatic(const QDjangoHttpRequest &request, const QString &filePath, const QDateTime &expires = QDateTime());
51
52 private:
53 static QDjangoHttpResponse *serveError(const QDjangoHttpRequest &request, int code, const QString &text);
54 };
55
56 #endif
QDjangoHttpController
The QDjangoHttpController class provides static methods for replying to HTTP requests.
Definition: QDjangoHttpController.h:35
QDjangoHttpRequest
The QDjangoHttpRequest class represents an HTTP request.
Definition: QDjangoHttpRequest.h:32
QDjangoHttpResponse
The QDjangoHttpResponse class represents an HTTP response.
Definition: QDjangoHttpResponse.h:32