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

Defines a buffered server response. More...

#include <qgsbufferserverresponse.h>

Inheritance diagram for QgsBufferServerResponse:

Public Member Functions

 QgsBufferServerResponse ()
 QgsBufferServerResponse (const QgsBufferServerResponse &)=delete
void addHeader (const QString &key, const QString &value) override
 Add a header value for the given key, without replacing any existing value for the same key Add Header entry to the response.
QByteArray body () const
 Returns body.
void clear () override
 Reset all headers and content for this response.
QByteArray data () const override
 Gets the data written so far.
void finish () override
 Finish the response, ending the transaction.
void flush () override
 Flushes the current output buffer to the network.
virtual QList< QString > fullHeader (const QString &key) const override
 Returns all the values for a header key.
QMap< QString, QList< QString > > fullHeaders () const override
 Returns all the headers.
Q_DECL_DEPRECATED QString header (const QString &key) const override
 Returns a single header value, or an empty string if the header is not set.
Q_DECL_DEPRECATED QMap< QString, QString > headers () const override
 Returns all the headers as a map: only the last value is returned if multiple values are set for the same header name.
bool headersSent () const override
 Returns true if the headers have already been sent.
QIODevice * io () override
 Returns the underlying QIODevice.
void removeHeader (const QString &key) override
 Clear header Undo a previous 'setHeader' call.
void sendError (int code, const QString &message) override
 Send error This method delegates error handling at the server level.
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 after data have been sent through the wire.
void setStatusCode (int code) override
 Set the http status code.
int statusCode () const override
 Returns the http status code.
void truncate () override
 Truncate data.
Public Member Functions inherited from QgsServerResponse
 QgsServerResponse ()=default
virtual ~QgsServerResponse ()=default
virtual QgsFeedbackfeedback () const
 Returns the socket feedback if any.
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 a buffered server response.

Definition at line 36 of file qgsbufferserverresponse.h.

Constructor & Destructor Documentation

◆ QgsBufferServerResponse() [1/2]

QgsBufferServerResponse::QgsBufferServerResponse ( )

Definition at line 32 of file qgsbufferserverresponse.cpp.

◆ QgsBufferServerResponse() [2/2]

QgsBufferServerResponse::QgsBufferServerResponse ( const QgsBufferServerResponse & )
delete

Member Function Documentation

◆ addHeader()

void QgsBufferServerResponse::addHeader ( const QString & key,
const QString & value )
overridevirtual

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
Since
QGIS 4.2

Implements QgsServerResponse.

Definition at line 51 of file qgsbufferserverresponse.cpp.

◆ body()

QByteArray QgsBufferServerResponse::body ( ) const
inline

Returns body.

Definition at line 157 of file qgsbufferserverresponse.h.

◆ clear()

void QgsBufferServerResponse::clear ( )
overridevirtual

Reset all headers and content for this response.

Implements QgsServerResponse.

Definition at line 142 of file qgsbufferserverresponse.cpp.

◆ data()

QByteArray QgsBufferServerResponse::data ( ) const
overridevirtual

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

Implements QgsServerResponse.

Definition at line 150 of file qgsbufferserverresponse.cpp.

◆ finish()

void QgsBufferServerResponse::finish ( )
overridevirtual

Finish the response, ending the transaction.

Reimplemented from QgsServerResponse.

Definition at line 109 of file qgsbufferserverresponse.cpp.

◆ flush()

void QgsBufferServerResponse::flush ( )
overridevirtual

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()'.

Reimplemented from QgsServerResponse.

Definition at line 128 of file qgsbufferserverresponse.cpp.

◆ fullHeader()

QList< QString > QgsBufferServerResponse::fullHeader ( const QString & key) const
overridevirtual

Returns all the values for a header key.

Implements QgsServerResponse.

Definition at line 163 of file qgsbufferserverresponse.cpp.

◆ fullHeaders()

QMap< QString, QList< QString > > QgsBufferServerResponse::fullHeaders ( ) const
inlineoverridevirtual

Returns all the headers.

Implements QgsServerResponse.

Definition at line 73 of file qgsbufferserverresponse.h.

◆ header()

QString QgsBufferServerResponse::header ( const QString & key) const
overridevirtual

Returns a single header value, or an empty string if the header is not set.

If multiple values are set for the same header, only the last value is returned.

Deprecated
QGIS 4.2. Use fullHeader() instead.

Implements QgsServerResponse.

Definition at line 68 of file qgsbufferserverresponse.cpp.

◆ headers()

QMap< QString, QString > QgsBufferServerResponse::headers ( ) const
overridevirtual

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

Deprecated
QGIS 4.2. Use fullHeaders() instead.

Implements QgsServerResponse.

Definition at line 74 of file qgsbufferserverresponse.cpp.

◆ headersSent()

bool QgsBufferServerResponse::headersSent ( ) const
overridevirtual

Returns true if the headers have already been sent.

Implements QgsServerResponse.

Definition at line 84 of file qgsbufferserverresponse.cpp.

◆ io()

QIODevice * QgsBufferServerResponse::io ( )
overridevirtual

Returns the underlying QIODevice.

Implements QgsServerResponse.

Definition at line 104 of file qgsbufferserverresponse.cpp.

◆ removeHeader()

void QgsBufferServerResponse::removeHeader ( const QString & key)
overridevirtual

Clear header Undo a previous 'setHeader' call.

Implements QgsServerResponse.

Definition at line 37 of file qgsbufferserverresponse.cpp.

◆ sendError()

void QgsBufferServerResponse::sendError ( int code,
const QString & message )
overridevirtual

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

Implements QgsServerResponse.

Definition at line 89 of file qgsbufferserverresponse.cpp.

◆ setHeader()

void QgsBufferServerResponse::setHeader ( const QString & key,
const QString & value )
overridevirtual

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.

Implements QgsServerResponse.

Definition at line 43 of file qgsbufferserverresponse.cpp.

◆ setStatusCode()

void QgsBufferServerResponse::setStatusCode ( int code)
overridevirtual

Set the http status code.

Parameters
codeHTTP status code value

Implements QgsServerResponse.

Definition at line 63 of file qgsbufferserverresponse.cpp.

◆ statusCode()

int QgsBufferServerResponse::statusCode ( ) const
inlineoverridevirtual

Returns the http status code.

Implements QgsServerResponse.

Definition at line 100 of file qgsbufferserverresponse.h.

◆ truncate()

void QgsBufferServerResponse::truncate ( )
overridevirtual

Truncate data.

Clear internal buffer

Implements QgsServerResponse.

Definition at line 156 of file qgsbufferserverresponse.cpp.


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