QGIS API Documentation  3.0.2-Girona (307d082)
qgsrequesthandler.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgshttprequesthandler.h
3  -----------------------
4  begin : June 29, 2007
5  copyright : (C) 2007 by Marco Hugentobler
6  (C) 2014 by Alessandro Pasotti
7  email : marco dot hugentobler at karto dot baug dot ethz dot ch
8  a dot pasotti at itopen dot it
9  ***************************************************************************/
10 
11 /***************************************************************************
12  * *
13  * This program is free software; you can redistribute it and/or modify *
14  * it under the terms of the GNU General Public License as published by *
15  * the Free Software Foundation; either version 2 of the License, or *
16  * (at your option) any later version. *
17  * *
18  ***************************************************************************/
19 
20 #ifndef QGSREQUESTHANDLER_H
21 #define QGSREQUESTHANDLER_H
22 
23 #include <QMap>
24 #include "qgis_sip.h"
25 #include <QString>
26 #include <QStringList>
27 #include <QPair>
28 #include <QColor>
29 #include <QHash>
30 
31 #include "qgis_server.h"
32 
33 class QDomDocument;
34 class QImage;
35 class QgsServerException;
36 class QgsServerRequest;
38 
39 typedef QList< QPair<QRgb, int> > QgsColorBox; //Color / number of pixels
40 typedef QMultiMap< int, QgsColorBox > QgsColorBoxMap; // sum of pixels / color box
41 
47 class SERVER_EXPORT QgsRequestHandler
48 {
49  public:
50 
56  explicit QgsRequestHandler( QgsServerRequest &request, QgsServerResponse &response );
57 
59  void setServiceException( const QgsServerException &ex );
60 
67  void sendResponse();
68 
70  void setResponseHeader( const QString &name, const QString &value );
71 
73  void removeResponseHeader( const QString &name );
74 
76  QString responseHeader( const QString &name ) const;
77 
79  QMap<QString, QString> responseHeaders() const;
80 
82  void setRequestHeader( const QString &name, const QString &value );
83 
85  void removeRequestHeader( const QString &name );
86 
88  QString requestHeader( const QString &name ) const;
89 
91  QMap<QString, QString> requestHeaders() const;
92 
94  void clear();
95 
97  void appendBody( const QByteArray &body );
98 
100  bool exceptionRaised() const;
101 
103  void clearBody();
104 
106  QByteArray body() const;
107 
109  QByteArray data() const;
110 
112  QString url() const;
113 
115  void setStatusCode( int code );
116 
118  int statusCode() const;
119 
125  QMap<QString, QString> parameterMap() const;
126 
128  void setParameter( const QString &key, const QString &value );
129 
131  QString parameter( const QString &key ) const;
132 
134  void removeParameter( const QString &key );
135 
140  void parseInput() SIP_SKIP;
141 
143  QString format() const { return mFormat; }
144 
146  bool headersSent() const;
147 
148  private:
149 
150  void setupParameters();
151 
153  QString mFormat;
154  QString mFormatString; //format string as it is passed in the request (with base)
155  QString mService;
156  bool mExceptionRaised;
157 
158  QgsServerRequest &mRequest;
159  QgsServerResponse &mResponse;
160 
161 };
162 
163 #endif
QString format() const
Return the requested format string.
#define SIP_SKIP
Definition: qgis_sip.h:119
This class is an interface hiding the details of reading input and writing output from/to a wms reque...
Exception base class for server exceptions.
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QMultiMap< int, QgsColorBox > QgsColorBoxMap
QList< QPair< QRgb, int > > QgsColorBox
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...