QGIS API Documentation 3.35.0-Master (728e5967df5)
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
40// Note:
41// This class is intended to be used from Python code: method signatures and return types should be
42// compatible with pyQGIS/pyQT types and rules.
43
44class SERVER_EXPORT QgsServerResponse
45{
46 public:
47
49 QgsServerResponse() = default;
50
52 virtual ~QgsServerResponse() = default;
53
59 virtual void setHeader( const QString &key, const QString &value ) = 0;
60
65 virtual void removeHeader( const QString &key ) = 0;
66
70 virtual QString header( const QString &key ) const = 0;
71
75 virtual QMap<QString, QString> headers() const = 0;
76
80 virtual bool headersSent() const = 0;
81
82
87 virtual void setStatusCode( int code ) = 0;
88
92 virtual int statusCode() const = 0;
93
103 virtual void sendError( int code, const QString &message ) = 0;
104
110 virtual void write( const QString &data );
111
118 virtual qint64 write( const QByteArray &byteArray );
119
129 virtual qint64 write( const char *data, qint64 maxsize ) SIP_SKIP;
130
140 virtual qint64 write( const char *data ) SIP_SKIP;
141
151 virtual qint64 write( std::string data ) SIP_SKIP;
152
156 virtual void write( const QgsServerException &ex );
157
161 virtual QIODevice *io() = 0;
162
166 virtual void finish() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
167
175 virtual void flush() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
176
180 virtual void clear() = 0;
181
191 virtual QByteArray data() const = 0;
192
198 virtual void truncate() = 0;
199
204 virtual QgsFeedback *feedback() const;
205};
206
207#endif
Base class for feedback objects to be used for cancellation of something running in a worker thread.
Definition qgsfeedback.h:45
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
destructor
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
constructor
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:191
#define SIP_THROW(name,...)
Definition qgis_sip.h:198