QGIS API Documentation  3.21.0-Master (909859188c)
qgsfilterresponsedecorator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfilterresponsedecorator.h
3 
4  Define response adapter for handling filter's hooks
5  -------------------
6  begin : 2017-01-05
7  copyright : (C) 2017 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 QGSFILTERRESPONSEDECORATOR_H
20 #define QGSFILTERRESPONSEDECORATOR_H
21 
22 #define SIP_NO_FILE
23 
24 
25 #include "qgsserverresponse.h"
26 #include "qgsserverfilter.h"
27 #include "qgsserverexception.h"
28 
36 {
37  public:
38 
45 
49  void start() SIP_THROW( QgsServerException ) SIP_VIRTUALERRORHANDLER( server_exception_handler );
50 
51  // QgsServerResponse overrides
52 
53  void setHeader( const QString &key, const QString &value ) override { mResponse.setHeader( key, value ); }
54 
55  void removeHeader( const QString &key ) override { mResponse.removeHeader( key ); }
56 
57  QString header( const QString &key ) const override { return mResponse.header( key ); }
58 
59  QMap<QString, QString> headers() const override { return mResponse.headers(); }
60 
61  bool headersSent() const override { return mResponse.headersSent(); }
62 
63  void setStatusCode( int code ) override { mResponse.setStatusCode( code ); }
64 
65  int statusCode() const override { return mResponse.statusCode(); }
66 
67  void sendError( int code, const QString &message ) override { mResponse.sendError( code, message ); }
68 
69  QIODevice *io() override { return mResponse.io(); }
70 
71  void finish() override;
72 
73  void flush() override;
74 
75  void clear() override { mResponse.clear(); }
76 
77  QByteArray data() const override { return mResponse.data(); }
78 
79  void truncate() override { mResponse.truncate(); }
80 
81  private:
82  QgsServerFiltersMap mFilters;
83  QgsServerResponse &mResponse;
84 };
85 
86 #endif
87 
88 
89 
90 
91 
Class defining decorator for calling filter's hooks.
void clear() override
Reset all headers and content for this response.
int statusCode() const override
Returns the http status code.
void sendError(int code, const QString &message) override
Send error This method delegates error handling at the server level.
QIODevice * io() override
Returns the underlying QIODevice.
void flush() override
Flushes the current output buffer to the network.
void finish() override
Finish the response, ending the transaction.
QMap< QString, QString > headers() const override
Returns the header value.
void removeHeader(const QString &key) override
Clear header Undo a previous 'setHeader' call.
void setStatusCode(int code) override
Set the http status code.
QgsFilterResponseDecorator(QgsServerFiltersMap filters, QgsServerResponse &response)
Constructor for QgsFilterResponseDecorator.
QByteArray data() const override
Gets the data written so far.
void truncate() override
Truncate data.
bool headersSent() const override
Returns true if the headers have already been sent.
void setHeader(const QString &key, const QString &value) override
Set Header entry Add Header entry to the response Note that it is usually an error to set Header afte...
void start() SIP_THROW(QgsServerException)
Call filters requestReady() method.
QString header(const QString &key) const override
Returns the header value.
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 void truncate()=0
Truncate data.
virtual QByteArray data() const =0
Gets the data written so far.
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...
virtual void clear()=0
Reset all headers and content for this response.
virtual QIODevice * io()=0
Returns the underlying QIODevice.
virtual QMap< QString, QString > headers() const =0
Returns the header value.
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 QString header(const QString &key) const =0
Returns the header value.
virtual void setStatusCode(int code)=0
Set the http status code.
#define SIP_THROW(name)
Definition: qgis_sip.h:189
#define SIP_VIRTUALERRORHANDLER(name)
Definition: qgis_sip.h:182
QMultiMap< int, QgsServerFilter * > QgsServerFiltersMap