Skip to content
Permalink
Browse files

Replace headersWritten by headersSent

  • Loading branch information
dmarteau committed Jan 10, 2017
1 parent befc52a commit 4f996980bebc1a48e2298d21a1beb887da75451a
@@ -59,9 +59,9 @@ class QgsServerResponse
virtual QList<QString> headerKeys() const = 0;

/**
* Return true if the headers have alredy beeing written
* Return true if the headers have alredy been sent
*/
virtual bool headersWritten() const = 0;
virtual bool headersSent() const = 0;

/** Set the http return code
* @param code HTTP return code value
@@ -30,9 +30,9 @@
QgsBufferServerResponse::QgsBufferServerResponse()
{
mBuffer.open( QIODevice::ReadWrite );
mHeadersWritten = false;
mFinished = false;
mReturnCode = 200;
mHeadersSent = false;
mFinished = false;
mReturnCode = 200;
}

QgsBufferServerResponse::~QgsBufferServerResponse()
@@ -42,13 +42,13 @@ QgsBufferServerResponse::~QgsBufferServerResponse()

void QgsBufferServerResponse::clearHeader( const QString& key )
{
if ( !mHeadersWritten )
if ( !mHeadersSent )
mHeaders.remove( key );
}

void QgsBufferServerResponse::setHeader( const QString& key, const QString& value )
{
if ( ! mHeadersWritten )
if ( ! mHeadersSent )
mHeaders.insert( key, value );
}

@@ -67,16 +67,16 @@ QList<QString> QgsBufferServerResponse::headerKeys() const
return mHeaders.keys();
}

bool QgsBufferServerResponse::headersWritten() const
bool QgsBufferServerResponse::headersSent() const
{
return mHeadersWritten;
return mHeadersSent;
}

void QgsBufferServerResponse::sendError( int code, const QString& message )
{
if ( mHeadersWritten )
if ( mHeadersSent )
{
QgsMessageLog::logMessage( "Cannot send error after headers written" );
QgsMessageLog::logMessage( "Cannot send error after headers sent" );
return;
}

@@ -100,7 +100,7 @@ void QgsBufferServerResponse::finish()
return;
}

if ( !mHeadersWritten )
if ( !mHeadersSent )
{
if ( ! mHeaders.contains( "Content-Length" ) )
{
@@ -113,9 +113,9 @@ void QgsBufferServerResponse::finish()

void QgsBufferServerResponse::flush()
{
if ( ! mHeadersWritten )
if ( ! mHeadersSent )
{
mHeadersWritten = true;
mHeadersSent = true;
}

mBuffer.seek( 0 );
@@ -46,7 +46,7 @@ class QgsBufferServerResponse: public QgsServerResponse

virtual QList<QString> headerKeys() const override;

virtual bool headersWritten() const override;
virtual bool headersSent() const override;

virtual void setReturnCode( int code ) override;

@@ -80,7 +80,7 @@ class QgsBufferServerResponse: public QgsServerResponse
QBuffer mBuffer;
QByteArray mBody;
bool mFinished;
bool mHeadersWritten;
bool mHeadersSent;
int mReturnCode;
};

@@ -32,7 +32,7 @@
QgsFcgiServerResponse::QgsFcgiServerResponse( QgsServerRequest::Method method )
{
mBuffer.open( QIODevice::ReadWrite );
mHeadersWritten = false;
mHeadersSent = false;
mFinished = false;
mMethod = method;
}
@@ -62,9 +62,9 @@ QList<QString> QgsFcgiServerResponse::headerKeys() const
return mHeaders.keys();
}

bool QgsFcgiServerResponse::headersWritten() const
bool QgsFcgiServerResponse::headersSent() const
{
return mHeadersWritten;
return mHeadersSent;
}

void QgsFcgiServerResponse::setReturnCode( int code )
@@ -75,7 +75,7 @@ void QgsFcgiServerResponse::setReturnCode( int code )

void QgsFcgiServerResponse::sendError( int code, const QString& message )
{
if ( mHeadersWritten )
if ( mHeadersSent )
{
QgsMessageLog::logMessage( "Cannot send error after headers written" );
return;
@@ -102,7 +102,7 @@ void QgsFcgiServerResponse::finish()
return;
}

if ( !mHeadersWritten )
if ( !mHeadersSent )
{
if ( ! mHeaders.contains( "Content-Length" ) )
{
@@ -115,7 +115,7 @@ void QgsFcgiServerResponse::finish()

void QgsFcgiServerResponse::flush()
{
if ( ! mHeadersWritten )
if ( ! mHeadersSent )
{
// Send all headers
QMap<QString, QString>::const_iterator it;
@@ -127,7 +127,7 @@ void QgsFcgiServerResponse::flush()
fputs( "\n" , FCGI_stdout );
}
fputs( "\n", FCGI_stdout );
mHeadersWritten = true;
mHeadersSent = true;
}

mBuffer.seek( 0 );
@@ -44,7 +44,7 @@ class QgsFcgiServerResponse: public QgsServerResponse

virtual QList<QString> headerKeys() const override;

virtual bool headersWritten() const override;
virtual bool headersSent() const override;

virtual void setReturnCode( int code ) override;

@@ -67,7 +67,7 @@ class QgsFcgiServerResponse: public QgsServerResponse
QMap<QString, QString> mHeaders;
QBuffer mBuffer;
bool mFinished;
bool mHeadersWritten;
bool mHeadersSent;
QgsServerRequest::Method mMethod;
};

@@ -49,7 +49,7 @@ class QgsFilterResponseDecorator: public QgsServerResponse

QList<QString> headerKeys() const override { return mResponse.headerKeys(); }

bool headersWritten() const override { return mResponse.headersWritten(); }
bool headersSent() const override { return mResponse.headersSent(); }

void setReturnCode( int code ) override { mResponse.setReturnCode( code ); }

@@ -100,7 +100,7 @@ QList<QString> QgsRequestHandler::headerKeys() const

bool QgsRequestHandler::headersSent() const
{
return mResponse.headersWritten();
return mResponse.headersSent();
}


@@ -68,9 +68,9 @@ class SERVER_EXPORT QgsServerResponse
virtual QList<QString> headerKeys() const = 0;

/**
* Return true if the headers have alredy beeing written
* Return true if the headers have alredy been sent
*/
virtual bool headersWritten() const = 0;
virtual bool headersSent() const = 0;


/** Set the http return code

0 comments on commit 4f99698

Please sign in to comment.
You can’t perform that action at this time.