2014-10-10 19:28:20 +02:00
|
|
|
/***************************************************************************
|
|
|
|
qgsrequesthandler.sip
|
|
|
|
|
|
|
|
This class is an interface hiding the details of reading input and
|
|
|
|
writing output from/to a wms request mechanism
|
|
|
|
-------------------
|
|
|
|
begin : 2014-09-10
|
|
|
|
copyright : (C) 2014 by Alessandro Pasotti
|
|
|
|
email : a dot pasotti at itopen dot it
|
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2016-02-14 03:50:23 +01:00
|
|
|
* \ingroup server
|
|
|
|
* This class is an interface hiding the details of reading input and writing
|
|
|
|
* output from/to a wms request mechanism.
|
2014-10-10 19:28:20 +02:00
|
|
|
* Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage
|
|
|
|
* as a standalone command line executable
|
|
|
|
*/
|
2017-01-05 13:35:20 +01:00
|
|
|
class QgsRequestHandler /Abstract/
|
2014-10-09 15:05:19 +02:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
2017-01-11 22:59:27 +01:00
|
|
|
#include "qgsserverexception.h"
|
2014-10-09 15:05:19 +02:00
|
|
|
#include "qgsrequesthandler.h"
|
|
|
|
%End
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2017-01-11 22:59:27 +01:00
|
|
|
/** Allow plugins to return a QgsServerException*/
|
2017-04-21 13:12:22 +02:00
|
|
|
void setServiceException( const QgsServerException &ex );
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2017-04-30 12:59:20 +02:00
|
|
|
//! Set an HTTP response header
|
|
|
|
void setResponseHeader( const QString &name, const QString &value );
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2017-04-30 12:59:20 +02:00
|
|
|
//! Remove an HTTP response header
|
|
|
|
void removeResponseHeader( const QString &name );
|
2017-01-05 17:40:57 +01:00
|
|
|
|
2017-04-30 12:59:20 +02:00
|
|
|
//! Retrieve response header value
|
|
|
|
QString responseHeader( const QString &name ) const;
|
2017-01-05 17:40:57 +01:00
|
|
|
|
2017-04-30 12:59:20 +02:00
|
|
|
//! Return the response headers
|
|
|
|
QMap<QString, QString> responseHeaders() const;
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2017-04-30 12:59:20 +02:00
|
|
|
//! Set an HTTP request header
|
|
|
|
void setRequestHeader( const QString &name, const QString &value );
|
|
|
|
|
|
|
|
//! Remove an HTTP request header
|
|
|
|
void removeRequestHeader( const QString &name );
|
|
|
|
|
|
|
|
//! Retrieve request header value
|
|
|
|
QString requestHeader( const QString &name ) const;
|
|
|
|
|
|
|
|
//! Return the Request headers
|
|
|
|
QMap<QString, QString> requestHeaders() const;
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Append the bytestream to response body*/
|
2017-01-05 13:35:20 +01:00
|
|
|
void appendBody( const QByteArray &body );
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Send out HTTP headers and flush output buffer*/
|
2017-01-05 13:35:20 +01:00
|
|
|
void sendResponse();
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2017-04-22 10:17:08 +02:00
|
|
|
//! Set response http status code
|
|
|
|
void setStatusCode( int code );
|
|
|
|
|
|
|
|
//! Return response http status code
|
|
|
|
int statusCode( ) const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Pointer to last raised exception*/
|
2017-01-05 13:35:20 +01:00
|
|
|
bool exceptionRaised() const;
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2017-04-21 13:12:22 +02:00
|
|
|
/** Clear response buffer */
|
|
|
|
void clearBody();
|
|
|
|
|
2017-04-30 12:59:20 +02:00
|
|
|
//! Clears the response body and headers
|
|
|
|
void clear();
|
|
|
|
|
2017-04-21 13:12:22 +02:00
|
|
|
/** Return body data */
|
|
|
|
QByteArray body() const;
|
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return a copy of the parsed parameters as a key-value pair, to modify
|
2014-10-10 19:28:20 +02:00
|
|
|
* a parameter setParameter( const QString &key, const QString &value)
|
|
|
|
* and removeParameter(const QString &key) must be used
|
|
|
|
*/
|
2017-01-05 17:40:57 +01:00
|
|
|
QMap<QString, QString> parameterMap() const;
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Set a request parameter*/
|
2017-01-05 13:35:20 +01:00
|
|
|
void setParameter( const QString &key, const QString &value );
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Remove a request parameter*/
|
2017-01-05 17:40:57 +01:00
|
|
|
void removeParameter( const QString &key );
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return a request parameter*/
|
2017-01-05 13:35:20 +01:00
|
|
|
QString parameter( const QString &key ) const;
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return the requested format string*/
|
2014-10-09 15:05:19 +02:00
|
|
|
QString format() const;
|
2016-10-01 11:23:26 +02:00
|
|
|
|
2015-07-29 11:52:14 +02:00
|
|
|
/** Return true if the HTTP headers were already sent to the client*/
|
2017-01-05 17:40:57 +01:00
|
|
|
bool headersSent() const;
|
2014-10-09 15:05:19 +02:00
|
|
|
};
|