QDjango
QDjangoHttpResponse.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_RESPONSE_H
19 #define QDJANGO_HTTP_RESPONSE_H
20 
21 #include <QObject>
22 
23 #include "QDjangoHttp_p.h"
24 
25 class QDjangoHttpResponsePrivate;
26 
31 class QDJANGO_HTTP_EXPORT QDjangoHttpResponse : public QObject
32 {
33  Q_OBJECT
34 
35 public:
38  enum HttpStatus {
39  OK = 200,
40  MovedPermanently = 301,
41  Found = 302,
42  NotModified = 304,
43  BadRequest = 400,
44  AuthorizationRequired = 401,
45  Forbidden = 403,
46  NotFound = 404,
47  MethodNotAllowed = 405,
48  InternalServerError = 500,
49  };
50 
53 
54  QByteArray body() const;
55  void setBody(const QByteArray &body);
56 
57  QString header(const QString &key) const;
58  void setHeader(const QString &key, const QString &value);
59 
60  virtual bool isReady() const;
61 
62  QString reasonPhrase() const;
63  int statusCode() const;
64  void setStatusCode(int code);
65 
66 signals:
72  void ready();
73 
74 private:
75  Q_DISABLE_COPY(QDjangoHttpResponse)
76  QDjangoHttpResponsePrivate* const d;
77  friend class QDjangoFastCgiConnection;
78  friend class QDjangoHttpConnection;
79 };
80 
81 #endif
The QDjangoHttpResponse class represents an HTTP response.
Definition: QDjangoHttpResponse.h:31
HttpStatus
Enum representing well-known HTTP status codes.
Definition: QDjangoHttpResponse.h:38