BPS C++ API  2.24.4
bpsmderequest.h
Go to the documentation of this file.
1 
4 #ifndef BPSMDEREQUEST_H
5 #define BPSMDEREQUEST_H
6 
7 #include "bps.h"
8 #include <QMap>
9 #include <QObject>
10 
11 class QTcpSocket;
12 class QTextStream;
13 
21 {
22  Q_OBJECT
24 
25 public:
26 
32  enum Method {
33  GET,
34  POST,
35  HEAD,
36  PUT,
40  CONNECT
41  };
42 
46  enum MimeType {
49  M_js,
54  M_jpg
55  };
56 
60  enum Status {
61  S_OK = 200,
62  S_SeeOther = 303,
63  S_Forbidden = 403,
64  S_NotFound = 404,
65  S_NotAllowed = 405,
66  S_ServerError = 500
67  };
68 
74  BpsMdeRequest(QTcpSocket* aSocket, QObject* aParent = nullptr);
75 
76  virtual ~BpsMdeRequest();
77 
81  QTcpSocket* socket() const;
82 
87 
91  QString endl() const;
92 
96  qlonglong sessionId() const;
97 
104  void setSessionId(qlonglong aSessionId);
105 
109  QString protocol() const;
110 
114  Method method() const;
115 
120 
124  Status status() const;
125 
130  void setStatus(Status aStatus);
131 
136 
141  void setMimeType(MimeType aMimeType);
142 
146  QString path() const;
147 
151  QString host() const;
152 
158  QVariantMap params() const;
159 
163  QByteArray data() const;
164 
169  void setData(const QByteArray& aData);
170 
174  QString location() const;
175 
180  void setLocation(const QString& aLocation);
181 
187  void setMaxAge(quint32 aSeconds);
188 
189 
193  bool mustClose() const;
194 
198  void setMustClose();
199 
207  void redirect(const QString& aPath = QString());
208 
212  void sendReply();
213 
219  static MimeType getMimeType(const QString& aPath);
220 
226  static QString httpDate(const QDateTime& aUtcDateTime);
227 };
228 
229 #endif // BPSMDEREQUEST_H
Public include file for Bps class.
#define BPSCORE_EXPORT
Declare class to be an import from the shared library.
Definition: bpscore_global.h:22
#define BPS_PRIVATE(Class)
Declare pointer to private object in a public class.
Definition: bpsglobals.h:102
BPS MDE request.
Definition: bpsmderequest.h:21
MimeType mimeType() const
BpsMdeRequest(QTcpSocket *aSocket, QObject *aParent=nullptr)
Constructor for the BpsMdeRequest objects.
Method method() const
Method
Request methods.
Definition: bpsmderequest.h:32
@ GET
Request a resource from server.
Definition: bpsmderequest.h:33
@ OPTIONS
Query options supported by server.
Definition: bpsmderequest.h:39
@ PUT
Upload a resource to server.
Definition: bpsmderequest.h:36
@ HEAD
Like GET, but no body data sent.
Definition: bpsmderequest.h:35
@ DELETE
Delete a resource from server.
Definition: bpsmderequest.h:37
@ POST
Send data to server.
Definition: bpsmderequest.h:34
@ TRACE
Loopback the request.
Definition: bpsmderequest.h:38
void sendReply()
Send the reply back to the client after setting the necessary status, text etc.
QString endl() const
QString path() const
void setSessionId(qlonglong aSessionId)
Set a new session ID.
QString host() const
Status status() const
void setMustClose()
Force connection close after reply.
void redirect(const QString &aPath=QString())
A convenience function to make redirections on the current server.
QByteArray data() const
Status
HTML status codes.
Definition: bpsmderequest.h:60
QTcpSocket * socket() const
QString methodAsText() const
QString protocol() const
void setData(const QByteArray &aData)
Put file contents to reply with in this.
bool mustClose() const
qlonglong sessionId() const
MimeType
MIME types used by BPS MDE server.
Definition: bpsmderequest.h:46
@ M_gif
Graphics interchange format.
Definition: bpsmderequest.h:53
@ M_htc
HTML component.
Definition: bpsmderequest.h:50
@ M_png
Portable network graphics.
Definition: bpsmderequest.h:52
@ M_html
Hypertext markup.
Definition: bpsmderequest.h:47
@ M_js
Javascript.
Definition: bpsmderequest.h:49
@ M_css
Cascaded style sheet.
Definition: bpsmderequest.h:48
@ M_ico
Microsoft format icon.
Definition: bpsmderequest.h:51
static MimeType getMimeType(const QString &aPath)
Get the MIME type from a file name.
QString location() const
void setLocation(const QString &aLocation)
Set a redirection URL.
void setMaxAge(quint32 aSeconds)
Set the content cache seconds.
QVariantMap params() const
For GET/POST parameter names ending with [], the values are stored as QStringList and the [] is remov...
QTextStream & html()
void setStatus(Status aStatus)
Set the status for the reply.
void setMimeType(MimeType aMimeType)
Set the MIME type for the reply.
static QString httpDate(const QDateTime &aUtcDateTime)
Format a UTC timestamp as HTTP date.