QGIS API Documentation  3.2.0-Bonn (bc43194)
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 
34 // Note about design: this interface must be passed along to Python and thus signatures methods must be
35 // compatible with pyQGIS/pyQT api and rules.
36 
37 class SERVER_EXPORT QgsServerRequest
38 {
39  public:
40 
41  typedef QMap<QString, QString> Parameters;
42  typedef QMap<QString, QString> Headers;
43 
47  enum Method
48  {
53  DeleteMethod
54  };
55 
56 
60  QgsServerRequest() = default;
61 
70 
79 
81  virtual ~QgsServerRequest() = default;
82 
86  QUrl url() const;
87 
91  QgsServerRequest::Method method() const;
92 
97  QgsServerRequest::Parameters parameters() const;
98 
102  void setParameter( const QString &key, const QString &value );
103 
107  QString parameter( const QString &key ) const;
108 
112  void removeParameter( const QString &key );
113 
119  QString header( const QString &name ) const;
120 
126  void setHeader( const QString &name, const QString &value );
127 
132  QMap<QString, QString> headers() const;
133 
138  void removeHeader( const QString &name );
139 
145  virtual QByteArray data() const;
146 
150  void setUrl( const QUrl &url );
151 
155  void setMethod( QgsServerRequest::Method method );
156 
157  private:
158  QUrl mUrl;
159  Method mMethod = GetMethod;
160  // We mark as mutable in order
161  // to support lazy initialization
162  // Use QMap here because it will be faster for small
163  // number of elements
164  mutable bool mDecoded = false;
165  mutable Parameters mParams;
166  mutable Headers mHeaders;
167 };
168 
169 #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...
QMap< QString, QString > Parameters