CCgiManager.h
Go to the documentation of this file.
1 #ifndef iweb_CCgiManager_included
2 #define iweb_CCgiManager_included
3 
4 
5 // Qt includes
6 #include <QtCore/QString>
7 #include <QtCore/QStringList>
8 #include <QtCore/QByteArray>
9 #include <QtCore/QVariant>
10 #include <QtCore/QVariantMap>
11 #include <QtCore/QMap>
12 
13 
14 namespace iweb
15 {
16 
17 
19 {
20 public:
21  typedef QMap<QString, QString> KeyValueMap;
22 
26  static QString ContentImageGIF;
27 
31  static QString ContentImageJPEG;
32 
36  static QString ContentImageJPG;
37 
41  static QString ContentImagePNG;
42 
46  static QString ContentImageSVG;
47 
51  static QString ContentImageTIFF;
52 
56  static QString ContentFont;
57 
61  static QString ContentFontEOT;
62 
66  static QString ContentFontOTF;
67 
71  static QString ContentFontTTF;
72 
76  static QString ContentFontWOFF;
77 
81  static QString ContentScriptECMAS;
82 
86  static QString ContentScriptVB;
87 
91  static QString ContentTypeCSS;
92 
96  static QString ContentTypeHTML;
97 
101  static QString ContentTypeJS;
102 
106  static QString ContentTypeJSON;
107 
111  static QString ContentTypeText;
112 
116  static QString ContentTypeXML;
117 
121  static QString HeaderComSpec;
122 
126  static QString HeaderDocumentRoot;
127 
131  static QString HeaderGatewayInterface;
132 
136  static QString HeaderHttpAccept;
137 
141  static QString HeaderHttpAcceptEncoding;
142 
146  static QString HeaderHttpAcceptLanguage;
147 
151  static QString HeaderHttpConnection;
152 
156  static QString HeaderHttpCookie;
157 
161  static QString HeaderHttpHost;
162 
166  static QString HeaderHttpUserAgent;
167 
171  static QString HeaderPath;
172 
176  static QString HeaderQueryString;
177 
181  static QString HeaderRemoteAddress;
182 
186  static QString HeaderRemotePort;
187 
191  static QString HeaderRequestMethod;
192 
196  static QString HeaderRequestUri;
197 
201  static QString HeaderScriptFilename;
202 
206  static QString HeaderScriptName;
207 
211  static QString HeaderServerAddress;
212 
217 
221  static QString HeaderServerName;
222 
226  static QString HeaderServerPort;
227 
231  static QString HeaderServerProtocol;
232 
236  static QString HeaderServerSignature;
237 
241  static QString HeaderServerSoftware;
242 
246  static QString MethodDelete;
247 
251  static QString MethodGet;
252 
256  static QString MethodHead;
257 
261  static QString MethodPost;
262 
266  static QString MethodPut;
267 
271  CCgiManager();
272 
276  void AddResponseHeader(const QString& header, const QString& value);
277 
281  QString EncodeQuery(const KeyValueMap& queryMap, const QString& pairGlue = "&");
282 
286  QString EncodeQuery(const QVariantMap& queryMap, const QString& pairGlue = "&");
287 
291  void WriteResponse();
292 
296  QString GetResponseContent() const;
297 
301  QString GetCookie(const QString& cookieName) const;
302 
306  const KeyValueMap& GetCookies() const;
307 
311  QString GetParameter(const QString& parameterName) const;
312 
316  const KeyValueMap& GetPostData() const;
317 
321  const KeyValueMap& GetQueryData() const;
322 
326  QString GetRequestHeader(const QString& requestHeaderType) const;
327 
331  const KeyValueMap& GetRequestHeaders() const;
332 
336  void SetResponseContent(const QString& responseContent);
337 
341  void SetResponseContentType(const QString& contentType);
342 
343 protected:
347  void ProcessCookies();
348 
352  void ProcessGet();
353 
357  void ProcessHeaders();
358 
362  void ProcessPost();
363 
367  void SendResponseContent();
368 
372  void SendHeaders();
373 
377  KeyValueMap DecodeQuery(const QString& query, const QString& pairSeparator = "&");
378 
379 private:
383  QString m_responseContent;
384 
388  KeyValueMap m_cookies;
389 
393  KeyValueMap m_getParameters;
394 
398  KeyValueMap m_postParameters;
399 
403  KeyValueMap m_requestHeaders;
404 
408  KeyValueMap m_responseHeaders;
409 };
410 
411 
412 } // namespace iweb
413 
414 
415 #endif // iweb_CCgiManager_included
416 
417 
static QString HeaderGatewayInterface
This proeprty contains the GATEWAY_INTERFACE header name.
Definition: CCgiManager.h:131
const KeyValueMap & GetQueryData() const
This method returns the current GET map from the instance.
static QString ContentFontEOT
This property contains the header type for EOT.
Definition: CCgiManager.h:61
static QString HeaderServerAdministrator
This property contians the SERVER_ADMIN header name.
Definition: CCgiManager.h:216
static QString ContentTypeJS
This property contains the header type for JS.
Definition: CCgiManager.h:101
QString GetParameter(const QString &parameterName) const
This method returns a GET/POST parameter from the instance if one exists.
static QString ContentFont
This property contins the header type for FONT.
Definition: CCgiManager.h:56
static QString ContentFontTTF
This property contains the header type for TTF.
Definition: CCgiManager.h:71
void ProcessPost()
This method processes the POST data into the instance.
static QString ContentScriptVB
This property contains the header type for VB.
Definition: CCgiManager.h:86
static QString MethodGet
This property contains the GET data request method name.
Definition: CCgiManager.h:251
static QString HeaderHttpUserAgent
This property contains the HTTP_USER_AGENT header name.
Definition: CCgiManager.h:166
CCgiManager()
This constructor automatically parses the HTTP headers and data.
static QString HeaderScriptFilename
This paragraph contains the SCRIPT_FILENAME header name.
Definition: CCgiManager.h:201
static QString HeaderServerName
This property contains the SERVER_NAME header name.
Definition: CCgiManager.h:221
static QString HeaderDocumentRoot
This property contains the DOCUMENT_ROOT header name.
Definition: CCgiManager.h:126
const KeyValueMap & GetCookies() const
This method returns the current cookie map in the instance.
QMap< QString, QString > KeyValueMap
Definition: CCgiManager.h:21
static QString ContentTypeText
This property contains the header type for TXT.
Definition: CCgiManager.h:111
void WriteResponse()
This method writes the HTTP response to the browser/socket.
const KeyValueMap & GetPostData() const
This method returns the current POST map from the instance.
static QString ContentTypeXML
This property contains the header type for XML.
Definition: CCgiManager.h:116
static QString HeaderServerPort
This property contains the SERVER_PORT header name.
Definition: CCgiManager.h:226
static QString ContentFontWOFF
This property contains the header type for WOFF.
Definition: CCgiManager.h:76
QString GetRequestHeader(const QString &requestHeaderType) const
This method returns a request header from the instance if one exists.
static QString HeaderServerProtocol
This property contains the SERVER_PROTOCOL header name.
Definition: CCgiManager.h:231
KeyValueMap DecodeQuery(const QString &query, const QString &pairSeparator="&")
This method decodes a query string into a query map.
void SendHeaders()
This method writes the response headers to the browser/socket/stream.
static QString ContentImageJPEG
This property contains the header type for JPEG.
Definition: CCgiManager.h:31
static QString MethodHead
This property contains the HEAD data request method name.
Definition: CCgiManager.h:256
QString EncodeQuery(const KeyValueMap &queryMap, const QString &pairGlue="&")
This method encodes a query map into a query string.
static QString HeaderRemoteAddress
This property contains the REMOTE_ADDR header name.
Definition: CCgiManager.h:181
static QString HeaderHttpAcceptLanguage
This property contains the HTTP_ACCEPT_LANGUAGE header.
Definition: CCgiManager.h:146
static QString ContentImageJPG
This property contains the header type for JPG.
Definition: CCgiManager.h:36
void AddResponseHeader(const QString &header, const QString &value)
This method adds a response header to the instance.
static QString HeaderServerSignature
This property contains the SERVER_SIGNATURE header name.
Definition: CCgiManager.h:236
QString GetResponseContent() const
This method returns the current response content in the instance.
static QString MethodPost
This property contains the POST data request method name.
Definition: CCgiManager.h:261
static QString ContentTypeCSS
This property contains the header type for CSS.
Definition: CCgiManager.h:91
void ProcessGet()
This method processes the QUERY_STRING from the header.
static QString ContentScriptECMAS
This property contains the header type for ECMAS.
Definition: CCgiManager.h:81
static QString HeaderServerAddress
This property contains the SERVER_ADDR header name.
Definition: CCgiManager.h:211
const KeyValueMap & GetRequestHeaders() const
This method returns the current request header map in the instance.
static QString HeaderRemotePort
This property contain the REMOTE_PORT header name.
Definition: CCgiManager.h:186
static QString ContentImageTIFF
This property contains the header type for TIFF.
Definition: CCgiManager.h:51
static QString HeaderHttpHost
This property contains the HTTP_HOST header name.
Definition: CCgiManager.h:161
static QString ContentFontOTF
This property contains the header type for OTF.
Definition: CCgiManager.h:66
static QString ContentTypeHTML
This property contain the header type for HTML.
Definition: CCgiManager.h:96
static QString HeaderQueryString
This property contains the QUERY_STRING header name.
Definition: CCgiManager.h:176
void ProcessHeaders()
This method processes the request headers into the instance.
void SendResponseContent()
This method writes the content to the browser/socket/stream.
static QString MethodDelete
This property contains the DELETE data request method name.
Definition: CCgiManager.h:246
static QString HeaderPath
This property contains the PATH header name.
Definition: CCgiManager.h:171
void SetResponseContentType(const QString &contentType)
This method sets the content type header into the instance.
QString GetCookie(const QString &cookieName) const
This method returns a cookie from the instance if one exists.
static QString HeaderHttpAccept
This property contains the HTTP_ACCEPT header name.
Definition: CCgiManager.h:136
static QString ContentImagePNG
This property contains the header type for PNG.
Definition: CCgiManager.h:41
static QString HeaderRequestMethod
This property contains the REQUEST_METHOD header name.
Definition: CCgiManager.h:191
static QString MethodPut
This property contains the PUT data request method name.
Definition: CCgiManager.h:266
static QString ContentTypeJSON
This property contains the header type for JSON.
Definition: CCgiManager.h:106
static QString HeaderHttpCookie
This property contains the HTTP_COOKIE header name.
Definition: CCgiManager.h:156
static QString ContentImageSVG
Thie property contains the header type for SVG.
Definition: CCgiManager.h:46
static QString HeaderComSpec
This property contains the COMSPEC header name.
Definition: CCgiManager.h:121
void ProcessCookies()
This method processes the HTTP_COOKIE from the header.
static QString ContentImageGIF
This property contains the header type for GIF.
Definition: CCgiManager.h:26
void SetResponseContent(const QString &responseContent)
This method sets the response content into the instance.
static QString HeaderHttpAcceptEncoding
This property contains the HTTP_ACCEPT_ENCODING header name.
Definition: CCgiManager.h:141
static QString HeaderScriptName
This property contains the SCRIPT_NAME header namr.
Definition: CCgiManager.h:206
static QString HeaderHttpConnection
This property contains the HTTP_CONNECTION header name.
Definition: CCgiManager.h:151
static QString HeaderServerSoftware
This property contains the SERVER_SOFTWARE header name.
Definition: CCgiManager.h:241
static QString HeaderRequestUri
This property contains the REQUEST_URI header name.
Definition: CCgiManager.h:196

© 2007-2011 Witold Gantzke and Kirill Lepskiy