SDRAngel  4.11.5
Developer docs for <a href="https://github.com/f4exb/sdrangel">SDRangel<\a>, an Open Source Qt5 / OpenGL 3.0+ SDR and signal analyzer frontend to various hardware.
httpresponse.h
Go to the documentation of this file.
1 
6 #ifndef HTTPRESPONSE_H
7 #define HTTPRESPONSE_H
8 
9 #include <QMap>
10 #include <QString>
11 #include <QTcpSocket>
12 #include "httpglobal.h"
13 #include "httpcookie.h"
14 
15 #include "export.h"
16 
17 namespace qtwebapp {
18 
39  Q_DISABLE_COPY(HttpResponse)
40 public:
41 
46  HttpResponse(QTcpSocket* socket);
47 
54  void setHeader(QByteArray name, QByteArray value);
55 
62  void setHeader(QByteArray name, int value);
63 
65  QMap<QByteArray,QByteArray>& getHeaders();
66 
68  QMap<QByteArray,HttpCookie>& getCookies();
69 
74  void setStatus(int statusCode, QByteArray description=QByteArray());
75 
77  int getStatusCode() const;
78 
92  void write(QByteArray data, bool lastPart=false);
93 
97  bool hasSentLastPart() const;
98 
103  void setCookie(const HttpCookie& cookie);
104 
110  void redirect(const QByteArray& url);
111 
117  void flush();
118 
123  bool isConnected() const;
124 
125 private:
126 
128  QMap<QByteArray,QByteArray> headers;
129 
131  QTcpSocket* socket;
132 
135 
137  QByteArray statusText;
138 
141 
144 
147 
149  QMap<QByteArray,HttpCookie> cookies;
150 
152  bool writeToSocket(QByteArray data);
153 
159  void writeHeaders();
160 
161 };
162 
163 } // end of namespace
164 
165 #endif // HTTPRESPONSE_H
QMap< QByteArray, QByteArray > headers
Definition: httpresponse.h:128
#define HTTPSERVER_API
Definition: export.h:88
QMap< QByteArray, HttpCookie > cookies
Definition: httpresponse.h:149