QGIS/python/server/qgsserverrequest.sip

153 lines
3.6 KiB
Plaintext
Raw Normal View History

/***************************************************************************
qgsserverrequest.h
Define request class for getting request contents
-------------------
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
* QgsServerRequest
* Class defining request interface passed to services QgsService::executeRequest() method
*/
class QgsServerRequest
{
%TypeHeaderCode
#include "qgsserverrequest.h"
%End
2016-12-14 21:46:00 +01:00
public:
typedef QMap<QString, QString> Parameters;
typedef QMap<QString, QString> Headers;
enum Method
{
2016-12-14 21:46:00 +01:00
HeadMethod, PutMethod, GetMethod, PostMethod, DeleteMethod
};
/**
* Constructor
*/
QgsServerRequest();
2016-12-14 21:46:00 +01:00
/**
* Constructor
*
* @param url the url string
* @param method the request method
*/
QgsServerRequest( const QString &url, Method method );
2016-12-14 21:46:00 +01:00
/**
* Constructor
*
* \param url the url string
* \param method the request method
* \param headers
2016-12-14 21:46:00 +01:00
*/
QgsServerRequest( const QString &url, Method method = GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers( ) );
/**
* Constructor
*
* \param url QUrl
* \param method the request method
* \param headers
*/
QgsServerRequest( const QUrl &url, Method method = GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers( ) );
2016-12-14 21:46:00 +01:00
//! destructor
virtual ~QgsServerRequest();
/**
* Return the header value
* @param name of the header
* @return the header value or an empty string
*/
QString header( const QString &name ) const;
/**
* Set an header
* @param name
* @param value
*/
void setHeader( const QString &name, const QString &value );
/**
* Return the header map
* @return the headers map
*/
QMap<QString, QString> headers( ) const;
2016-12-14 21:46:00 +01:00
/**
* Remove an header
* @param name
2016-12-14 21:46:00 +01:00
*/
void removeHeader( const QString &name );
2016-12-14 21:46:00 +01:00
/**
* @return the request url
*/
QUrl url() const;
2016-12-14 21:46:00 +01:00
/**
* @return the request method
*/
Method method() const;
/**
2016-12-16 17:01:48 +01:00
* @return query params
*/
QMap<QString, QString> parameters() const;
2016-12-14 21:46:00 +01:00
2017-01-17 00:09:24 +01:00
/**
* Set a parameter
*/
void setParameter( const QString &key, const QString &value );
2017-01-17 00:09:24 +01:00
/**
* Get a parameter value
*/
QString parameter( const QString& key ) const;
2017-01-17 00:09:24 +01:00
/**
* Remove a parameter
*/
void removeParameter( const QString &key );
2017-01-17 00:09:24 +01:00
2016-12-14 21:46:00 +01:00
/**
* Return post/put data
* Check for QByteArray::isNull() to check if data
* is available.
*/
virtual QByteArray data() const;
/**
* Set the request url
*/
void setUrl( const QUrl &url );
/**
* Set the request method
*/
void setMethod( Method method );
};