Skip to content

Commit cdb947c

Browse files
authored
Merge pull request #4465 from boundlessgeo/server-plugins-api-refactoring2
[server] Server plugins API refactoring
2 parents 3be20f8 + 569593b commit cdb947c

33 files changed

+745
-435
lines changed
+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/server/qgsbufferserverrequest.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsBufferServerRequest : QgsServerRequest
13+
{
14+
%Docstring
15+
QgsBufferServerRequest
16+
Class defining request with data
17+
%End
18+
19+
%TypeHeaderCode
20+
#include "qgsbufferserverrequest.h"
21+
%End
22+
public:
23+
24+
QgsBufferServerRequest( const QString &url, Method method = GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers( ), QByteArray *data = 0 );
25+
%Docstring
26+
Constructor
27+
28+
\param url the url string
29+
\param method the request method
30+
%End
31+
32+
QgsBufferServerRequest( const QUrl &url, Method method = GetMethod, const QgsServerRequest::Headers &headers = QgsServerRequest::Headers( ), QByteArray *data = 0 );
33+
%Docstring
34+
Constructor
35+
36+
\param url QUrl
37+
\param method the request method
38+
%End
39+
40+
~QgsBufferServerRequest();
41+
42+
virtual QByteArray data() const;
43+
44+
};
45+
46+
/************************************************************************
47+
* This file has been generated automatically from *
48+
* *
49+
* src/server/qgsbufferserverrequest.h *
50+
* *
51+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
52+
************************************************************************/
+153
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/server/qgsbufferserverresponse.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsBufferServerResponse: QgsServerResponse
13+
{
14+
%Docstring
15+
Class defining buffered response
16+
%End
17+
18+
%TypeHeaderCode
19+
#include "qgsbufferserverresponse.h"
20+
%End
21+
public:
22+
23+
QgsBufferServerResponse();
24+
~QgsBufferServerResponse();
25+
26+
27+
virtual void setHeader( const QString &key, const QString &value );
28+
29+
%Docstring
30+
Set Header entry
31+
Add Header entry to the response
32+
Note that it is usually an error to set Header after data have been sent through the wire
33+
%End
34+
35+
virtual void removeHeader( const QString &key );
36+
37+
%Docstring
38+
Clear header
39+
Undo a previous 'setHeader' call
40+
%End
41+
42+
virtual QString header( const QString &key ) const;
43+
44+
%Docstring
45+
Return the header value
46+
:rtype: str
47+
%End
48+
49+
virtual QMap<QString, QString> headers() const;
50+
%Docstring
51+
Return all the headers
52+
:rtype: QMap<str, QString>
53+
%End
54+
55+
virtual bool headersSent() const;
56+
57+
%Docstring
58+
Return true if the headers have alredy been sent
59+
:rtype: bool
60+
%End
61+
62+
virtual void setStatusCode( int code );
63+
64+
%Docstring
65+
Set the http status code
66+
\param code HTTP status code value
67+
%End
68+
69+
virtual int statusCode( ) const;
70+
%Docstring
71+
Return the http status code
72+
:rtype: int
73+
%End
74+
75+
virtual void sendError( int code, const QString &message );
76+
77+
%Docstring
78+
Send error
79+
This method delegates error handling at the server level. This is different
80+
from calling setReturnCode() which let you return a specific response body.
81+
Calling sendError() will end the transaction and any attempt to write data
82+
or set headers will be an error.
83+
\param code HHTP return code value
84+
\param message An informative error message
85+
%End
86+
87+
virtual QIODevice *io();
88+
89+
%Docstring
90+
Return the underlying QIODevice
91+
:rtype: QIODevice
92+
%End
93+
94+
virtual void finish();
95+
96+
%Docstring
97+
Finish the response, ending the transaction
98+
%End
99+
100+
virtual void flush();
101+
102+
%Docstring
103+
Flushes the current output buffer to the network
104+
105+
'flush()' may be called multiple times. For HTTP transactions
106+
headers will be written on the first call to 'flush()'.
107+
%End
108+
109+
virtual void clear();
110+
111+
%Docstring
112+
Reset all headers and content for this response
113+
%End
114+
115+
virtual QByteArray data() const;
116+
117+
%Docstring
118+
Get the data written so far
119+
120+
This is implementation dependent: some implementations may not
121+
give access to the underlying and return an empty array.
122+
123+
Note that each call to 'flush' may empty the buffer and in case
124+
of streaming process you may get partial content
125+
:rtype: QByteArray
126+
%End
127+
128+
virtual void truncate();
129+
130+
%Docstring
131+
Truncate data
132+
133+
Clear internal buffer
134+
%End
135+
136+
QByteArray body() const;
137+
%Docstring
138+
Return body
139+
:rtype: QByteArray
140+
%End
141+
142+
143+
private:
144+
QgsBufferServerResponse( const QgsBufferServerResponse & ) ;
145+
};
146+
147+
/************************************************************************
148+
* This file has been generated automatically from *
149+
* *
150+
* src/server/qgsbufferserverresponse.h *
151+
* *
152+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
153+
************************************************************************/

python/server/qgsrequesthandler.sip

+22-10
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,29 @@ class QgsRequestHandler /Abstract/
2929
/** Allow plugins to return a QgsServerException*/
3030
void setServiceException( const QgsServerException &ex );
3131

32-
/** Set an HTTP header*/
33-
void setHeader( const QString &name, const QString &value );
32+
//! Set an HTTP response header
33+
void setResponseHeader( const QString &name, const QString &value );
3434

35-
//! Retrieve header value
36-
QString header( const QString &name ) const;
35+
//! Remove an HTTP response header
36+
void removeResponseHeader( const QString &name );
3737

38-
//! Return the list of all header keys
39-
QList<QString> headerKeys() const;
38+
//! Retrieve response header value
39+
QString responseHeader( const QString &name ) const;
4040

41-
/** Remove an HTTP header*/
42-
void removeHeader( const QString &name );
41+
//! Return the response headers
42+
QMap<QString, QString> responseHeaders() const;
4343

44-
/** Delete all HTTP headers*/
45-
void clear();
44+
//! Set an HTTP request header
45+
void setRequestHeader( const QString &name, const QString &value );
46+
47+
//! Remove an HTTP request header
48+
void removeRequestHeader( const QString &name );
49+
50+
//! Retrieve request header value
51+
QString requestHeader( const QString &name ) const;
52+
53+
//! Return the Request headers
54+
QMap<QString, QString> requestHeaders() const;
4655

4756
/** Append the bytestream to response body*/
4857
void appendBody( const QByteArray &body );
@@ -62,6 +71,9 @@ class QgsRequestHandler /Abstract/
6271
/** Clear response buffer */
6372
void clearBody();
6473

74+
//! Clears the response body and headers
75+
void clear();
76+
6577
/** Return body data */
6678
QByteArray body() const;
6779

0 commit comments

Comments
 (0)