QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsfcgiserverresponse.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfcgiserverresponse.h
3 
4  Define response wrapper for fcgi response
5  -------------------
6  begin : 2017-01-03
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 QGSFCGISERVERRESPONSE_H
20 #define QGSFCGISERVERRESPONSE_H
21 
22 #define SIP_NO_FILE
23 
24 
25 #include "qgsserverrequest.h"
26 #include "qgsserverresponse.h"
27 
28 #include <QBuffer>
29 
36 class SERVER_EXPORT QgsFcgiServerResponse: public QgsServerResponse
37 {
38  public:
39 
45 
46  void setHeader( const QString &key, const QString &value ) override;
47 
48  void removeHeader( const QString &key ) override;
49 
50  QString header( const QString &key ) const override;
51 
52  QMap<QString, QString> headers() const override { return mHeaders; }
53 
54  bool headersSent() const override;
55 
56  void setStatusCode( int code ) override;
57 
58  int statusCode() const override { return mStatusCode; }
59 
60  void sendError( int code, const QString &message ) override;
61 
62  QIODevice *io() override;
63 
64  void finish() override;
65 
66  void flush() override;
67 
68  void clear() override;
69 
70  QByteArray data() const override;
71 
72  void truncate() override;
73 
77  void setDefaultHeaders();
78 
79  private:
80  QMap<QString, QString> mHeaders;
81  QBuffer mBuffer;
82  bool mFinished = false;
83  bool mHeadersSent = false;
85  int mStatusCode = 0;
86 };
87 
88 #endif
QgsServerRequest::GetMethod
@ GetMethod
Definition: qgsserverrequest.h:69
QgsServerResponse::flush
virtual void flush() SIP_THROW(QgsServerException)
Flushes the current output buffer to the network.
Definition: qgsserverresponse.cpp:73
QgsFcgiServerResponse::headers
QMap< QString, QString > headers() const override
Returns the header value.
Definition: qgsfcgiserverresponse.h:52
QgsServerResponse::truncate
virtual void truncate()=0
Truncate data.
QgsServerResponse::clear
virtual void clear()=0
Reset all headers and content for this response.
QgsFcgiServerResponse
Class defining fcgi response.
Definition: qgsfcgiserverresponse.h:36
QgsFcgiServerResponse::statusCode
int statusCode() const override
Returns the http status code.
Definition: qgsfcgiserverresponse.h:58
qgsserverrequest.h
qgsserverresponse.h
QgsServerResponse::header
virtual QString header(const QString &key) const =0
Returns the header value.
QgsServerResponse::setStatusCode
virtual void setStatusCode(int code)=0
Set the http status code.
QgsServerResponse::removeHeader
virtual void removeHeader(const QString &key)=0
Clear header Undo a previous 'setHeader' call.
QgsServerResponse::data
virtual QByteArray data() const =0
Gets the data written so far.
QgsServerResponse::headersSent
virtual bool headersSent() const =0
Returns true if the headers have already been sent.
QgsServerResponse::finish
virtual void finish() SIP_THROW(QgsServerException)
Finish the response, ending the transaction.
Definition: qgsserverresponse.cpp:68
QgsServerResponse::io
virtual QIODevice * io()=0
Returns the underlying QIODevice.
QgsServerRequest::Method
Method
HTTP Method (or equivalent) used for the request.
Definition: qgsserverrequest.h:65
QgsServerResponse::sendError
virtual void sendError(int code, const QString &message)=0
Send error This method delegates error handling at the server level.
QgsServerResponse
Definition: qgsserverresponse.h:43
QgsServerResponse::setHeader
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...