QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
23 #include <fcgi_stdio.h>
33 mBuffer.open( QIODevice::ReadWrite );
39 mHeaders.remove( key );
44 mHeaders.insert( key, value );
49 return mHeaders.value( key );
60 mHeaders.insert( QStringLiteral(
"Status" ), QStringLiteral(
" %1" ).arg( code ) );
75 setHeader( QStringLiteral(
"Content-Type" ), QStringLiteral(
"text/html;charset=utf-8" ) );
76 write( QStringLiteral(
"<html><body>%1</body></html>" ).arg( message ) );
95 if ( ! mHeaders.contains(
"Content-Length" ) )
97 mHeaders.insert( QStringLiteral(
"Content-Length" ), QStringLiteral(
"%1" ).arg( mBuffer.pos() ) );
106 if ( ! mHeadersSent )
109 QMap<QString, QString>::const_iterator it;
110 for ( it = mHeaders.constBegin(); it != mHeaders.constEnd(); ++it )
112 fputs( it.key().toUtf8(), FCGI_stdout );
113 fputs(
": ", FCGI_stdout );
114 fputs( it.value().toUtf8(), FCGI_stdout );
115 fputs(
"\n", FCGI_stdout );
117 fputs(
"\n", FCGI_stdout );
126 mBuffer.buffer().clear();
128 else if ( mBuffer.bytesAvailable() > 0 )
130 QByteArray &ba = mBuffer.buffer();
131 size_t count = fwrite( (
void * )ba.data(), ba.size(), 1, FCGI_stdout );
133 qDebug() << QStringLiteral(
"Sent %1 blocks of %2 bytes" ).arg( count ).arg( ba.size() );
147 mBuffer.buffer().clear();
156 return mBuffer.data();
163 mBuffer.buffer().clear();
169 setHeader( QStringLiteral(
"Server" ), QStringLiteral(
" QGIS FCGI server - QGIS version %1" ).arg(
Qgis::version() ) );
static QString version()
Version string.
QIODevice * io() override
Returns the underlying QIODevice.
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...
bool headersSent() const override
Returns true if the headers have already been sent.
void sendError(int code, const QString &message) override
Send error This method delegates error handling at the server level.
QByteArray data() const override
Gets the data written so far.
void clear() override
Reset all headers and content for this response.
void flush() override
Flushes the current output buffer to the network.
virtual void write(const QString &data)
Write string This is a convenient method that will write directly to the underlying I/O device.
void truncate() override
Truncate data.
QString header(const QString &key) const override
Returns the header value.
QgsFcgiServerResponse(QgsServerRequest::Method method=QgsServerRequest::GetMethod)
Constructor for QgsFcgiServerResponse.
void removeHeader(const QString &key) override
Clear header Undo a previous 'setHeader' call.
void setStatusCode(int code) override
Set the http status code.
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).
Method
HTTP Method (or equivalent) used for the request.
void finish() override
Finish the response, ending the transaction.
void setDefaultHeaders()
Set the default headers.