QGIS API Documentation  3.4.15-Madeira (e83d02e274)
qgsserverrequest.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserverrequest.h
3 
4  Define request class for getting request contents
5  -------------------
6  begin : 2016-12-05
7  copyright : (C) 2016 by David Marteau
8  email : david dot marteau at 3liz dot com
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 #ifndef QGSSERVERREQUEST_H
20 #define QGSSERVERREQUEST_H
21 
22 #include <QUrl>
23 #include <QMap>
24 #include "qgis_server.h"
25 #include "qgsserverparameters.h"
26 
35 // Note about design: this interface must be passed along to Python and thus signatures methods must be
36 // compatible with pyQGIS/pyQT api and rules.
37 
38 class SERVER_EXPORT QgsServerRequest
39 {
40  public:
41 
42  typedef QMap<QString, QString> Parameters;
43  typedef QMap<QString, QString> Headers;
44 
48  enum Method
49  {
54  DeleteMethod
55  };
56 
57 
61  QgsServerRequest() = default;
62 
71 
80 
82  virtual ~QgsServerRequest() = default;
83 
90  QUrl url() const;
91 
95  QgsServerRequest::Method method() const;
96 
101  QgsServerRequest::Parameters parameters() const;
102 
106  QgsServerParameters serverParameters() const;
107 
111  void setParameter( const QString &key, const QString &value );
112 
116  QString parameter( const QString &key ) const;
117 
121  void removeParameter( const QString &key );
122 
128  QString header( const QString &name ) const;
129 
135  void setHeader( const QString &name, const QString &value );
136 
141  QMap<QString, QString> headers() const;
142 
147  void removeHeader( const QString &name );
148 
154  virtual QByteArray data() const;
155 
159  void setUrl( const QUrl &url );
160 
168  QUrl originalUrl() const;
169 
173  void setMethod( QgsServerRequest::Method method );
174 
175  protected:
176 
183  void setOriginalUrl( const QUrl &url );
184 
185 
186  private:
187  // Url as seen by QGIS server after web server rewrite
188  QUrl mUrl;
189  // Unrewritten url as seen by the web server
190  QUrl mOriginalUrl;
191  Method mMethod = GetMethod;
192  // We mark as mutable in order
193  // to support lazy initialization
194  mutable Headers mHeaders;
195  QgsServerParameters mParams;
196 };
197 
198 #endif
Method
HTTP Method (or equivalent) used for the request.
QMap< QString, QString > Headers
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
QMap< QString, QString > Parameters