Stellarium 0.15.2
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 
35 class DECLSPEC HttpResponse {
36  Q_DISABLE_COPY(HttpResponse)
37 public:
38 
43  HttpResponse(QTcpSocket* socket);
44 
51  void setHeader(QByteArray name, QByteArray value);
52 
59  void setHeader(QByteArray name, int value);
60 
62  bool hasHeader(const QByteArray name) const;
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 
134  int statusCode;
135 
137  QByteArray statusText;
138 
140  bool sentHeaders;
141 
143  bool sentLastPart;
144 
146  bool chunkedMode;
147 
149  QMap<QByteArray,HttpCookie> cookies;
150 
152  bool writeToSocket(QByteArray data);
153 
159  void writeHeaders();
160 
161 };
162 
163 #endif // HTTPRESPONSE_H
HTTP cookie as defined in RFC 2109.
Definition: httpcookie.h:20
This object represents a HTTP response, used to return something to the web client.
Definition: httpresponse.h:35