Skip to content
Permalink
Browse files

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
  • Loading branch information
elpaso committed Oct 9, 2014
1 parent f00db95 commit 2bb7f1963879d5cbc02689f862839007868067d8
Showing with 36 additions and 1 deletion.
  1. +36 −0 src/mapserver/qgis_map_serv.cpp
  2. +0 −1 src/mapserver/qgsrequesthandler.h
@@ -37,6 +37,11 @@
#include "qgsnetworkaccessmanager.h"
#include "qgsmaplayerregistry.h"
#include "qgsserverlogger.h"
#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
#include "qgsserverplugins.h"
#include "qgsserverfilter.h"
#include "qgsserverinterfaceimpl.h"
#endif

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

#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
// Create the interface
QgsServerInterfaceImpl serverIface( &capabilitiesCache );
// Init plugins
if (! QgsServerPlugins::initPlugins( &serverIface ) )
{
QgsMessageLog::logMessage( "No server plugins are available", "Server", QgsMessageLog::INFO );
}
// Store plugin filters for faster access
QMultiMap<int, QgsServerFilter*> pluginFilters = serverIface.filters();
#endif

while ( fcgi_accept() >= 0 )
{
QgsMapLayerRegistry::instance()->removeAllMapLayers();
@@ -340,6 +357,17 @@ int main( int argc, char * argv[] )
theRequestHandler->setServiceException( e );
}

#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
// Set the request handler into the interface for plugins to manipulate it
serverIface.setRequestHandler( theRequestHandler.data() );
// Iterate filters and call their requestReady() method
QgsServerFiltersMap::const_iterator filtersIterator;
for( filtersIterator = pluginFilters.constBegin(); filtersIterator != pluginFilters.constEnd(); ++filtersIterator)
{
filtersIterator.value()->requestReady();
}
#endif

// Copy the parameters map
QMap<QString, QString> parameterMap( theRequestHandler->parameterMap() );

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

#ifdef MAPSERVER_HAVE_PYTHON_PLUGINS
// Call responseReady plugin filters
for(filtersIterator = pluginFilters.constBegin(); filtersIterator != pluginFilters.constEnd(); ++filtersIterator)
{
filtersIterator.value()->responseReady();
}
#endif

theRequestHandler->sendResponse();

if ( logLevel < 1 )
@@ -65,7 +65,6 @@ class QgsRequestHandler
virtual void setInfoFormat( const QString &format ) = 0;
/**Send out HTTP headers and flush output buffer*/
virtual void sendResponse( ) = 0;
virtual bool responseReady() const = 0;
/**Pointer to last raised exception*/
virtual bool exceptionRaised() const = 0;
QMap<QString, QString> parameterMap( ) { return mParameterMap; }

0 comments on commit 2bb7f19

Please sign in to comment.
You can’t perform that action at this time.