QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
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#include "qgsserverexception.h"
25#include "qgsfeedback.h"
26
27#include <QString>
28#include <QIODevice>
29
31
39// Note:
40// This class is intended to be used from Python code: method signatures and return types should be
41// compatible with pyQGIS/pyQT types and rules.
42
43class SERVER_EXPORT QgsServerResponse
44{
45 public:
46
47 QgsServerResponse() = default;
48 virtual ~QgsServerResponse() = default;
49
55 virtual void setHeader( const QString &key, const QString &value ) = 0;
56
61 virtual void removeHeader( const QString &key ) = 0;
62
66 virtual QString header( const QString &key ) const = 0;
67
71 virtual QMap<QString, QString> headers() const = 0;
72
76 virtual bool headersSent() const = 0;
77
78
83 virtual void setStatusCode( int code ) = 0;
84
88 virtual int statusCode() const = 0;
89
99 virtual void sendError( int code, const QString &message ) = 0;
100
106 virtual void write( const QString &data );
107
114 virtual qint64 write( const QByteArray &byteArray );
115
125 virtual qint64 write( const char *data, qint64 maxsize ) SIP_SKIP;
126
136 virtual qint64 write( const char *data ) SIP_SKIP;
137
147 virtual qint64 write( std::string data ) SIP_SKIP;
148
152 virtual void write( const QgsServerException &ex );
153
157 virtual QIODevice *io() = 0;
158
162 virtual void finish() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
163
171 virtual void flush() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
172
176 virtual void clear() = 0;
177
187 virtual QByteArray data() const = 0;
188
194 virtual void truncate() = 0;
195
200 virtual QgsFeedback *feedback() const;
201};
202
203#endif
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:44
Exception base class for server exceptions.
QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() m...
virtual void removeHeader(const QString &key)=0
Clear header Undo a previous 'setHeader' call.
virtual int statusCode() const =0
Returns the http status code.
virtual ~QgsServerResponse()=default
virtual QMap< QString, QString > headers() const =0
Returns the header value.
virtual void setHeader(const QString &key, const QString &value)=0
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
QgsServerResponse()=default
virtual bool headersSent() const =0
Returns true if the headers have already been sent.
virtual void sendError(int code, const QString &message)=0
Send error This method delegates error handling at the server level.
virtual QIODevice * io()=0
Returns the underlying QIODevice.
virtual QString header(const QString &key) const =0
Returns the header value.
virtual void setStatusCode(int code)=0
Set the http status code.
#define SIP_SKIP
Definition qgis_sip.h:126
#define SIP_VIRTUALERRORHANDLER(name)
Definition qgis_sip.h:196
#define SIP_THROW(name,...)
Definition qgis_sip.h:203