2016-12-07 22:09:57 +01:00
|
|
|
/***************************************************************************
|
2016-12-14 12:43:00 +01:00
|
|
|
qgsserverresponse.sip
|
2016-12-07 22:09:57 +01:00
|
|
|
|
|
|
|
Define response class for services
|
|
|
|
-------------------
|
|
|
|
begin : 2016-12-05
|
|
|
|
copyright : (C) 2016 by David Marteau
|
|
|
|
email : david dot marteau at 3liz dot com
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \ingroup server
|
|
|
|
* QgsServerResponse
|
|
|
|
* Class defining response interface passed to services QgsService::executeRequest() method
|
|
|
|
*/
|
2016-12-14 12:43:00 +01:00
|
|
|
|
2016-12-07 22:09:57 +01:00
|
|
|
class QgsServerResponse
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include "qgsserverresponse.h"
|
|
|
|
%End
|
|
|
|
public:
|
|
|
|
|
|
|
|
//!constructor
|
|
|
|
QgsServerResponse();
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~QgsServerResponse();
|
|
|
|
|
2016-12-14 12:43:00 +01:00
|
|
|
/** Set Header entry
|
|
|
|
* Add Header entry to the response
|
2016-12-14 19:17:57 +01:00
|
|
|
* Note that it is usually an error to set Header after writing data
|
2016-12-07 22:09:57 +01:00
|
|
|
*/
|
|
|
|
virtual void setHeader( const QString& key, const QString& value ) = 0;
|
|
|
|
|
2016-12-14 12:43:00 +01:00
|
|
|
/** Set the http return code
|
|
|
|
* @param code HTTP return code value
|
2016-12-07 22:09:57 +01:00
|
|
|
*/
|
|
|
|
virtual void setReturnCode( int code ) = 0;
|
|
|
|
|
|
|
|
/**
|
2016-12-14 12:43:00 +01:00
|
|
|
* Send error
|
2016-12-14 19:17:57 +01:00
|
|
|
* This method delegates error handling at the server level. This is different
|
|
|
|
* from calling setReturnCode() along with and a specific response body.
|
2016-12-14 12:43:00 +01:00
|
|
|
* @param code HHTP return code value
|
|
|
|
* @param message An informative error message
|
2016-12-07 22:09:57 +01:00
|
|
|
*/
|
|
|
|
virtual void sendError( int code, const QString& message ) = 0;
|
|
|
|
|
|
|
|
/**
|
2016-12-14 12:43:00 +01:00
|
|
|
* Write string
|
|
|
|
* This is a convenient method that will write directly
|
|
|
|
* to the underlying I/O device
|
2016-12-07 22:09:57 +01:00
|
|
|
*/
|
|
|
|
virtual void write(const QString& data );
|
|
|
|
|
|
|
|
/**
|
2016-12-14 12:43:00 +01:00
|
|
|
* Write chunk of data
|
2016-12-14 19:17:57 +01:00
|
|
|
* This is a convenient method that will write directly to the
|
2016-12-07 22:09:57 +01:00
|
|
|
* underlying I/O device
|
2016-12-14 19:17:57 +01:00
|
|
|
* @return the number of bytes that were actually written
|
2016-12-14 12:43:00 +01:00
|
|
|
*/
|
2016-12-07 22:09:57 +01:00
|
|
|
virtual qint64 write(const QByteArray& byteArray );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the underlying QIODevice
|
|
|
|
*/
|
|
|
|
virtual QIODevice* io() = 0;
|
|
|
|
|
|
|
|
};
|
|
|
|
|