QGIS API Documentation 4.1.0-Master (31622b25bb0)
Loading...
Searching...
No Matches
qgsrequesthandler.h
Go to the documentation of this file.
1/***************************************************************************
2 qgshttprequesthandler.h
3 -----------------------
4 begin : June 29, 2007
5 copyright : (C) 2007 by Marco Hugentobler
6 (C) 2014 by Alessandro Pasotti
7 email : marco dot hugentobler at karto dot baug dot ethz dot ch
8 a dot pasotti at itopen dot it
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20#ifndef QGSREQUESTHANDLER_H
21#define QGSREQUESTHANDLER_H
22
23#include "qgis_server.h"
24#include "qgis_sip.h"
25
26#include <QMap>
27#include <QString>
28
32
38class SERVER_EXPORT QgsRequestHandler
39{
40 public:
46 explicit QgsRequestHandler( QgsServerRequest &request, QgsServerResponse &response );
47
50
57 void sendResponse();
58
60 void setResponseHeader( const QString &name, const QString &value );
61
63 void removeResponseHeader( const QString &name );
64
66 QString responseHeader( const QString &name ) const;
67
72 Q_DECL_DEPRECATED QMap<QString, QString> responseHeaders() const SIP_DEPRECATED;
73
78 QList<QString> fullResponseHeader( const QString &name ) const;
79
84 QMap<QString, QList<QString>> fullResponseHeaders() const;
85
87 void setRequestHeader( const QString &name, const QString &value );
88
90 void removeRequestHeader( const QString &name );
91
93 QString requestHeader( const QString &name ) const;
94
96 QMap<QString, QString> requestHeaders() const;
97
99 void clear();
100
102 void appendBody( const QByteArray &body );
103
105 bool exceptionRaised() const;
106
108 void clearBody();
109
111 QByteArray body() const;
112
114 QByteArray data() const;
115
117 QString url() const;
118
123 QString path() const;
124
126 void setStatusCode( int code );
127
129 int statusCode() const;
130
137 QMap<QString, QString> parameterMap() const;
138
140 void setParameter( const QString &key, const QString &value );
141
143 QString parameter( const QString &key ) const;
144
146 void removeParameter( const QString &key );
147
152 void parseInput() SIP_SKIP;
153
155 QString format() const { return mFormat; }
156
158 bool headersSent() const;
159
160 private:
161#ifdef SIP_RUN
162 QgsRequestHandler &operator=( const QgsRequestHandler & );
163#endif
164
165 void setupParameters();
166
168 QString mFormat;
169 QString mFormatString; //format string as it is passed in the request (with base)
170 QString mService;
171 bool mExceptionRaised = false;
172
173 QgsServerRequest &mRequest;
174 QgsServerResponse &mResponse;
175};
176
177#endif
An interface hiding the details of reading input and writing output from/to a wms request mechanism.
void removeParameter(const QString &key)
Remove a request parameter.
void removeRequestHeader(const QString &name)
Remove an HTTP request header.
QString responseHeader(const QString &name) const
Retrieve response header value.
void clearBody()
Clear response buffer.
QString requestHeader(const QString &name) const
Retrieve request header value.
QMap< QString, QString > parameterMap() const
Returns the parsed parameters as a key-value pair.
QString path() const
Returns the path component of the request URL.
QByteArray data() const
Returns the request POST data (can be null).
QString format() const
Returns the requested format string.
bool exceptionRaised() const
Pointer to last raised exception.
void parseInput()
Parses the input and creates a request neutral Parameter/Value map.
void setServiceException(const QgsServerException &ex)
Allow plugins to return a QgsMapServiceException.
void removeResponseHeader(const QString &name)
Remove an HTTP response header.
void sendResponse()
Send out HTTP headers and flush output buffer.
Q_DECL_DEPRECATED QMap< QString, QString > responseHeaders() const
Returns the response headers: note that if multiple values are set for the same header,...
void setRequestHeader(const QString &name, const QString &value)
Sets an HTTP request header.
QMap< QString, QList< QString > > fullResponseHeaders() const
Returns the response headers as a map of header name to list of values (to support multiple values fo...
void appendBody(const QByteArray &body)
Sets the info format string such as "text/xml".
QString parameter(const QString &key) const
Returns a request parameter.
QMap< QString, QString > requestHeaders() const
Returns the Request headers.
QString url() const
Returns the request url.
void setStatusCode(int code)
Sets response http status code.
QgsRequestHandler(QgsServerRequest &request, QgsServerResponse &response)
Constructor.
QByteArray body() const
Returns the response body data.
void clear()
Clears the response body and headers.
void setResponseHeader(const QString &name, const QString &value)
Sets an HTTP response header.
int statusCode() const
Returns the response http status code.
void setParameter(const QString &key, const QString &value)
Sets a request parameter.
QList< QString > fullResponseHeader(const QString &name) const
Returns the list of response headers for a given header name.
Exception base class for server exceptions.
Defines requests passed to QgsService classes.
Defines the response interface passed to QgsService.
#define SIP_DEPRECATED
Definition qgis_sip.h:113
#define SIP_SKIP
Definition qgis_sip.h:133