QGIS API Documentation  3.0.2-Girona (307d082)
Public Member Functions | List of all members
QgsServerResponse Class Referenceabstract

QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() method. More...

#include <qgsserverresponse.h>

Public Member Functions

 QgsServerResponse ()=default
 constructor More...
 
virtual ~QgsServerResponse ()=default
 destructor More...
 
virtual void clear ()=0
 Reset all headers and content for this response. More...
 
virtual QByteArray data () const =0
 Get the data written so far. More...
 
virtual void finish ()=0
 Finish the response, ending the transaction. More...
 
virtual void flush ()=0
 Flushes the current output buffer to the network. More...
 
virtual QString header (const QString &key) const =0
 Return the header value. More...
 
virtual QMap< QString, QString > headers () const =0
 Return the header value. More...
 
virtual bool headersSent () const =0
 Return true if the headers have alredy been sent. More...
 
virtual QIODevice * io ()=0
 Return the underlying QIODevice. More...
 
virtual void removeHeader (const QString &key)=0
 Clear header Undo a previous 'setHeader' call. More...
 
virtual void sendError (int code, const QString &message)=0
 Send error This method delegates error handling at the server level. More...
 
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 after data have been sent through the wire. More...
 
virtual void setStatusCode (int code)=0
 Set the http status code. More...
 
virtual int statusCode () const =0
 Return the http status code. More...
 
virtual void truncate ()=0
 Truncate data. More...
 
virtual void write (const QString &data)
 Write string This is a convenient method that will write directly to the underlying I/O device. More...
 
virtual qint64 write (const QByteArray &byteArray)
 Write chunk of data This is a convenient method that will write directly to the underlying I/O device. More...
 
virtual qint64 write (const char *data, qint64 maxsize)
 Writes at most maxSize bytes of data. More...
 
virtual qint64 write (const char *data)
 Writes at most maxSize bytes of data. More...
 
virtual void write (const QgsServerException &ex)
 Write server exception. More...
 

Detailed Description

QgsServerResponse Class defining response interface passed to services QgsService::executeRequest() method.

Since
QGIS 3.0

Definition at line 42 of file qgsserverresponse.h.

Constructor & Destructor Documentation

◆ QgsServerResponse()

QgsServerResponse::QgsServerResponse ( )
default

constructor

◆ ~QgsServerResponse()

virtual QgsServerResponse::~QgsServerResponse ( )
virtualdefault

destructor

Member Function Documentation

◆ clear()

virtual void QgsServerResponse::clear ( )
pure virtual

Reset all headers and content for this response.

◆ data()

virtual QByteArray QgsServerResponse::data ( ) const
pure virtual

Get the data written so far.

This is implementation dependent: some implementations may not give access to the underlying and return an empty array.

Note that each call to 'flush' may empty the buffer and in case of streaming process you may get partial content

◆ finish()

virtual void QgsServerResponse::finish ( )
pure virtual

Finish the response, ending the transaction.

◆ flush()

virtual void QgsServerResponse::flush ( )
pure virtual

Flushes the current output buffer to the network.

'flush()' may be called multiple times. For HTTP transactions headers will be written on the first call to 'flush()'.

◆ header()

virtual QString QgsServerResponse::header ( const QString &  key) const
pure virtual

Return the header value.

◆ headers()

virtual QMap<QString, QString> QgsServerResponse::headers ( ) const
pure virtual

Return the header value.

◆ headersSent()

virtual bool QgsServerResponse::headersSent ( ) const
pure virtual

Return true if the headers have alredy been sent.

◆ io()

virtual QIODevice* QgsServerResponse::io ( )
pure virtual

Return the underlying QIODevice.

◆ removeHeader()

virtual void QgsServerResponse::removeHeader ( const QString &  key)
pure virtual

Clear header Undo a previous 'setHeader' call.

◆ sendError()

virtual void QgsServerResponse::sendError ( int  code,
const QString &  message 
)
pure virtual

Send error This method delegates error handling at the server level.

This is different from calling setReturnCode() which let you return a specific response body. Calling sendError() will end the transaction and any attempt to write data or set headers will be an error.

Parameters
codeHHTP return code value
messageAn informative error message

◆ setHeader()

virtual void QgsServerResponse::setHeader ( const QString &  key,
const QString &  value 
)
pure virtual

Set Header entry Add Header entry to the response Note that it is usually an error to set Header after data have been sent through the wire.

◆ setStatusCode()

virtual void QgsServerResponse::setStatusCode ( int  code)
pure virtual

Set the http status code.

Parameters
codeHTTP status code value

◆ statusCode()

virtual int QgsServerResponse::statusCode ( ) const
pure virtual

Return the http status code.

◆ truncate()

virtual void QgsServerResponse::truncate ( )
pure virtual

Truncate data.

Clear internal buffer

◆ write() [1/5]

virtual void QgsServerResponse::write ( const QString &  data)
virtual

Write string This is a convenient method that will write directly to the underlying I/O device.

◆ write() [2/5]

virtual qint64 QgsServerResponse::write ( const QByteArray &  byteArray)
virtual

Write chunk of data This is a convenient method that will write directly to the underlying I/O device.

Returns
the number of bytes that were actually written

◆ write() [3/5]

virtual qint64 QgsServerResponse::write ( const char *  data,
qint64  maxsize 
)
virtual

Writes at most maxSize bytes of data.

This is a convenient method that will write directly to the underlying I/O device

Returns
the number of bytes written
Note
not available in Python bindings

◆ write() [4/5]

virtual qint64 QgsServerResponse::write ( const char *  data)
virtual

Writes at most maxSize bytes of data.

This is a convenient method that will write directly to the underlying I/O device

Returns
the number of bytes written
Note
not available in Python bindings

◆ write() [5/5]

virtual void QgsServerResponse::write ( const QgsServerException ex)
virtual

Write server exception.


The documentation for this class was generated from the following file: