QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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
27// Note about design: this interface must be passed along to Python and thus signatures methods must be
28// compatible with pyQGIS/pyQT api and rules.
29
36class SERVER_EXPORT QgsServerRequest
37{
38 Q_GADGET
39
40 public:
41
42 typedef QMap<QString, QString> Parameters;
43 typedef QMap<QString, QString> Headers;
44
57 Q_ENUM( Method )
58
59
79 Q_ENUM( RequestHeader )
80
81 QgsServerRequest() = default;
82
90 QgsServerRequest( const QString &url, QgsServerRequest::Method method = QgsServerRequest::GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers() );
91
99 QgsServerRequest( const QUrl &url, QgsServerRequest::Method method = QgsServerRequest::GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers() );
100
101 QgsServerRequest( const QgsServerRequest &other );
102
103 QgsServerRequest &operator=( const QgsServerRequest & ) = default;
104 virtual ~QgsServerRequest() = default;
105
110 static QString methodToString( const Method &method );
111
112
118 QUrl url() const;
119
123 QgsServerRequest::Method method() const;
124
129 QgsServerRequest::Parameters parameters() const;
130
134 QgsServerParameters serverParameters() const;
135
139 virtual void setParameter( const QString &key, const QString &value );
140
144 QString parameter( const QString &key, const QString &defaultValue = QString() ) const;
145
149 virtual void removeParameter( const QString &key );
150
156 virtual QString header( const QString &name ) const;
157
163 virtual QString header( const RequestHeader &headerEnum ) const;
164
170 void setHeader( const QString &name, const QString &value );
171
176 QMap<QString, QString> headers() const;
177
183 void removeHeader( const QString &name );
184
190 virtual QByteArray data() const;
191
195 virtual void setUrl( const QUrl &url );
196
204 QUrl originalUrl() const;
205
214 QUrl baseUrl() const;
215
219 void setMethod( QgsServerRequest::Method method );
220
225 const QString queryParameter( const QString &name, const QString &defaultValue = QString( ) ) const;
226
227 protected:
228
235 void setOriginalUrl( const QUrl &url );
236
242 void setBaseUrl( const QUrl &url );
243
244 private:
245 // Url as seen by QGIS server after web server rewrite
246 QUrl mUrl;
247 // Unrewritten url as seen by the web server
248 QUrl mOriginalUrl;
249 QUrl mBaseUrl;
250 Method mMethod = GetMethod;
251 // We mark as mutable in order
252 // to support lazy initialization
253 mutable Headers mHeaders;
254 QgsServerParameters mParams;
255};
256
257#endif
QgsServerParameters provides an interface to retrieve and manipulate global parameters received from ...
QgsServerRequest Class defining request interface passed to services QgsService::executeRequest() met...
Method
HTTP Method (or equivalent) used for the request.
QMap< QString, QString > Parameters
QMap< QString, QString > Headers
RequestHeader
The internal HTTP Header used for the request as enum.
@ X_QGIS_WMS_SERVICE_URL
The QGIS WMS service URL.
@ ACCEPT
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Accept.
@ X_QGIS_WCS_SERVICE_URL
The QGIS WCS service URL.
@ USER_AGENT
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent.
@ X_QGIS_WFS_SERVICE_URL
The QGIS WFS service URL.
@ X_FORWARDED_FOR
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For.
@ X_FORWARDED_PROTO
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Proto.
@ X_QGIS_WMTS_SERVICE_URL
The QGIS WMTS service URL.
@ X_QGIS_SERVICE_URL
The QGIS service URL.
@ X_FORWARDED_HOST
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-Host.
@ FORWARDED
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Forwarded, https://tools....
@ HOST
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host.
@ AUTHORIZATION
Https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Authorization.