Skip to content

Commit

Permalink
Http request/response handler refactoring.
Browse files Browse the repository at this point in the history
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 Nov 26, 2014
1 parent f00db95 commit 2bb7f19
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
36 changes: 36 additions & 0 deletions src/mapserver/qgis_map_serv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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();
Expand All @@ -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() );

Expand Down Expand Up @@ -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 )
Expand Down
1 change: 0 additions & 1 deletion src/mapserver/qgsrequesthandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down

0 comments on commit 2bb7f19

Please sign in to comment.