QGIS API Documentation  2.10.1-Pisa
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsrequesthandler.h
Go to the documentation of this file.
1 
2 /***************************************************************************
3  qgsrequesthandler.h
4  abstraction for reading from/ writing to a request datasource
5  -------------------
6  begin : May 16, 2006
7  copyright : (C) 2006 by Marco Hugentobler
8  (C) 2014 by Alessandro Pasotti
9  email : marco dot hugentobler at karto dot baug dot ethz dot ch
10  a dot pasotti at itopen dot it
11  ***************************************************************************/
12 
13 /***************************************************************************
14  * *
15  * This program is free software; you can redistribute it and/or modify *
16  * it under the terms of the GNU General Public License as published by *
17  * the Free Software Foundation; either version 2 of the License, or *
18  * (at your option) any later version. *
19  * *
20  ***************************************************************************/
21 
22 #ifndef QGSREQUESTHANDLER_H
23 #define QGSREQUESTHANDLER_H
24 
25 //Needed for HAVE_SERVER_PYTHON_PLUGINS
26 #include "qgsconfig.h"
27 
28 #include <QMap>
29 #include <QString>
30 #include <QStringList>
31 
32 #ifdef HAVE_SERVER_PYTHON_PLUGINS
33 #include "qgsserverfilter.h"
34 #endif
35 
36 class QDomDocument;
37 class QImage;
39 
43 {
44 
45  public:
46 
48  : mHeadersSent( false )
49  , mException( 0 )
50  {}
51  virtual ~QgsRequestHandler() {}
53  virtual void parseInput() = 0;
55  virtual void setGetMapResponse( const QString& service, QImage* img, int imageQuality ) = 0;
56  virtual void setGetCapabilitiesResponse( const QDomDocument& doc ) = 0;
57  virtual void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) = 0;
59  virtual void setServiceException( QgsMapServiceException ex ) = 0;
60  virtual void setXmlResponse( const QDomDocument& doc ) = 0;
61  virtual void setXmlResponse( const QDomDocument& doc, const QString& mimeType ) = 0;
62  virtual void setGetPrintResponse( QByteArray* b ) = 0;
63  virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) = 0;
64  virtual void setGetFeatureResponse( QByteArray* ba ) = 0;
65  virtual void endGetFeatureResponse( QByteArray* ba ) = 0;
66  virtual void setGetCoverageResponse( QByteArray* ba ) = 0;
68  virtual void setHeader( const QString &name, const QString &value ) = 0;
70  virtual int removeHeader( const QString &name ) = 0;
72  virtual void clearHeaders( ) = 0;
74  virtual void appendBody( const QByteArray &body ) = 0;
76  virtual void clearBody( ) = 0;
78  virtual QByteArray body() { return mBody; }
80  virtual void setInfoFormat( const QString &format ) = 0;
82  virtual bool responseReady() const = 0;
84  virtual void sendResponse( ) = 0;
86  virtual bool exceptionRaised() const = 0;
93  virtual void setParameter( const QString &key, const QString &value ) = 0;
95  virtual int removeParameter( const QString &key ) = 0;
97  virtual QString parameter( const QString &key ) const = 0;
99  QString format() const { return mFormat; }
101  QString infoFormat() const { return mInfoFormat; }
103  bool headersSent() { return mHeadersSent; }
104 #ifdef HAVE_SERVER_PYTHON_PLUGINS
105 
106  virtual void setPluginFilters( QgsServerFiltersMap pluginFilters ) = 0;
107 #endif
108  protected:
109  virtual void sendHeaders( ) = 0;
110  virtual void sendBody( ) const = 0;
111 #ifdef HAVE_SERVER_PYTHON_PLUGINS
112  QgsServerFiltersMap mPluginFilters;
113 #endif
114  QByteArray mBody; // The response payload
117  QString mFormatString; //format string as it is passed in the request (with base)
121  QgsMapServiceException* mException; // Stores the exception
126 
127 };
128 
129 #endif
virtual void setGetCapabilitiesResponse(const QDomDocument &doc)=0
virtual QByteArray body()
Return the response body.
virtual void setServiceException(QgsMapServiceException ex)=0
Allow plugins to return a QgsMapServiceException.
virtual bool responseReady() const =0
Check whether there is any header set or the body is not empty.
virtual int removeParameter(const QString &key)=0
Remove a request parameter.
virtual void setGetCoverageResponse(QByteArray *ba)=0
virtual void sendHeaders()=0
virtual void setXmlResponse(const QDomDocument &doc)=0
bool headersSent()
Return true if the HTTP headers were already sent to the client.
virtual void clearBody()=0
Clears the response body.
virtual void endGetFeatureResponse(QByteArray *ba)=0
virtual bool exceptionRaised() const =0
Pointer to last raised exception.
QString format() const
Return the requested format string.
virtual void setHeader(const QString &name, const QString &value)=0
Set an HTTP header.
virtual ~QgsRequestHandler()
virtual void setGetMapResponse(const QString &service, QImage *img, int imageQuality)=0
Sends the map image back to the client.
QMap< QString, QString > mParameterMap
virtual void setGetFeatureResponse(QByteArray *ba)=0
QMap< QString, QString > mHeaders
Response headers.
virtual void parseInput()=0
Parses the input and creates a request neutral Parameter/Value map.
virtual void setGetFeatureInfoResponse(const QDomDocument &infoDoc, const QString &infoFormat)=0
virtual void sendBody() const =0
virtual void clearHeaders()=0
Delete all HTTP headers.
This class is an interface hiding the details of reading input and writing output from/to a wms reque...
QgsMapServiceException * mException
QString infoFormat() const
Return the mime type for the response.
virtual void setParameter(const QString &key, const QString &value)=0
Set a request parameter.
QMap< QString, QString > parameterMap()
Return a copy of the parsed parameters as a key-value pair, to modify a parameter setParameter( const...
virtual void appendBody(const QByteArray &body)=0
Append the bytestream to response body.
QString mFormat
This is set by the parseInput methods of the subclasses (parameter FORMAT, e.g.
virtual void setInfoFormat(const QString &format)=0
Set the info format string such as "text/xml".
virtual QString parameter(const QString &key) const =0
Return a request parameter.
virtual int removeHeader(const QString &name)=0
Remove an HTTP header.
virtual void setGetPrintResponse(QByteArray *b)=0
virtual void sendResponse()=0
Send out HTTP headers and flush output buffer.
Exception class for WMS service exceptions.
virtual bool startGetFeatureResponse(QByteArray *ba, const QString &infoFormat)=0