32 mBuffer.open( QIODevice::ReadWrite );
38 mHeaders.remove( key );
44 mHeaders.insert( key, value );
54 return mHeaders.value( key );
72 setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/plain; charset=utf-8" ) );
92 if ( ! mHeaders.contains(
"Content-Length" ) )
94 mHeaders.insert( QStringLiteral(
"Content-Length" ), QStringLiteral(
"%1" ).arg( mBuffer.pos() ) );
103 if ( ! mHeadersSent )
109 QByteArray &ba = mBuffer.buffer();
119 mBuffer.buffer().clear();
125 return mBuffer.data();
132 mBuffer.buffer().clear();
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 setStatusCode(int code) override
Set the http status code.
void clear() override
Reset all headers and content for this response.
QgsBufferServerResponse()
void removeHeader(const QString &key) override
Clear header Undo a previous 'setHeader' call.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device...
void finish() override
Finish the response, ending the transaction.
void truncate() override
Truncate data.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
QByteArray data() const override
Gets the data written so far.
QString header(const QString &key) const override
Returns the header value.
void flush() override
Flushes the current output buffer to the network.
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.
bool headersSent() const override
Returns true if the headers have already been sent.