QGIS API Documentation 4.1.0-Master (31622b25bb0)
Loading...
Searching...
No Matches
QgsServerResponse Class Referenceabstract

Defines the response interface passed to QgsService. More...

#include <qgsserverresponse.h>

Inheritance diagram for QgsServerResponse:

Public Member Functions

 QgsServerResponse ()=default
virtual ~QgsServerResponse ()=default
virtual void addHeader (const QString &key, const QString &value)=0
 Add a header value for the given key, without replacing any existing value for the same key Add Header entry to the response.
virtual void clear ()=0
 Reset all headers and content for this response.
virtual QByteArray data () const =0
 Gets the data written so far.
virtual QgsFeedbackfeedback () const
 Returns the socket feedback if any.
virtual void finish ()
 Finish the response, ending the transaction.
virtual void flush ()
 Flushes the current output buffer to the network.
virtual QList< QString > fullHeader (const QString &key) const =0
 Returns a (possibly empty) list of all the header values for the given key.
virtual QMap< QString, QList< QString > > fullHeaders () const =0
 Returns all the header values.
virtual Q_DECL_DEPRECATED QString header (const QString &key) const =0
 Returns a single header value for a given key.
virtual Q_DECL_DEPRECATED QMap< QString, QString > headers () const =0
 Returns the header values as a map: only the last value is returned if multiple values are set for the same header.
virtual bool headersSent () const =0
 Returns true if the headers have already been sent.
virtual QIODevice * io ()=0
 Returns the underlying QIODevice.
virtual void removeHeader (const QString &key)=0
 Clear all header values for the given key Undo a previous 'setHeader' call.
virtual void sendError (int code, const QString &message)=0
 Send error This method delegates error handling at the server level.
virtual void setHeader (const QString &key, const QString &value)=0
 Set a single header value replacing any existing value(s) for the same key.
virtual void setStatusCode (int code)=0
 Set the http status code.
virtual int statusCode () const =0
 Returns the http status code.
virtual void truncate ()=0
 Truncate data.
virtual qint64 write (const char *data)
 Writes at most maxSize bytes of data.
virtual qint64 write (const char *data, qint64 maxsize)
 Writes at most maxSize bytes of data.
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.
virtual void write (const QgsServerException &ex)
 Write server exception.
virtual void write (const QString &data)
 Write string This is a convenient method that will write directly to the underlying I/O device.
virtual qint64 write (std::string data)
 Writes at most maxSize bytes of data.

Detailed Description

Defines the response interface passed to QgsService.

Definition at line 41 of file qgsserverresponse.h.

Constructor & Destructor Documentation

◆ QgsServerResponse()

QgsServerResponse::QgsServerResponse ( )
default

◆ ~QgsServerResponse()

virtual QgsServerResponse::~QgsServerResponse ( )
virtualdefault

Member Function Documentation

◆ addHeader()

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

Add a header value for the given key, without replacing any existing value for the same key Add Header entry to the response.

Note
that it is usually an error to set Header after data have been sent through the wire
See also
setHeader() for a method that replaces any existing value(s) for the same header key
Since
QGIS 4.2

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ clear()

virtual void QgsServerResponse::clear ( )
pure virtual

Reset all headers and content for this response.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ data()

virtual QByteArray QgsServerResponse::data ( ) const
pure virtual

Gets 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

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ feedback()

QgsFeedback * QgsServerResponse::feedback ( ) const
virtual

Returns the socket feedback if any.

Since
QGIS 3.36

Reimplemented in QgsFcgiServerResponse, and QgsFilterResponseDecorator.

Definition at line 100 of file qgsserverresponse.cpp.

◆ finish()

void QgsServerResponse::finish ( )
virtual

Finish the response, ending the transaction.

The default implementation does nothing.

Reimplemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

Definition at line 72 of file qgsserverresponse.cpp.

◆ flush()

void QgsServerResponse::flush ( )
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()'. The default implementation does nothing.

Reimplemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

Definition at line 75 of file qgsserverresponse.cpp.

◆ fullHeader()

virtual QList< QString > QgsServerResponse::fullHeader ( const QString & key) const
pure virtual

Returns a (possibly empty) list of all the header values for the given key.

See also
header() to get only the last value for a given header key
Since
QGIS 4.2

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ fullHeaders()

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

Returns all the header values.

See also
headers() to get only the last value for each header key
Since
QGIS 4.2

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ header()

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

Returns a single header value for a given key.

Note
if multiple values are set for the same key, the last one is returned
Deprecated
QGIS 4.2. Use fullHeader() instead.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ headers()

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

Returns the header values as a map: only the last value is returned if multiple values are set for the same header.

See also
fullHeaders() to get all the values for all the headers
Deprecated
QGIS 4.2. Use fullHeaders() instead.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ headersSent()

virtual bool QgsServerResponse::headersSent ( ) const
pure virtual

Returns true if the headers have already been sent.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ io()

virtual QIODevice * QgsServerResponse::io ( )
pure virtual

Returns the underlying QIODevice.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ removeHeader()

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

Clear all header values for the given key Undo a previous 'setHeader' call.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ 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

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ setHeader()

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

Set a single header value replacing any existing value(s) for the same key.

Note
that it is usually an error to set Header after data have been sent through the wire
See also
addHeader() for a method that allows setting multiple values for the same header key
removeHeader() to clear header values for a given key

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ setStatusCode()

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

Set the http status code.

Parameters
codeHTTP status code value

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ statusCode()

virtual int QgsServerResponse::statusCode ( ) const
pure virtual

Returns the http status code.

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ truncate()

virtual void QgsServerResponse::truncate ( )
pure virtual

Truncate data.

Clear internal buffer

Implemented in QgsBufferServerResponse, QgsFcgiServerResponse, and QgsFilterResponseDecorator.

◆ write() [1/6]

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

Definition at line 62 of file qgsserverresponse.cpp.

◆ write() [2/6]

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

Definition at line 52 of file qgsserverresponse.cpp.

◆ write() [3/6]

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

Definition at line 42 of file qgsserverresponse.cpp.

◆ write() [4/6]

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

Write server exception.

Definition at line 83 of file qgsserverresponse.cpp.

◆ write() [5/6]

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

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

Definition at line 29 of file qgsserverresponse.cpp.

◆ write() [6/6]

qint64 QgsServerResponse::write ( std::string 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
Since
QGIS 3.10

Definition at line 78 of file qgsserverresponse.cpp.


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