Skip to content

Commit 2bb7f19

Browse files
committed
Http request/response handler refactoring.
HTTP Request handler now manages HTTP request and response. * added methods to manage HTTP response headers * added methods to manage response body * added accessors API methods for request parameters and response headers and body
1 parent f00db95 commit 2bb7f19

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

src/mapserver/qgis_map_serv.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@
3737
#include "qgsnetworkaccessmanager.h"
3838
#include "qgsmaplayerregistry.h"
3939
#include "qgsserverlogger.h"
40+
#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
41+
#include "qgsserverplugins.h"
42+
#include "qgsserverfilter.h"
43+
#include "qgsserverinterfaceimpl.h"
44+
#endif
4045

4146
#include <QDomDocument>
4247
#include <QNetworkDiskCache>
@@ -315,6 +320,18 @@ int main( int argc, char * argv[] )
315320
int logLevel = QgsServerLogger::instance()->logLevel();
316321
QTime time; //used for measuring request time if loglevel < 1
317322

323+
#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
324+
// Create the interface
325+
QgsServerInterfaceImpl serverIface( &capabilitiesCache );
326+
// Init plugins
327+
if (! QgsServerPlugins::initPlugins( &serverIface ) )
328+
{
329+
QgsMessageLog::logMessage( "No server plugins are available", "Server", QgsMessageLog::INFO );
330+
}
331+
// Store plugin filters for faster access
332+
QMultiMap<int, QgsServerFilter*> pluginFilters = serverIface.filters();
333+
#endif
334+
318335
while ( fcgi_accept() >= 0 )
319336
{
320337
QgsMapLayerRegistry::instance()->removeAllMapLayers();
@@ -340,6 +357,17 @@ int main( int argc, char * argv[] )
340357
theRequestHandler->setServiceException( e );
341358
}
342359

360+
#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
361+
// Set the request handler into the interface for plugins to manipulate it
362+
serverIface.setRequestHandler( theRequestHandler.data() );
363+
// Iterate filters and call their requestReady() method
364+
QgsServerFiltersMap::const_iterator filtersIterator;
365+
for( filtersIterator = pluginFilters.constBegin(); filtersIterator != pluginFilters.constEnd(); ++filtersIterator)
366+
{
367+
filtersIterator.value()->requestReady();
368+
}
369+
#endif
370+
343371
// Copy the parameters map
344372
QMap<QString, QString> parameterMap( theRequestHandler->parameterMap() );
345373

@@ -398,6 +426,14 @@ int main( int argc, char * argv[] )
398426
} // end switch
399427
} // end if not exception raised
400428

429+
#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
430+
// Call responseReady plugin filters
431+
for(filtersIterator = pluginFilters.constBegin(); filtersIterator != pluginFilters.constEnd(); ++filtersIterator)
432+
{
433+
filtersIterator.value()->responseReady();
434+
}
435+
#endif
436+
401437
theRequestHandler->sendResponse();
402438

403439
if ( logLevel < 1 )

src/mapserver/qgsrequesthandler.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ class QgsRequestHandler
6565
virtual void setInfoFormat( const QString &format ) = 0;
6666
/**Send out HTTP headers and flush output buffer*/
6767
virtual void sendResponse( ) = 0;
68-
virtual bool responseReady() const = 0;
6968
/**Pointer to last raised exception*/
7069
virtual bool exceptionRaised() const = 0;
7170
QMap<QString, QString> parameterMap( ) { return mParameterMap; }

0 commit comments

Comments
 (0)