QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
27 #include "qgis_server.h"
28 
29 class QgsServerException;
30 class QgsServerRequest;
31 class QgsServerResponse;
32 
38 class SERVER_EXPORT QgsRequestHandler
39 {
40  public:
41 
47  explicit QgsRequestHandler( QgsServerRequest &request, QgsServerResponse &response );
48 
50  void setServiceException( const QgsServerException &ex );
51 
58  void sendResponse();
59 
61  void setResponseHeader( const QString &name, const QString &value );
62 
64  void removeResponseHeader( const QString &name );
65 
67  QString responseHeader( const QString &name ) const;
68 
70  QMap<QString, QString> responseHeaders() const;
71 
73  void setRequestHeader( const QString &name, const QString &value );
74 
76  void removeRequestHeader( const QString &name );
77 
79  QString requestHeader( const QString &name ) const;
80 
82  QMap<QString, QString> requestHeaders() const;
83 
85  void clear();
86 
88  void appendBody( const QByteArray &body );
89 
91  bool exceptionRaised() const;
92 
94  void clearBody();
95 
97  QByteArray body() const;
98 
100  QByteArray data() const;
101 
103  QString url() const;
104 
106  void setStatusCode( int code );
107 
109  int statusCode() const;
110 
116  QMap<QString, QString> parameterMap() const;
117 
119  void setParameter( const QString &key, const QString &value );
120 
122  QString parameter( const QString &key ) const;
123 
125  void removeParameter( const QString &key );
126 
131  void parseInput() SIP_SKIP;
132 
134  QString format() const { return mFormat; }
135 
137  bool headersSent() const;
138 
139  private:
140 #ifdef SIP_RUN
141  QgsRequestHandler &operator=( const QgsRequestHandler & );
142 #endif
143 
144  void setupParameters();
145 
147  QString mFormat;
148  QString mFormatString; //format string as it is passed in the request (with base)
149  QString mService;
150  bool mExceptionRaised;
151 
152  QgsServerRequest &mRequest;
153  QgsServerResponse &mResponse;
154 
155 };
156 
157 #endif
QgsRequestHandler::format
QString format() const
Returns the requested format string.
Definition: qgsrequesthandler.h:134
QgsServerRequest
Definition: qgsserverrequest.h:38
SIP_SKIP
#define SIP_SKIP
Definition: qgis_sip.h:126
qgis_sip.h
QgsServerException
Exception base class for server exceptions.
Definition: qgsserverexception.h:42
QgsRequestHandler
Definition: qgsrequesthandler.h:38
QgsServerResponse
Definition: qgsserverresponse.h:43