QGIS API Documentation  3.2.0-Bonn (bc43194)
qgsserverresponse.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsserverresponse.h
3 
4  Define response class for services
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 QGSSERVERRESPONSE_H
20 #define QGSSERVERRESPONSE_H
21 
22 #include "qgis_server.h"
23 #include "qgis_sip.h"
24 
25 #include <QString>
26 #include <QIODevice>
27 
28 class QgsServerException;
29 
38 // Note:
39 // This class is intended to be used from Python code: method signatures and return types should be
40 // compatible with pyQGIS/pyQT types and rules.
41 
42 class SERVER_EXPORT QgsServerResponse
43 {
44  public:
45 
47  QgsServerResponse() = default;
48 
50  virtual ~QgsServerResponse() = default;
51 
57  virtual void setHeader( const QString &key, const QString &value ) = 0;
58 
63  virtual void removeHeader( const QString &key ) = 0;
64 
68  virtual QString header( const QString &key ) const = 0;
69 
73  virtual QMap<QString, QString> headers() const = 0;
74 
78  virtual bool headersSent() const = 0;
79 
80 
85  virtual void setStatusCode( int code ) = 0;
86 
90  virtual int statusCode() const = 0;
91 
101  virtual void sendError( int code, const QString &message ) = 0;
102 
108  virtual void write( const QString &data );
109 
116  virtual qint64 write( const QByteArray &byteArray );
117 
127  virtual qint64 write( const char *data, qint64 maxsize ) SIP_SKIP;
128 
138  virtual qint64 write( const char *data ) SIP_SKIP;
139 
143  virtual void write( const QgsServerException &ex );
144 
148  virtual QIODevice *io() = 0;
149 
153  virtual void finish() = 0;
154 
161  virtual void flush() = 0;
162 
166  virtual void clear() = 0;
167 
177  virtual QByteArray data() const = 0;
178 
184  virtual void truncate() = 0;
185 };
186 
187 #endif
#define SIP_SKIP
Definition: qgis_sip.h:119
Exception base class for server exceptions.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...