QGIS API Documentation 3.41.0-Master (af5edcb665c)
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 QgsServerResponse() = default;
47 virtual ~QgsServerResponse() = default;
48
54 virtual void setHeader( const QString &key, const QString &value ) = 0;
55
60 virtual void removeHeader( const QString &key ) = 0;
61
65 virtual QString header( const QString &key ) const = 0;
66
70 virtual QMap<QString, QString> headers() const = 0;
71
75 virtual bool headersSent() const = 0;
76
77
82 virtual void setStatusCode( int code ) = 0;
83
87 virtual int statusCode() const = 0;
88
98 virtual void sendError( int code, const QString &message ) = 0;
99
105 virtual void write( const QString &data );
106
113 virtual qint64 write( const QByteArray &byteArray );
114
124 virtual qint64 write( const char *data, qint64 maxsize ) SIP_SKIP;
125
135 virtual qint64 write( const char *data ) SIP_SKIP;
136
146 virtual qint64 write( std::string data ) SIP_SKIP;
147
151 virtual void write( const QgsServerException &ex );
152
156 virtual QIODevice *io() = 0;
157
161 virtual void finish() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
162
170 virtual void flush() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
171
175 virtual void clear() = 0;
176
186 virtual QByteArray data() const = 0;
187
193 virtual void truncate() = 0;
194
199 virtual QgsFeedback *feedback() const;
200};
201
202#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