Skip to content

Commit 156a0fa

Browse files
committedNov 4, 2014
Merge pull request #1671 from elpaso/requesthandler-refactoring2
Requesthandler refactoring2
2 parents 1d3f8a7 + a4fb2a1 commit 156a0fa

17 files changed

+462
-279
lines changed
 

‎src/mapserver/qgis_map_serv.cpp

Lines changed: 54 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
* *
1717
***************************************************************************/
1818

19+
//for CMAKE_INSTALL_PREFIX
20+
#include "qgsconfig.h"
21+
1922
#include "qgsapplication.h"
2023
#include "qgscapabilitiescache.h"
2124
#include "qgsconfigcache.h"
@@ -42,9 +45,6 @@
4245
#include <QDateTime>
4346
#include <QScopedPointer>
4447

45-
//for CMAKE_INSTALL_PREFIX
46-
#include "qgsconfig.h"
47-
4848
#include <fcgi_stdio.h>
4949

5050

@@ -281,6 +281,7 @@ int main( int argc, char * argv[] )
281281
QgsDebugMsg( "User DB PATH: " + QgsApplication::qgisUserDbFilePath() );
282282
QgsDebugMsg( "SVG PATHS: " + QgsApplication::svgPaths().join( ":" ) );
283283

284+
// FIXME: what is this debug line for?
284285
QgsDebugMsg( qgsapp.applicationDirPath() + "/qgis_wms_server.log" );
285286
QgsApplication::createDB(); //init qgis.db (e.g. necessary for user crs)
286287

@@ -327,78 +328,82 @@ int main( int argc, char * argv[] )
327328

328329
//Request handler
329330
QScopedPointer<QgsRequestHandler> theRequestHandler( createRequestHandler() );
330-
QMap<QString, QString> parameterMap;
331+
331332
try
332333
{
333-
parameterMap = theRequestHandler->parseInput();
334+
// TODO: split parse input into plain parse and processing from specific services
335+
theRequestHandler->parseInput();
334336
}
335337
catch ( QgsMapServiceException& e )
336338
{
337339
QgsMessageLog::logMessage( "Parse input exception: " + e.message(), "Server", QgsMessageLog::CRITICAL );
338-
theRequestHandler->sendServiceException( e );
339-
continue;
340+
theRequestHandler->setServiceException( e );
340341
}
341342

343+
// Copy the parameters map
344+
QMap<QString, QString> parameterMap( theRequestHandler->parameterMap() );
345+
342346
printRequestParameters( parameterMap, logLevel );
343347
QMap<QString, QString>::const_iterator paramIt;
344-
345348
//Config file path
346349
QString configFilePath = configPath( defaultConfigFilePath, parameterMap );
347-
348350
//Service parameter
349-
QString serviceString;
350-
paramIt = parameterMap.find( "SERVICE" );
351-
if ( paramIt == parameterMap.constEnd() )
352-
{
353-
QgsMessageLog::logMessage( "Exception: SERVICE parameter is missing", "Server", QgsMessageLog::CRITICAL );
354-
theRequestHandler->sendServiceException( QgsMapServiceException( "ServiceNotSpecified", "Service not specified. The SERVICE parameter is mandatory" ) );
355-
continue;
356-
}
357-
else
358-
{
359-
serviceString = paramIt.value();
360-
}
351+
QString serviceString = theRequestHandler->parameter( "SERVICE" );
361352

362-
if ( serviceString == "WCS" )
353+
// Enter core services main switch
354+
if ( !theRequestHandler->exceptionRaised() )
363355
{
364-
QgsWCSProjectParser* p = QgsConfigCache::instance()->wcsConfiguration( configFilePath );
365-
if ( !p )
356+
if ( serviceString == "WCS" )
366357
{
367-
theRequestHandler->sendServiceException( QgsMapServiceException( "Project file error", "Error reading the project file" ) );
368-
continue;
358+
QgsWCSProjectParser* p = QgsConfigCache::instance()->wcsConfiguration( configFilePath );
359+
if ( !p )
360+
{
361+
theRequestHandler->setServiceException( QgsMapServiceException( "Project file error", "Error reading the project file" ) );
362+
}
363+
else
364+
{
365+
QgsWCSServer wcsServer( configFilePath, parameterMap, p, theRequestHandler.data() );
366+
wcsServer.executeRequest();
367+
}
369368
}
370-
QgsWCSServer wcsServer( configFilePath, parameterMap, p, theRequestHandler.take() );
371-
wcsServer.executeRequest();
372-
}
373-
else if ( serviceString == "WFS" )
374-
{
375-
QgsWFSProjectParser* p = QgsConfigCache::instance()->wfsConfiguration( configFilePath );
376-
if ( !p )
369+
else if ( serviceString == "WFS" )
377370
{
378-
theRequestHandler->sendServiceException( QgsMapServiceException( "Project file error", "Error reading the project file" ) );
379-
continue;
371+
QgsWFSProjectParser* p = QgsConfigCache::instance()->wfsConfiguration( configFilePath );
372+
if ( !p )
373+
{
374+
theRequestHandler->setServiceException( QgsMapServiceException( "Project file error", "Error reading the project file" ) );
375+
}
376+
else
377+
{
378+
QgsWFSServer wfsServer( configFilePath, parameterMap, p, theRequestHandler.data() );
379+
wfsServer.executeRequest();
380+
}
380381
}
381-
QgsWFSServer wfsServer( configFilePath, parameterMap, p, theRequestHandler.take() );
382-
wfsServer.executeRequest();
383-
}
384-
else //WMS else
385-
{
386-
QgsWMSConfigParser* p = QgsConfigCache::instance()->wmsConfiguration( configFilePath, parameterMap );
387-
if ( !p )
382+
else if ( serviceString == "WMS" )
388383
{
389-
theRequestHandler->sendServiceException( QgsMapServiceException( "WMS configuration error", "There was an error reading the project file or the SLD configuration" ) );
390-
continue;
384+
QgsWMSConfigParser* p = QgsConfigCache::instance()->wmsConfiguration( configFilePath, parameterMap );
385+
if ( !p )
386+
{
387+
theRequestHandler->setServiceException( QgsMapServiceException( "WMS configuration error", "There was an error reading the project file or the SLD configuration" ) );
388+
}
389+
else
390+
{
391+
QgsWMSServer wmsServer( configFilePath, parameterMap, p, theRequestHandler.data() , theMapRenderer.data(), &capabilitiesCache );
392+
wmsServer.executeRequest();
393+
}
391394
}
392-
QgsWMSServer wmsServer( configFilePath, parameterMap, p, theRequestHandler.take(), theMapRenderer.data(), &capabilitiesCache );
393-
wmsServer.executeRequest();
394-
}
395+
else
396+
{
397+
theRequestHandler->setServiceException( QgsMapServiceException( "Service configuration error", "Service unknown or unsupported" ) );
398+
} // end switch
399+
} // end if not exception raised
400+
401+
theRequestHandler->sendResponse();
395402

396403
if ( logLevel < 1 )
397404
{
398405
QgsMessageLog::logMessage( "Request finished in " + QString::number( time.elapsed() ) + " ms", "Server", QgsMessageLog::INFO );
399406
}
400407
}
401-
402408
return 0;
403409
}
404-

‎src/mapserver/qgsgetrequesthandler.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ QgsGetRequestHandler::QgsGetRequestHandler()
2424
{
2525
}
2626

27-
QMap<QString, QString> QgsGetRequestHandler::parseInput()
27+
void QgsGetRequestHandler::parseInput()
2828
{
2929
QString queryString;
30-
QMap<QString, QString> parameters;
3130

3231
const char* qs = getenv( "QUERY_STRING" );
3332
if ( qs )
@@ -38,9 +37,8 @@ QMap<QString, QString> QgsGetRequestHandler::parseInput()
3837
else
3938
{
4039
QgsDebugMsg( "error, no query string found" );
41-
return parameters; //no query string? something must be wrong...
40+
return; //no query string? something must be wrong...
4241
}
4342

44-
requestStringToParameterMap( queryString, parameters );
45-
return parameters;
43+
requestStringToParameterMap( queryString, mParameterMap );
4644
}

‎src/mapserver/qgsgetrequesthandler.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,15 @@
1818

1919
#include "qgshttprequesthandler.h"
2020

21+
#ifndef QGSGETPREQUESTHANDLER_H
22+
#define QGSGETPREQUESTHANDLER_H
23+
24+
2125
class QgsGetRequestHandler: public QgsHttpRequestHandler
2226
{
2327
public:
2428
QgsGetRequestHandler();
25-
QMap<QString, QString> parseInput();
29+
void parseInput();
2630
};
31+
32+
#endif

‎src/mapserver/qgshttprequesthandler.cpp

Lines changed: 165 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
-------------------------
44
begin : June 29, 2007
55
copyright : (C) 2007 by Marco Hugentobler
6+
(C) 2014 by Alessandro Pasotti
67
email : marco dot hugentobler at karto dot baug dot ethz dot ch
8+
a dot pasotti at itopen dot it
79
***************************************************************************/
810

911
/***************************************************************************
@@ -30,19 +32,21 @@
3032
#include <QUrl>
3133
#include <fcgi_stdio.h>
3234

33-
QgsHttpRequestHandler::QgsHttpRequestHandler(): QgsRequestHandler()
34-
{
35-
35+
QgsHttpRequestHandler::QgsHttpRequestHandler():
36+
QgsRequestHandler()
37+
{
38+
mException = NULL;
39+
mHeadersSent = FALSE;
3640
}
3741

3842
QgsHttpRequestHandler::~QgsHttpRequestHandler()
3943
{
4044

4145
}
4246

43-
void QgsHttpRequestHandler::sendHttpResponse( QByteArray* ba, const QString& format ) const
47+
void QgsHttpRequestHandler::setHttpResponse( QByteArray *ba, const QString &format )
4448
{
45-
QgsDebugMsg( "Checking byte array is ok to send..." );
49+
QgsDebugMsg( "Checking byte array is ok to set..." );
4650
if ( !ba )
4751
{
4852
return;
@@ -52,23 +56,114 @@ void QgsHttpRequestHandler::sendHttpResponse( QByteArray* ba, const QString& for
5256
{
5357
return;
5458
}
59+
QgsDebugMsg( "Byte array looks good, setting response..." );
5560

56-
QgsDebugMsg( "Byte array looks good, returning response..." );
57-
QgsDebugMsg( QString( "Content size: %1" ).arg( ba->size() ) );
58-
QgsDebugMsg( QString( "Content format: %1" ).arg( format ) );
59-
printf( "Content-Type: " );
60-
printf( format.toLocal8Bit() );
61-
printf( "\n" );
62-
printf( "Content-Length: %d\n", ba->size() );
61+
appendBody( *ba );
62+
mInfoFormat = format;
63+
}
64+
65+
bool QgsHttpRequestHandler::responseReady() const
66+
{
67+
return mHeaders.count() || ( mBody.size() && mInfoFormat.length() );
68+
}
69+
70+
bool QgsHttpRequestHandler::exceptionRaised() const
71+
{
72+
return mException != NULL;
73+
}
74+
75+
void QgsHttpRequestHandler::setHeader( const QString &name, const QString &value )
76+
{
77+
mHeaders.insert( name, value);
78+
}
79+
80+
81+
void QgsHttpRequestHandler::clearHeaders( )
82+
{
83+
mHeaders.clear();
84+
}
85+
86+
int QgsHttpRequestHandler::removeHeader( const QString &name )
87+
{
88+
return mHeaders.remove( name );
89+
}
90+
91+
void QgsHttpRequestHandler::appendBody( const QByteArray &body)
92+
{
93+
mBody.append( body );
94+
}
95+
96+
void QgsHttpRequestHandler::clearBody( )
97+
{
98+
mBody.clear();
99+
}
100+
101+
102+
void QgsHttpRequestHandler::setInfoFormat( const QString &format )
103+
{
104+
mInfoFormat = format;
105+
}
106+
107+
void QgsHttpRequestHandler::sendHeaders()
108+
{
109+
// Send default headers if they've not been set in a previous stage
110+
if ( mHeaders.empty() )
111+
{
112+
QgsDebugMsg( QString( "Content size: %1" ).arg( mBody.size() ) );
113+
QgsDebugMsg( QString( "Content format: %1" ).arg( mInfoFormat ) );
114+
printf( "Content-Type: " );
115+
printf( mInfoFormat.toLocal8Bit() );
116+
printf( "\n" );
117+
// size is not known when streaming
118+
if ( mBody.size() > 0)
119+
{
120+
printf( "Content-Length: %d\n", mBody.size() );
121+
}
122+
}
123+
else
124+
{
125+
QMap<QString, QString>::const_iterator it;
126+
for ( it = mHeaders.constBegin(); it != mHeaders.constEnd(); ++it )
127+
{
128+
printf ( it.key().toLocal8Bit() );
129+
printf ( ": " );
130+
printf ( it.value().toLocal8Bit() );
131+
printf ( "\n" );
132+
}
133+
printf( "\n" );
134+
}
63135
printf( "\n" );
64-
size_t result = fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
136+
mHeadersSent = TRUE;
137+
}
138+
139+
void QgsHttpRequestHandler::sendBody() const
140+
{
141+
fwrite( (void*)mBody.data(), mBody.size(), 1, FCGI_stdout );
65142
#ifdef QGISDEBUG
66-
QgsDebugMsg( QString( "Sent %1 bytes" ).arg( result ) );
143+
QgsDebugMsg( QString( "Sent %1 bytes" ).arg( mBody.size() ) );
67144
#else
68145
Q_UNUSED( result );
69146
#endif
70147
}
71148

149+
void QgsHttpRequestHandler::sendResponse()
150+
{
151+
QgsDebugMsg( QString( "Sending HTTP response" ) );
152+
if ( ! responseReady() )
153+
{
154+
QgsDebugMsg( QString( "Trying to send out an empty reponse" ) );
155+
return;
156+
}
157+
if (! mHeadersSent )
158+
{
159+
sendHeaders();
160+
}
161+
sendBody();
162+
//Clear the body to allow for streaming content to stdout
163+
clearBody();
164+
}
165+
166+
72167
QString QgsHttpRequestHandler::formatToMimeType( const QString& format ) const
73168
{
74169
if ( format.compare( "png", Qt::CaseInsensitive ) == 0 )
@@ -90,10 +185,10 @@ QString QgsHttpRequestHandler::formatToMimeType( const QString& format ) const
90185
return format;
91186
}
92187

93-
void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage* img, int imageQuality = -1 ) const
188+
void QgsHttpRequestHandler::setGetMapResponse( const QString& service, QImage* img, int imageQuality = -1 )
94189
{
95190
Q_UNUSED( service );
96-
QgsDebugMsg( "Sending getmap response..." );
191+
QgsDebugMsg( "setting getmap response..." );
97192
if ( img )
98193
{
99194
bool png16Bit = ( mFormatString.compare( "image/png; mode=16bit", Qt::CaseInsensitive ) == 0 );
@@ -103,11 +198,11 @@ void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage*
103198
if ( mFormat != "PNG" && mFormat != "JPG" && !png16Bit && !png8Bit && !png1Bit )
104199
{
105200
QgsDebugMsg( "service exception - incorrect image format requested..." );
106-
sendServiceException( QgsMapServiceException( "InvalidFormat", "Output format '" + mFormatString + "' is not supported in the GetMap request" ) );
201+
setServiceException( QgsMapServiceException( "InvalidFormat", "Output format '" + mFormatString + "' is not supported in the GetMap request" ) );
107202
return;
108203
}
109204

110-
//store the image in a QByteArray and send it directly
205+
//store the image in a QByteArray and set it directly
111206
QByteArray ba;
112207
QBuffer buffer( &ba );
113208
buffer.open( QIODevice::WriteOnly );
@@ -147,24 +242,23 @@ void QgsHttpRequestHandler::sendGetMapResponse( const QString& service, QImage*
147242
{
148243
ba = ba.toBase64();
149244
}
150-
151-
sendHttpResponse( &ba, formatToMimeType( mFormat ) );
245+
setHttpResponse( &ba, formatToMimeType( mFormat ) );
152246
}
153247
}
154248

155-
void QgsHttpRequestHandler::sendGetCapabilitiesResponse( const QDomDocument& doc ) const
249+
void QgsHttpRequestHandler::setGetCapabilitiesResponse( const QDomDocument& doc )
156250
{
157251
QByteArray ba = doc.toByteArray();
158-
sendHttpResponse( &ba, "text/xml" );
252+
setHttpResponse( &ba, "text/xml" );
159253
}
160254

161-
void QgsHttpRequestHandler::sendGetStyleResponse( const QDomDocument& doc ) const
255+
void QgsHttpRequestHandler::setGetStyleResponse( const QDomDocument& doc )
162256
{
163257
QByteArray ba = doc.toByteArray();
164-
sendHttpResponse( &ba, "text/xml" );
258+
setHttpResponse( &ba, "text/xml" );
165259
}
166260

167-
void QgsHttpRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) const
261+
void QgsHttpRequestHandler::setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat )
168262
{
169263
QByteArray ba;
170264
QgsDebugMsg( "Info format is:" + infoFormat );
@@ -283,17 +377,18 @@ void QgsHttpRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& info
283377
}
284378
ba = featureInfoString.toUtf8();
285379
}
286-
else //unsupported format, send exception
380+
else //unsupported format, set exception
287381
{
288-
sendServiceException( QgsMapServiceException( "InvalidFormat", "Feature info format '" + mFormat + "' is not supported. Possibilities are 'text/plain', 'text/html' or 'text/xml'." ) );
382+
setServiceException( QgsMapServiceException( "InvalidFormat", "Feature info format '" + mFormat + "' is not supported. Possibilities are 'text/plain', 'text/html' or 'text/xml'." ) );
289383
return;
290384
}
291385

292-
sendHttpResponse( &ba, infoFormat );
386+
setHttpResponse( &ba, infoFormat );
293387
}
294388

295-
void QgsHttpRequestHandler::sendServiceException( const QgsMapServiceException& ex ) const
389+
void QgsHttpRequestHandler::setServiceException(QgsMapServiceException ex )
296390
{
391+
mException = &ex;
297392
//create Exception DOM document
298393
QDomDocument exceptionDoc;
299394
QDomElement serviceExceptionReportElem = exceptionDoc.createElement( "ServiceExceptionReport" );
@@ -307,19 +402,20 @@ void QgsHttpRequestHandler::sendServiceException( const QgsMapServiceException&
307402
serviceExceptionReportElem.appendChild( serviceExceptionElem );
308403

309404
QByteArray ba = exceptionDoc.toByteArray();
310-
sendHttpResponse( &ba, "text/xml" );
405+
setHttpResponse( &ba, "text/xml" );
311406
}
312407

313-
void QgsHttpRequestHandler::sendGetPrintResponse( QByteArray* ba ) const
408+
void QgsHttpRequestHandler::setGetPrintResponse( QByteArray* ba )
314409
{
315410
if ( mFormatString.endsWith( ";base64", Qt::CaseInsensitive ) )
316411
{
317412
*ba = ba->toBase64();
318413
}
319-
sendHttpResponse( ba, formatToMimeType( mFormat ) );
414+
setHttpResponse( ba, formatToMimeType( mFormat ) );
320415
}
321416

322-
bool QgsHttpRequestHandler::startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) const
417+
418+
bool QgsHttpRequestHandler::startGetFeatureResponse( QByteArray* ba, const QString& infoFormat )
323419
{
324420
if ( !ba )
325421
{
@@ -337,15 +433,14 @@ bool QgsHttpRequestHandler::startGetFeatureResponse( QByteArray* ba, const QStri
337433
else
338434
format = "text/xml";
339435

340-
printf( "Content-Type: " );
341-
printf( format.toLocal8Bit() );
342-
printf( "\n" );
343-
printf( "\n" );
344-
fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
436+
setHeader( "Content-Type", format );
437+
appendBody( *ba );
438+
// Streaming
439+
sendResponse();
345440
return true;
346441
}
347442

348-
void QgsHttpRequestHandler::sendGetFeatureResponse( QByteArray* ba ) const
443+
void QgsHttpRequestHandler::setGetFeatureResponse( QByteArray* ba )
349444
{
350445
if ( !ba )
351446
{
@@ -356,22 +451,25 @@ void QgsHttpRequestHandler::sendGetFeatureResponse( QByteArray* ba ) const
356451
{
357452
return;
358453
}
359-
fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
454+
appendBody( *ba );
455+
// Streaming
456+
sendResponse();
360457
}
361458

362-
void QgsHttpRequestHandler::endGetFeatureResponse( QByteArray* ba ) const
459+
void QgsHttpRequestHandler::endGetFeatureResponse( QByteArray* ba )
363460
{
364461
if ( !ba )
365462
{
366463
return;
367464
}
368-
369-
fwrite( ba->data(), ba->size(), 1, FCGI_stdout );
465+
appendBody( *ba );
466+
// Streaming
467+
sendResponse();
370468
}
371469

372-
void QgsHttpRequestHandler::sendGetCoverageResponse( QByteArray* ba ) const
470+
void QgsHttpRequestHandler::setGetCoverageResponse( QByteArray* ba )
373471
{
374-
sendHttpResponse( ba, "image/tiff" );
472+
setHttpResponse( ba, "image/tiff" );
375473
}
376474

377475
void QgsHttpRequestHandler::requestStringToParameterMap( const QString& request, QMap<QString, QString>& parameters )
@@ -510,6 +608,26 @@ QString QgsHttpRequestHandler::readPostBody() const
510608
return inputString;
511609
}
512610

611+
void QgsHttpRequestHandler::setParameter(const QString &key, const QString &value)
612+
{
613+
if(! ( key.isEmpty() || value.isEmpty() ) )
614+
{
615+
mParameterMap.insert(key, value);
616+
}
617+
}
618+
619+
620+
QString QgsHttpRequestHandler::parameter(const QString &key) const
621+
{
622+
return mParameterMap.value(key);
623+
}
624+
625+
int QgsHttpRequestHandler::removeParameter(const QString &key)
626+
{
627+
return mParameterMap.remove(key);
628+
}
629+
630+
513631
void QgsHttpRequestHandler::medianCut( QVector<QRgb>& colorTable, int nColors, const QImage& inputImage )
514632
{
515633
QHash<QRgb, int> inputColors;
@@ -798,3 +916,5 @@ QRgb QgsHttpRequestHandler::boxColor( const QgsColorBox& box, int boxPixels )
798916

799917
return qRgba( avRed, avGreen, avBlue, avAlpha );
800918
}
919+
920+

‎src/mapserver/qgshttprequesthandler.h

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
-----------------------
44
begin : June 29, 2007
55
copyright : (C) 2007 by Marco Hugentobler
6+
(C) 2014 by Alessandro Pasotti
67
email : marco dot hugentobler at karto dot baug dot ethz dot ch
8+
a dot pasotti at itopen dot it
79
***************************************************************************/
810

911
/***************************************************************************
@@ -26,26 +28,41 @@ typedef QList< QPair<QRgb, int> > QgsColorBox; //Color / number of pixels
2628
typedef QMultiMap< int, QgsColorBox > QgsColorBoxMap; // sum of pixels / color box
2729

2830
/**Base class for request handler using HTTP.
29-
It provides a method to send data to the client*/
31+
It provides a method to set data to the client*/
3032
class QgsHttpRequestHandler: public QgsRequestHandler
3133
{
3234
public:
3335
QgsHttpRequestHandler();
3436
~QgsHttpRequestHandler();
3537

36-
virtual void sendGetMapResponse( const QString& service, QImage* img, int imageQuality ) const;
37-
virtual void sendGetCapabilitiesResponse( const QDomDocument& doc ) const;
38-
virtual void sendGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) const;
39-
virtual void sendServiceException( const QgsMapServiceException& ex ) const;
40-
virtual void sendGetStyleResponse( const QDomDocument& doc ) const;
41-
virtual void sendGetPrintResponse( QByteArray* ba ) const;
42-
virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) const;
43-
virtual void sendGetFeatureResponse( QByteArray* ba ) const;
44-
virtual void endGetFeatureResponse( QByteArray* ba ) const;
45-
virtual void sendGetCoverageResponse( QByteArray* ba ) const;
38+
virtual void setGetMapResponse( const QString& service, QImage* img, int imageQuality );
39+
virtual void setGetCapabilitiesResponse( const QDomDocument& doc );
40+
virtual void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat );
41+
virtual void setServiceException( QgsMapServiceException ex );
42+
virtual void setGetStyleResponse( const QDomDocument& doc );
43+
virtual void setGetPrintResponse( QByteArray* ba );
44+
virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat );
45+
virtual void setGetFeatureResponse( QByteArray* ba );
46+
virtual void endGetFeatureResponse( QByteArray* ba );
47+
virtual void setGetCoverageResponse( QByteArray* ba );
48+
/**Send out HTTP headers and flush output buffer*/
49+
virtual void sendResponse();
50+
virtual void setHeader( const QString &name, const QString &value );
51+
virtual int removeHeader( const QString &name );
52+
virtual void clearHeaders( );
53+
virtual void appendBody( const QByteArray &body);
54+
virtual void clearBody( );
55+
virtual void setInfoFormat( const QString &format );
56+
virtual bool responseReady() const;
57+
virtual bool exceptionRaised() const;
58+
virtual void setParameter(const QString &key, const QString &value);
59+
virtual QString parameter(const QString &key) const;
60+
virtual int removeParameter(const QString &key);
4661

4762
protected:
48-
void sendHttpResponse( QByteArray* ba, const QString& format ) const;
63+
virtual void sendHeaders( );
64+
virtual void sendBody( ) const;
65+
void setHttpResponse(QByteArray *ba, const QString &format );
4966
/**Converts format to official mimetype (e.g. 'jpg' to 'image/jpeg')
5067
@return mime string (or the entered string if not found)*/
5168
QString formatToMimeType( const QString& format ) const;
@@ -55,6 +72,7 @@ class QgsHttpRequestHandler: public QgsRequestHandler
5572
QString readPostBody() const;
5673

5774
private:
75+
QByteArray mBody; // The response payload
5876
static void medianCut( QVector<QRgb>& colorTable, int nColors, const QImage& inputImage );
5977
static void imageColors( QHash<QRgb, int>& colors, const QImage& image );
6078
static void splitColorBox( QgsColorBox& colorBox, QgsColorBoxMap& colorBoxMap,
@@ -65,7 +83,7 @@ class QgsHttpRequestHandler: public QgsRequestHandler
6583
static bool blueCompare( const QPair<QRgb, int>& c1, const QPair<QRgb, int>& c2 );
6684
static bool alphaCompare( const QPair<QRgb, int>& c1, const QPair<QRgb, int>& c2 );
6785
/**Calculates a representative color for a box (pixel weighted average)*/
68-
static QRgb boxColor( const QgsColorBox& box, int boxPixels );
86+
static QRgb boxColor( const QgsColorBox& box, int boxPixels );
6987
};
7088

7189
#endif

‎src/mapserver/qgsowsserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class QgsOWSServer
2525
public:
2626
QgsOWSServer( const QString& configFilePath, const QMap<QString, QString>& parameters, QgsRequestHandler* rh )
2727
: mParameters( parameters ), mRequestHandler( rh ), mConfigFilePath( configFilePath ) {}
28-
virtual ~QgsOWSServer() { delete mRequestHandler; }
28+
virtual ~QgsOWSServer() {}
2929

3030
virtual void executeRequest() = 0;
3131

‎src/mapserver/qgspostrequesthandler.cpp

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,18 +27,17 @@ QgsPostRequestHandler::~QgsPostRequestHandler()
2727
{
2828
}
2929

30-
QMap<QString, QString> QgsPostRequestHandler::parseInput()
30+
void QgsPostRequestHandler::parseInput()
3131
{
3232
QgsDebugMsg( "QgsPostRequestHandler::parseInput" );
33-
QMap<QString, QString> parameters;
3433
QString inputString = readPostBody();
3534
QgsDebugMsg( inputString );
3635

3736
QDomDocument doc;
3837
QString errorMsg;
3938
if ( !doc.setContent( inputString, true, &errorMsg ) )
4039
{
41-
requestStringToParameterMap( inputString, parameters );
40+
requestStringToParameterMap( inputString, mParameterMap);
4241
}
4342
else
4443
{
@@ -52,19 +51,17 @@ QMap<QString, QString> QgsPostRequestHandler::parseInput()
5251
else
5352
{
5453
QgsDebugMsg( "error, no query string found but a QDomDocument" );
55-
return parameters; //no query string? something must be wrong...
54+
return; //no query string? something must be wrong...
5655
}
5756

58-
requestStringToParameterMap( queryString, parameters );
57+
requestStringToParameterMap( queryString, mParameterMap);
5958

6059
QDomElement docElem = doc.documentElement();
6160
if ( docElem.hasAttribute( "version" ) )
62-
parameters.insert( "VERSION", docElem.attribute( "version" ) );
61+
mParameterMap.insert( "VERSION", docElem.attribute( "version" ) );
6362
if ( docElem.hasAttribute( "service" ) )
64-
parameters.insert( "SERVICE", docElem.attribute( "service" ) );
65-
parameters.insert( "REQUEST", docElem.tagName() );
66-
parameters.insert( "REQUEST_BODY", inputString );
63+
mParameterMap.insert( "SERVICE", docElem.attribute( "service" ) );
64+
mParameterMap.insert( "REQUEST", docElem.tagName() );
65+
mParameterMap.insert( "REQUEST_BODY", inputString );
6766
}
68-
69-
return parameters;
7067
}

‎src/mapserver/qgspostrequesthandler.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class QgsPostRequestHandler: public QgsHttpRequestHandler
2828
~QgsPostRequestHandler();
2929

3030
/**Parses the input and creates a request neutral Parameter/Value map*/
31-
QMap<QString, QString> parseInput();
31+
void parseInput();
3232
};
3333

3434
#endif // QGSPOSTREQUESTHANDLER_H

‎src/mapserver/qgsrequesthandler.h

Lines changed: 58 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1+
12
/***************************************************************************
23
qgsrequesthandler.h
34
abstraction for reading from/ writing to a request datasource
45
-------------------
56
begin : May 16, 2006
67
copyright : (C) 2006 by Marco Hugentobler
8+
(C) 2014 by Alessandro Pasotti
79
email : marco dot hugentobler at karto dot baug dot ethz dot ch
10+
a dot pasotti at itopen dot it
811
***************************************************************************/
912

1013
/***************************************************************************
@@ -16,41 +19,80 @@
1619
* *
1720
***************************************************************************/
1821

19-
#ifndef QGSWMSREQUESTHANDLER
20-
#define QGSWMSREQUESTHANDLER
22+
#ifndef QGSREQUESTHANDLER_H
23+
#define QGSREQUESTHANDLER_H
2124

2225
#include <QMap>
2326
#include <QString>
27+
#include <QStringList>
28+
2429
class QDomDocument;
25-
class QgsMapServiceException;
2630
class QImage;
31+
class QgsMapServiceException;
2732

2833
/**This class is an interface hiding the details of reading input and writing output from/to a wms request mechanism.
2934
Examples of possible mechanisms are cgi Get, cgi Post, SOAP or the usage as a standalone command line executable*/
3035
class QgsRequestHandler
3136
{
37+
3238
public:
39+
3340
QgsRequestHandler() {}
3441
virtual ~QgsRequestHandler() {}
3542
/**Parses the input and creates a request neutral Parameter/Value map*/
36-
virtual QMap<QString, QString> parseInput() = 0;
43+
virtual void parseInput() = 0;
3744
/**Sends the map image back to the client*/
38-
virtual void sendGetMapResponse( const QString& service, QImage* img, int imageQuality ) const = 0;
39-
virtual void sendGetCapabilitiesResponse( const QDomDocument& doc ) const = 0;
40-
virtual void sendGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) const = 0;
41-
virtual void sendServiceException( const QgsMapServiceException& ex ) const = 0;
42-
virtual void sendGetStyleResponse( const QDomDocument& doc ) const = 0;
43-
virtual void sendGetPrintResponse( QByteArray* ba ) const = 0;
44-
virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) const = 0;
45-
virtual void sendGetFeatureResponse( QByteArray* ba ) const = 0;
46-
virtual void endGetFeatureResponse( QByteArray* ba ) const = 0;
47-
virtual void sendGetCoverageResponse( QByteArray* ba ) const = 0;
45+
virtual void setGetMapResponse( const QString& service, QImage* img, int imageQuality ) = 0;
46+
virtual void setGetCapabilitiesResponse( const QDomDocument& doc ) = 0;
47+
virtual void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) = 0;
48+
virtual void setServiceException( QgsMapServiceException ex ) = 0;
49+
virtual void setGetStyleResponse( const QDomDocument& doc ) = 0;
50+
virtual void setGetPrintResponse( QByteArray* b ) = 0;
51+
virtual bool startGetFeatureResponse( QByteArray* ba, const QString& infoFormat ) = 0;
52+
virtual void setGetFeatureResponse( QByteArray* ba ) = 0;
53+
virtual void endGetFeatureResponse( QByteArray* ba ) = 0;
54+
virtual void setGetCoverageResponse( QByteArray* ba ) = 0;
55+
/**Set an HTTP header*/
56+
virtual void setHeader( const QString &name, const QString &value ) = 0;
57+
/**Remove an HTTP header*/
58+
virtual int removeHeader( const QString &name ) = 0;
59+
/**Delete all HTTP headers*/
60+
virtual void clearHeaders( ) = 0;
61+
/**Append the bytestream to response body*/
62+
virtual void appendBody( const QByteArray &body) = 0;
63+
/**Clears the response body*/
64+
virtual void clearBody( ) = 0;
65+
virtual void setInfoFormat( const QString &format ) = 0;
66+
/**Send out HTTP headers and flush output buffer*/
67+
virtual void sendResponse( ) = 0;
68+
virtual bool responseReady() const = 0;
69+
/**Pointer to last raised exception*/
70+
virtual bool exceptionRaised() const = 0;
71+
QMap<QString, QString> parameterMap( ) { return mParameterMap; }
72+
/**Set a request parameter*/
73+
virtual void setParameter(const QString &key, const QString &value) = 0;
74+
/**Remove a request parameter*/
75+
virtual int removeParameter(const QString &key) = 0;
76+
/**Return a request parameter*/
77+
virtual QString parameter(const QString &key) const = 0;
4878
QString format() const { return mFormat; }
49-
protected:
79+
bool headersSent() { return mHeadersSent; }
80+
81+
protected:
82+
83+
virtual void sendHeaders( ) = 0;
84+
virtual void sendBody( ) const = 0;
5085
/**This is set by the parseInput methods of the subclasses (parameter FORMAT, e.g. 'FORMAT=PNG')*/
5186
QString mFormat;
52-
QString mFormatString; //format string as it is passed in the request (with base
87+
QString mFormatString; //format string as it is passed in the request (with base)
88+
bool mHeadersSent;
5389
QString mService;
90+
QString mInfoFormat;
91+
QgsMapServiceException* mException; // Stores the exception
92+
QMap<QString, QString> mParameterMap;
93+
/** Response headers. They can be empty, in this case headers are
94+
automatically generated from the content mFormat */
95+
QMap<QString, QString> mHeaders;
5496
};
5597

5698
#endif

‎src/mapserver/qgssoaprequesthandler.cpp

Lines changed: 60 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,8 @@ QgsSOAPRequestHandler::~QgsSOAPRequestHandler()
3737

3838
}
3939

40-
QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
40+
void QgsSOAPRequestHandler::parseInput()
4141
{
42-
QMap<QString, QString> result;
4342
QString inputString = readPostBody();
4443

4544
//QgsDebugMsg("input string is: " + inputString)
@@ -54,7 +53,7 @@ QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
5453
QgsDebugMsg( "the xml string was:" );
5554
QgsDebugMsg( inputString );
5655
throw QgsMapServiceException( "InvalidXML", "XML error: " + errorMsg );
57-
return result;
56+
return;
5857
}
5958

6059
// if xml reading was successfull, save the inputXML in a file
@@ -67,15 +66,15 @@ QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
6766
{
6867
QgsDebugMsg( "Envelope element not found" );
6968
throw QgsMapServiceException( "SOAPError", "Element <Envelope> not found" );
70-
return result;
69+
return;
7170
}
7271

7372
QDomNodeList bodyNodeList = envelopeNodeList.item( 0 ).toElement().elementsByTagNameNS( "http://schemas.xmlsoap.org/soap/envelope/", "Body" );
7473
if ( bodyNodeList.size() < 1 )
7574
{
7675
QgsDebugMsg( "body node not found" );
7776
throw QgsMapServiceException( "SOAPError", "Element <Body> not found" );
78-
return result;
77+
return;
7978
}
8079
QDomElement bodyElement = bodyNodeList.item( 0 ).toElement();
8180
QDomElement firstChildElement = bodyElement.firstChild().toElement();
@@ -84,27 +83,27 @@ QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
8483
if ( serviceString == "MS" )
8584
{
8685
QgsDebugMsg( "service = MS " );
87-
result.insert( "SERVICE", "MS" );
86+
mParameterMap.insert( "SERVICE", "MS" );
8887
mService = "MS";
8988
}
9089
else if ( serviceString == "WMS" )
9190
{
92-
result.insert( "SERVICE", "WMS" );
91+
mParameterMap.insert( "SERVICE", "WMS" );
9392
mService = "WMS";
9493
}
9594
else if ( serviceString == "MDS" )
9695
{
97-
result.insert( "SERVICE", "MDS" );
96+
mParameterMap.insert( "SERVICE", "MDS" );
9897
mService = "MDS";
9998
}
10099
else if ( serviceString == "MAS" )
101100
{
102-
result.insert( "SERVICE", "MAS" );
101+
mParameterMap.insert( "SERVICE", "MAS" );
103102
mService = "MAS";
104103
}
105104
else
106105
{
107-
result.insert( "SERVICE", "DISCOVERY" );
106+
mParameterMap.insert( "SERVICE", "DISCOVERY" );
108107
mService = "DISCOVERY";
109108
}
110109

@@ -113,31 +112,31 @@ QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
113112
//if(firstChildElement.localName().compare("getCapabilities", Qt::CaseInsensitive) == 0)
114113
if ( firstChildElement.localName() == "GetCapabilities" || firstChildElement.localName() == "getCapabilities" )
115114
{
116-
result.insert( "REQUEST", "GetCapabilities" );
115+
mParameterMap.insert( "REQUEST", "GetCapabilities" );
117116
}
118117
//GetMap request
119118
//else if(firstChildElement.tagName().compare("getMap",Qt::CaseInsensitive) == 0)
120119
else if ( firstChildElement.localName() == "GetMap" || firstChildElement.localName() == "getMap" )
121120
{
122-
result.insert( "REQUEST", "GetMap" );
123-
parseGetMapElement( result, firstChildElement );
121+
mParameterMap.insert( "REQUEST", "GetMap" );
122+
parseGetMapElement( mParameterMap, firstChildElement );
124123
}
125124
//GetDiagram request
126125
//else if(firstChildElement.tagName().compare("getDiagram", Qt::CaseInsensitive) == 0)
127126
else if ( firstChildElement.localName() == "GetDiagram" )
128127
{
129-
result.insert( "REQUEST", "GetDiagram" );
130-
parseGetMapElement( result, firstChildElement ); //reuse the method for GetMap
128+
mParameterMap.insert( "REQUEST", "GetDiagram" );
129+
parseGetMapElement( mParameterMap, firstChildElement ); //reuse the method for GetMap
131130
}
132131
//GetFeatureInfo request
133132
else if ( firstChildElement.localName() == "GetFeatureInfo" )
134133
{
135-
result.insert( "REQUEST", "GetFeatureInfo" );
136-
parseGetFeatureInfoElement( result, firstChildElement );
134+
mParameterMap.insert( "REQUEST", "GetFeatureInfo" );
135+
parseGetFeatureInfoElement( mParameterMap, firstChildElement );
137136
}
138137

139138
//set mFormat
140-
QString formatString = result.value( "FORMAT" );
139+
QString formatString = mParameterMap.value( "FORMAT" );
141140
if ( !formatString.isEmpty() )
142141
{
143142
//remove the image/ in front of the format
@@ -160,35 +159,33 @@ QMap<QString, QString> QgsSOAPRequestHandler::parseInput()
160159

161160
mFormat = formatString;
162161
}
163-
164-
return result;
165162
}
166163

167-
void QgsSOAPRequestHandler::sendGetMapResponse( const QString& service, QImage* img ) const
164+
void QgsSOAPRequestHandler::setGetMapResponse( const QString& service, QImage* img )
168165
{
169-
QgsMapServiceException ex( "Send error", "Error, could not send Image" );
166+
QgsMapServiceException ex( "set error", "Error, could not set Image" );
170167
if ( service == "WMS" )
171168
{
172-
if ( sendUrlToFile( img ) != 0 )
169+
if ( setUrlToFile( img ) != 0 )
173170
{
174-
sendServiceException( ex );
171+
setServiceException( ex );
175172
}
176173
}
177174
else if ( service == "MAS" || service == "MS" || service == "MDS" )
178175
{
179176

180-
if ( sendSOAPWithAttachments( img ) != 0 )
177+
if ( setSOAPWithAttachments( img ) != 0 )
181178
{
182-
sendServiceException( ex );
179+
setServiceException( ex );
183180
}
184181
}
185182
else
186183
{
187-
sendServiceException( ex );
184+
setServiceException( ex );
188185
}
189186
}
190187

191-
void QgsSOAPRequestHandler::sendGetCapabilitiesResponse( const QDomDocument& doc ) const
188+
void QgsSOAPRequestHandler::setGetCapabilitiesResponse( const QDomDocument& doc )
192189
{
193190
//Parse the QDomDocument Document and create a SOAP response
194191
QDomElement DocCapabilitiesElement = doc.firstChildElement();
@@ -373,12 +370,12 @@ void QgsSOAPRequestHandler::sendGetCapabilitiesResponse( const QDomDocument& doc
373370
}
374371

375372
QByteArray ba = soapResponseDoc.toByteArray();
376-
sendHttpResponse( &ba, "text/xml" );
373+
setHttpResponse( &ba, "text/xml" );
377374
}
378375
}
379376
}
380377

381-
void QgsSOAPRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) const
378+
void QgsSOAPRequestHandler::setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat )
382379
{
383380
Q_UNUSED( infoFormat );
384381
QDomDocument featureInfoResponseDoc;
@@ -395,12 +392,12 @@ void QgsSOAPRequestHandler::sendGetFeatureInfoResponse( const QDomDocument& info
395392

396393
soapBodyElement.appendChild( infoDoc.documentElement() );
397394

398-
//now send message
395+
//now set message
399396
QByteArray ba = featureInfoResponseDoc.toByteArray();
400-
sendHttpResponse( &ba, "text/xml" );
397+
setHttpResponse( &ba, "text/xml" );
401398
}
402399

403-
void QgsSOAPRequestHandler::sendGetStyleResponse( const QDomDocument& infoDoc ) const
400+
void QgsSOAPRequestHandler::setGetStyleResponse( const QDomDocument& infoDoc )
404401
{
405402
QDomDocument featureInfoResponseDoc;
406403

@@ -416,18 +413,18 @@ void QgsSOAPRequestHandler::sendGetStyleResponse( const QDomDocument& infoDoc )
416413

417414
soapBodyElement.appendChild( infoDoc.documentElement() );
418415

419-
//now send message
416+
//now set message
420417
QByteArray ba = featureInfoResponseDoc.toByteArray();
421-
sendHttpResponse( &ba, "text/xml" );
418+
setHttpResponse( &ba, "text/xml" );
422419
}
423420

424-
void QgsSOAPRequestHandler::sendGetPrintResponse( QByteArray* ba ) const
421+
void QgsSOAPRequestHandler::setGetPrintResponse( QByteArray* ba ) const
425422
{
426423
Q_UNUSED( ba );
427424
//soon...
428425
}
429426

430-
void QgsSOAPRequestHandler::sendServiceException( const QgsMapServiceException& ex ) const
427+
void QgsSOAPRequestHandler::setServiceException( const QgsMapServiceException& ex )
431428
{
432429
//create response document
433430
QDomDocument soapResponseDoc;
@@ -449,7 +446,7 @@ void QgsSOAPRequestHandler::sendServiceException( const QgsMapServiceException&
449446
msExceptionsElement.appendChild( msExceptionMessage );
450447

451448
QByteArray ba = soapResponseDoc.toByteArray();
452-
sendHttpResponse( &ba, "text/xml" );
449+
setHttpResponse( &ba, "text/xml" );
453450
}
454451

455452
int QgsSOAPRequestHandler::parseGetMapElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const
@@ -656,7 +653,7 @@ int QgsSOAPRequestHandler::parseOutputAttributesElement( QMap<QString, QString>&
656653
return 0;
657654
}
658655

659-
int QgsSOAPRequestHandler::sendSOAPWithAttachments( QImage* img ) const
656+
int QgsSOAPRequestHandler::setSOAPWithAttachments( QImage* img )
660657
{
661658
QgsDebugMsg( "Entering." );
662659
//create response xml document
@@ -680,37 +677,39 @@ int QgsSOAPRequestHandler::sendSOAPWithAttachments( QImage* img ) const
680677
img->save( &buffer, mFormat.toLocal8Bit().data(), -1 ); // writes image into ba
681678

682679
QByteArray xmlByteArray = xmlResponse.toString().toLocal8Bit();
683-
printf( "MIME-Version: 1.0\n" );
684-
printf( "Content-Type: Multipart/Related; boundary=\"MIME_boundary\"; type=\"text/xml\"; start=\"<xml@mapservice>\"\n" );
685-
printf( "\n" );
686-
printf( "--MIME_boundary\r\n" );
687-
printf( "Content-Type: text/xml\n" );
688-
printf( "Content-ID: <xml@mapservice>\n" );
689-
printf( "\n" );
690-
printf( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
691-
fwrite( xmlByteArray.data(), xmlByteArray.size(), 1, FCGI_stdout );
692-
printf( "\n" );
693-
printf( "\r\n" );
694-
printf( "--MIME_boundary\r\n" );
680+
681+
// Set headers
682+
setHeader( "MIME-Version", "1.0" );
683+
setHeader( "Content-Type", "Multipart/Related; boundary=\"MIME_boundary\"; type=\"text/xml\"; start=\"<xml@mapservice>\"" );
684+
// Start body
685+
appendBody( "--MIME_boundary\r\n" );
686+
appendBody( "Content-Type: text/xml\n" );
687+
appendBody( "Content-ID: <xml@mapservice>\n" );
688+
appendBody( "\n" );
689+
appendBody( "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" );
690+
appendBody( xmlByteArray );
691+
appendBody( "\n" );
692+
appendBody( "\r\n" );
693+
appendBody( "--MIME_boundary\r\n" );
695694
if ( mFormat == "JPG" )
696695
{
697-
printf( "Content-Type: image/jpg\n" );
696+
appendBody( "Content-Type: image/jpg\n" );
698697
}
699698
else if ( mFormat == "PNG" )
700699
{
701-
printf( "Content-Type: image/png\n" );
700+
appendBody( "Content-Type: image/png\n" );
702701
}
703-
printf( "Content-Transfer-Encoding: binary\n" );
704-
printf( "Content-ID: <image@mapservice>\n" );
705-
printf( "\n" );
706-
fwrite( ba.data(), ba.size(), 1, FCGI_stdout );
707-
printf( "\r\n" );
708-
printf( "--MIME_boundary\r\n" );
702+
appendBody( "Content-Transfer-Encoding: binary\n" );
703+
appendBody( "Content-ID: <image@mapservice>\n" );
704+
appendBody( "\n" );
705+
appendBody( ba );
706+
appendBody( "\r\n" );
707+
appendBody( "--MIME_boundary\r\n" );
709708

710709
return 0;
711710
}
712711

713-
int QgsSOAPRequestHandler::sendUrlToFile( QImage* img ) const
712+
int QgsSOAPRequestHandler::setUrlToFile( QImage* img )
714713
{
715714
QString uri;
716715
QFile theFile;
@@ -795,7 +794,7 @@ int QgsSOAPRequestHandler::sendUrlToFile( QImage* img ) const
795794
bodyElement.appendChild( getMapResponseElement );
796795

797796
QByteArray xmlByteArray = xmlResponse.toByteArray();
798-
sendHttpResponse( &xmlByteArray, "text/xml" );
797+
setHttpResponse( &xmlByteArray, "text/xml" );
799798
return 0;
800799
}
801800

‎src/mapserver/qgssoaprequesthandler.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,22 @@ class QgsSOAPRequestHandler: public QgsHttpRequestHandler
2828
public:
2929
QgsSOAPRequestHandler();
3030
~QgsSOAPRequestHandler();
31-
QMap<QString, QString> parseInput();
32-
void sendGetMapResponse( const QString& service, QImage* img ) const;
33-
void sendGetCapabilitiesResponse( const QDomDocument& doc ) const;
34-
void sendGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat ) const;
35-
void sendServiceException( const QgsMapServiceException& ex ) const;
36-
void sendGetStyleResponse( const QDomDocument& doc ) const;
37-
void sendGetPrintResponse( QByteArray* ba ) const;
31+
void parseInput();
32+
void setGetMapResponse( const QString& service, QImage* img );
33+
void setGetCapabilitiesResponse( const QDomDocument& doc );
34+
void setGetFeatureInfoResponse( const QDomDocument& infoDoc, const QString& infoFormat );
35+
void setServiceException( const QgsMapServiceException& ex );
36+
void setGetStyleResponse( const QDomDocument& doc );
37+
void setGetPrintResponse( QByteArray* ba ) const;
3838
private:
3939
/**Parses the xml of a getMap request and fills the parameters into the map. Returns 0 in case of success*/
4040
int parseGetMapElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const;
4141
/**Parses the xml of a feature info request and fills the parameters into the map. Returns 0 in case of success*/
4242
int parseGetFeatureInfoElement( QMap<QString, QString>& parameterMap, const QDomElement& getMapElement ) const;
4343
int parseBoundingBoxElement( QMap<QString, QString>& parameterMap, const QDomElement& boundingBoxElement ) const;
4444
int parseOutputAttributesElement( QMap<QString, QString>& parameterMap, const QDomElement& outputAttributesElement ) const;
45-
int sendSOAPWithAttachments( QImage* img ) const;
46-
int sendUrlToFile( QImage* img ) const;
45+
int setSOAPWithAttachments( QImage* img );
46+
int setUrlToFile( QImage* img );
4747
/**Reads the file wms_metadata.xml and extract the OnlineResource href. Returns 0 in case of success.*/
4848
int findOutHostAddress( QString& address ) const;
4949
};

‎src/mapserver/qgswcsserver.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static const QString WCS_NAMESPACE = "http://www.opengis.net/wcs";
3737
static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
3838
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";
3939

40-
QgsWCSServer::QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWCSProjectParser* pp,
40+
QgsWCSServer::QgsWCSServer(const QString& configFilePath, QMap<QString, QString> &parameters, QgsWCSProjectParser* pp,
4141
QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, rh ), mConfigParser( pp )
4242
{
4343
}
@@ -58,7 +58,7 @@ void QgsWCSServer::executeRequest()
5858
{
5959
//do some error handling
6060
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
61-
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
61+
mRequestHandler->setServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
6262
return;
6363
}
6464

@@ -71,11 +71,11 @@ void QgsWCSServer::executeRequest()
7171
}
7272
catch ( QgsMapServiceException& ex )
7373
{
74-
mRequestHandler->sendServiceException( ex );
74+
mRequestHandler->setServiceException( ex );
7575
return;
7676
}
77-
QgsDebugMsg( "sending GetCapabilities response" );
78-
mRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
77+
QgsDebugMsg( "seting GetCapabilities response" );
78+
mRequestHandler->setGetCapabilitiesResponse( capabilitiesDocument );
7979
return;
8080
}
8181
else if ( request.compare( "DescribeCoverage", Qt::CaseInsensitive ) == 0 )
@@ -87,11 +87,11 @@ void QgsWCSServer::executeRequest()
8787
}
8888
catch ( QgsMapServiceException& ex )
8989
{
90-
mRequestHandler->sendServiceException( ex );
90+
mRequestHandler->setServiceException( ex );
9191
return;
9292
}
93-
QgsDebugMsg( "sending GetCapabilities response" );
94-
mRequestHandler->sendGetCapabilitiesResponse( describeDocument );
93+
QgsDebugMsg( "seting GetCapabilities response" );
94+
mRequestHandler->setGetCapabilitiesResponse( describeDocument );
9595
return;
9696
}
9797
else if ( request.compare( "GetCoverage", Qt::CaseInsensitive ) == 0 )
@@ -103,12 +103,12 @@ void QgsWCSServer::executeRequest()
103103
}
104104
catch ( QgsMapServiceException& ex )
105105
{
106-
mRequestHandler->sendServiceException( ex );
106+
mRequestHandler->setServiceException( ex );
107107
return;
108108
}
109109
if ( coverageOutput )
110110
{
111-
mRequestHandler->sendGetCoverageResponse( coverageOutput );
111+
mRequestHandler->setGetCoverageResponse( coverageOutput );
112112
}
113113
return;
114114
}

‎src/mapserver/qgswcsserver.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class QgsWCSServer: public QgsOWSServer
3636
{
3737
public:
3838
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
39-
QgsWCSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWCSProjectParser* pp,
39+
QgsWCSServer( const QString& configFilePath, QMap<QString, QString>& parameters, QgsWCSProjectParser* pp,
4040
QgsRequestHandler* rh );
4141
~QgsWCSServer();
4242

‎src/mapserver/qgswfsserver.cpp

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static const QString GML_NAMESPACE = "http://www.opengis.net/gml";
6464
static const QString OGC_NAMESPACE = "http://www.opengis.net/ogc";
6565
static const QString QGS_NAMESPACE = "http://www.qgis.org/gml";
6666

67-
QgsWFSServer::QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWFSProjectParser* cp,
67+
QgsWFSServer::QgsWFSServer(const QString& configFilePath, QMap<QString, QString> &parameters, QgsWFSProjectParser* cp,
6868
QgsRequestHandler* rh ): QgsOWSServer( configFilePath, parameters, rh ), mConfigParser( cp )
6969
{
7070
}
@@ -90,7 +90,7 @@ void QgsWFSServer::executeRequest()
9090
{
9191
//do some error handling
9292
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
93-
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
93+
mRequestHandler->setServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
9494
return;
9595
}
9696

@@ -103,11 +103,11 @@ void QgsWFSServer::executeRequest()
103103
}
104104
catch ( QgsMapServiceException& ex )
105105
{
106-
mRequestHandler->sendServiceException( ex );
106+
mRequestHandler->setServiceException( ex );
107107
return;
108108
}
109-
QgsDebugMsg( "sending GetCapabilities response" );
110-
mRequestHandler->sendGetCapabilitiesResponse( capabilitiesDocument );
109+
QgsDebugMsg( "Setting GetCapabilities response" );
110+
mRequestHandler->setGetCapabilitiesResponse( capabilitiesDocument );
111111
return;
112112
}
113113
else if ( request.compare( "DescribeFeatureType", Qt::CaseInsensitive ) == 0 )
@@ -119,11 +119,11 @@ void QgsWFSServer::executeRequest()
119119
}
120120
catch ( QgsMapServiceException& ex )
121121
{
122-
mRequestHandler->sendServiceException( ex );
122+
mRequestHandler->setServiceException( ex );
123123
return;
124124
}
125-
QgsDebugMsg( "sending GetCapabilities response" );
126-
mRequestHandler->sendGetCapabilitiesResponse( describeDocument );
125+
QgsDebugMsg( "Setting GetCapabilities response" );
126+
mRequestHandler->setGetCapabilitiesResponse( describeDocument );
127127
return;
128128
}
129129
else if ( request.compare( "GetFeature", Qt::CaseInsensitive ) == 0 )
@@ -136,7 +136,7 @@ void QgsWFSServer::executeRequest()
136136
}
137137
catch ( QgsMapServiceException& ex )
138138
{
139-
mRequestHandler->sendServiceException( ex );
139+
mRequestHandler->setServiceException( ex );
140140
}
141141

142142
return;
@@ -150,11 +150,11 @@ void QgsWFSServer::executeRequest()
150150
}
151151
catch ( QgsMapServiceException& ex )
152152
{
153-
mRequestHandler->sendServiceException( ex );
153+
mRequestHandler->setServiceException( ex );
154154
return;
155155
}
156-
QgsDebugMsg( "sending Transaction response" );
157-
mRequestHandler->sendGetCapabilitiesResponse( transactionDocument );
156+
QgsDebugMsg( "Setting Transaction response" );
157+
mRequestHandler->setGetCapabilitiesResponse( transactionDocument );
158158
return;
159159
}
160160
}
@@ -533,7 +533,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
533533
if ( featureCounter == 0 )
534534
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
535535

536-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
536+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
537537

538538
fid = "";
539539
++featCounter;
@@ -570,7 +570,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
570570
if ( featureCounter == 0 )
571571
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
572572

573-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
573+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
574574
++featCounter;
575575
++featureCounter;
576576
}
@@ -596,7 +596,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
596596
if ( featureCounter == 0 )
597597
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
598598

599-
sendGetFeature( request, format, &feature, featureCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
599+
setGetFeature( request, format, &feature, featureCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
600600
++featureCounter;
601601
++featCounter;
602602
}
@@ -611,7 +611,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
611611
if ( featureCounter == 0 )
612612
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
613613

614-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
614+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
615615
++featCounter;
616616
++featureCounter;
617617
}
@@ -851,7 +851,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
851851
if ( featureCounter == 0 )
852852
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
853853

854-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
854+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
855855
++featCounter;
856856
++featureCounter;
857857
}
@@ -897,7 +897,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
897897
if ( featureCounter == 0 )
898898
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
899899

900-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
900+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
901901
++featCounter;
902902
++featureCounter;
903903
}
@@ -934,7 +934,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
934934
if ( featureCounter == 0 )
935935
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
936936

937-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
937+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
938938

939939
fid = "";
940940
++featCounter;
@@ -971,7 +971,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
971971
if ( featureCounter == 0 )
972972
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
973973

974-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
974+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
975975
++featCounter;
976976
++featureCounter;
977977
}
@@ -1016,7 +1016,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
10161016
if ( featureCounter == 0 )
10171017
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
10181018

1019-
sendGetFeature( request, format, &feature, featureCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
1019+
setGetFeature( request, format, &feature, featureCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
10201020
++featureCounter;
10211021
++featCounter;
10221022
}
@@ -1053,7 +1053,7 @@ int QgsWFSServer::getFeature( QgsRequestHandler& request, const QString& format
10531053
if ( featureCounter == 0 )
10541054
startGetFeature( request, format, layerPrec, layerCrs, &searchRect );
10551055

1056-
sendGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
1056+
setGetFeature( request, format, &feature, featCounter, layerPrec, layerCrs, attrIndexes, layerExcludedAttributes );
10571057
++featCounter;
10581058
++featureCounter;
10591059
}
@@ -1200,12 +1200,12 @@ void QgsWFSServer::startGetFeature( QgsRequestHandler& request, const QString& f
12001200
}
12011201
}
12021202
result = doc.toByteArray();
1203-
request.sendGetFeatureResponse( &result );
1203+
request.setGetFeatureResponse( &result );
12041204
}
12051205
fcString = "";
12061206
}
12071207

1208-
void QgsWFSServer::sendGetFeature( QgsRequestHandler& request, const QString& format, QgsFeature* feat, int featIdx, int prec, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes ) /*const*/
1208+
void QgsWFSServer::setGetFeature( QgsRequestHandler& request, const QString& format, QgsFeature* feat, int featIdx, int prec, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes ) /*const*/
12091209
{
12101210
if ( !feat->isValid() )
12111211
return;
@@ -1222,7 +1222,7 @@ void QgsWFSServer::sendGetFeature( QgsRequestHandler& request, const QString& fo
12221222
fcString += "\n";
12231223

12241224
result = fcString.toUtf8();
1225-
request.sendGetFeatureResponse( &result );
1225+
request.setGetFeatureResponse( &result );
12261226
fcString = "";
12271227
}
12281228
else
@@ -1241,7 +1241,7 @@ void QgsWFSServer::sendGetFeature( QgsRequestHandler& request, const QString& fo
12411241
}
12421242

12431243
result = gmlDoc.toByteArray();
1244-
request.sendGetFeatureResponse( &result );
1244+
request.setGetFeatureResponse( &result );
12451245
gmlDoc.removeChild( featureElement );
12461246
}
12471247
}

‎src/mapserver/qgswfsserver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class QgsWFSServer: public QgsOWSServer
6060
{
6161
public:
6262
/**Constructor. Takes parameter map and a pointer to a renderer object (does not take ownership)*/
63-
QgsWFSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWFSProjectParser* cp,
63+
QgsWFSServer( const QString& configFilePath, QMap<QString, QString>& parameters, QgsWFSProjectParser* cp,
6464
QgsRequestHandler* rh );
6565
~QgsWFSServer();
6666

@@ -104,7 +104,7 @@ class QgsWFSServer: public QgsOWSServer
104104
protected:
105105

106106
void startGetFeature( QgsRequestHandler& request, const QString& format, int prec, QgsCoordinateReferenceSystem& crs, QgsRectangle* rect );
107-
void sendGetFeature( QgsRequestHandler& request, const QString& format, QgsFeature* feat, int featIdx, int prec, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes );
107+
void setGetFeature( QgsRequestHandler& request, const QString& format, QgsFeature* feat, int featIdx, int prec, QgsCoordinateReferenceSystem& crs, QgsAttributeList attrIndexes, QSet<QString> excludedAttributes );
108108
void endGetFeature( QgsRequestHandler& request, const QString& format );
109109

110110
//method for transaction

‎src/mapserver/qgswmsserver.cpp

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
#include <QUrl>
6161
#include <QPaintEngine>
6262

63-
QgsWMSServer::QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWMSConfigParser* cp,
63+
QgsWMSServer::QgsWMSServer( const QString& configFilePath, QMap<QString, QString> &parameters, QgsWMSConfigParser* cp,
6464
QgsRequestHandler* rh, QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache )
6565
: QgsOWSServer( configFilePath, parameters, rh )
6666
, mMapRenderer( renderer )
@@ -92,17 +92,15 @@ void QgsWMSServer::executeRequest()
9292
{
9393
if ( !mMapRenderer || !mConfigParser || !mRequestHandler || !mCapabilitiesCache )
9494
{
95-
return; //todo: error handling
95+
return; //TODO: error handling
9696
}
9797

9898
//request type
9999
QString request = mParameters.value( "REQUEST" );
100100
if ( request.isEmpty() )
101101
{
102102
QgsDebugMsg( "unable to find 'REQUEST' parameter, exiting..." );
103-
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
104-
cleanupAfterRequest();
105-
return;
103+
mRequestHandler->setServiceException( QgsMapServiceException( "OperationNotSupported", "Please check the value of the REQUEST parameter" ) );
106104
}
107105

108106
//version
@@ -127,7 +125,7 @@ void QgsWMSServer::executeRequest()
127125
}
128126
catch ( QgsMapServiceException& ex )
129127
{
130-
mRequestHandler->sendServiceException( ex );
128+
mRequestHandler->setServiceException( ex );
131129
cleanupAfterRequest();
132130
return;
133131
}
@@ -141,7 +139,7 @@ void QgsWMSServer::executeRequest()
141139

142140
if ( capabilitiesDocument )
143141
{
144-
mRequestHandler->sendGetCapabilitiesResponse( *capabilitiesDocument );
142+
mRequestHandler->setGetCapabilitiesResponse( *capabilitiesDocument );
145143
}
146144
}
147145
//GetMap
@@ -155,15 +153,15 @@ void QgsWMSServer::executeRequest()
155153
catch ( QgsMapServiceException& ex )
156154
{
157155
QgsDebugMsg( "Caught exception during GetMap request" );
158-
mRequestHandler->sendServiceException( ex );
156+
mRequestHandler->setServiceException( ex );
159157
cleanupAfterRequest();
160158
return;
161159
}
162160

163161
if ( result )
164162
{
165-
QgsDebugMsg( "Sending GetMap response" );
166-
mRequestHandler->sendGetMapResponse( "WMS", result, getImageQuality() );
163+
QgsDebugMsg( "Setting GetMap response" );
164+
mRequestHandler->setGetMapResponse( "WMS", result, getImageQuality() );
167165
QgsDebugMsg( "Response sent" );
168166
}
169167
else
@@ -187,25 +185,25 @@ void QgsWMSServer::executeRequest()
187185
}
188186
catch ( QgsMapServiceException& ex )
189187
{
190-
mRequestHandler->sendServiceException( ex );
188+
mRequestHandler->setServiceException( ex );
191189
cleanupAfterRequest();
192190
return;
193191
}
194192

195193
QString infoFormat = mParameters.value( "INFO_FORMAT" );
196-
mRequestHandler->sendGetFeatureInfoResponse( featureInfoDoc, infoFormat );
194+
mRequestHandler->setGetFeatureInfoResponse( featureInfoDoc, infoFormat );
197195
}
198196
//GetContext
199197
else if ( request.compare( "GetContext", Qt::CaseInsensitive ) == 0 )
200198
{
201199
try
202200
{
203201
QDomDocument doc = getContext();
204-
mRequestHandler->sendGetStyleResponse( doc );
202+
mRequestHandler->setGetStyleResponse( doc );
205203
}
206204
catch ( QgsMapServiceException& ex )
207205
{
208-
mRequestHandler->sendServiceException( ex );
206+
mRequestHandler->setServiceException( ex );
209207
}
210208
}
211209
//GetStyle for compatibility with earlier QGIS versions
@@ -214,11 +212,11 @@ void QgsWMSServer::executeRequest()
214212
try
215213
{
216214
QDomDocument doc = getStyle();
217-
mRequestHandler->sendGetStyleResponse( doc );
215+
mRequestHandler->setGetStyleResponse( doc );
218216
}
219217
catch ( QgsMapServiceException& ex )
220218
{
221-
mRequestHandler->sendServiceException( ex );
219+
mRequestHandler->setServiceException( ex );
222220
}
223221
}
224222
//GetStyles
@@ -227,18 +225,18 @@ void QgsWMSServer::executeRequest()
227225
// GetStyles is only defined for WMS1.1.1/SLD1.0
228226
if ( version != "1.1.1" )
229227
{
230-
mRequestHandler->sendServiceException( QgsMapServiceException( "OperationNotSupported", "GetStyles method is only available in WMS version 1.1.1" ) );
228+
mRequestHandler->setServiceException( QgsMapServiceException( "OperationNotSupported", "GetStyles method is only available in WMS version 1.1.1" ) );
231229
}
232230
else
233231
{
234232
try
235233
{
236234
QDomDocument doc = getStyles();
237-
mRequestHandler->sendGetStyleResponse( doc );
235+
mRequestHandler->setGetStyleResponse( doc );
238236
}
239237
catch ( QgsMapServiceException& ex )
240238
{
241-
mRequestHandler->sendServiceException( ex );
239+
mRequestHandler->setServiceException( ex );
242240
}
243241
}
244242
}
@@ -255,14 +253,14 @@ void QgsWMSServer::executeRequest()
255253
catch ( QgsMapServiceException& ex )
256254
{
257255
QgsDebugMsg( "Caught exception during GetLegendGraphic request" );
258-
mRequestHandler->sendServiceException( ex );
256+
mRequestHandler->setServiceException( ex );
259257
}
260258

261259
if ( result )
262260
{
263-
QgsDebugMsg( "Sending GetLegendGraphic response" );
264-
//sending is the same for GetMap and GetLegendGraphic
265-
mRequestHandler->sendGetMapResponse( "WMS", result, getImageQuality() );
261+
QgsDebugMsg( "Setting GetLegendGraphic response" );
262+
//setting is the same for GetMap and GetLegendGraphic
263+
mRequestHandler->setGetMapResponse( "WMS", result, getImageQuality() );
266264
QgsDebugMsg( "Response sent" );
267265
}
268266
else
@@ -282,19 +280,19 @@ void QgsWMSServer::executeRequest()
282280
}
283281
catch ( QgsMapServiceException& ex )
284282
{
285-
mRequestHandler->sendServiceException( ex );
283+
mRequestHandler->setServiceException( ex );
286284
}
287285

288286
if ( printOutput )
289287
{
290-
mRequestHandler->sendGetPrintResponse( printOutput );
288+
mRequestHandler->setGetPrintResponse( printOutput );
291289
}
292290
delete printOutput;
293291
}
294292
else//unknown request
295293
{
296294
QgsMapServiceException e( "OperationNotSupported", "Operation " + request + " not supported" );
297-
mRequestHandler->sendServiceException( e );
295+
mRequestHandler->setServiceException( e );
298296
}
299297
cleanupAfterRequest();
300298
}

‎src/mapserver/qgswmsserver.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ independent from any server side technology*/
5959
class QgsWMSServer: public QgsOWSServer
6060
{
6161
public:
62-
/**Constructor. Takes ownership of QgsRequestHandler. Does _NOT_ take ownership of
62+
/**Constructor. Does _NOT_ take ownership of
6363
QgsConfigParser, QgsCapabilitiesCache and QgsMapRenderer*/
64-
QgsWMSServer( const QString& configFilePath, QMap<QString, QString> parameters, QgsWMSConfigParser* cp, QgsRequestHandler* rh,
64+
QgsWMSServer(const QString& configFilePath, QMap<QString, QString> &parameters, QgsWMSConfigParser* cp, QgsRequestHandler* rh,
6565
QgsMapRenderer* renderer, QgsCapabilitiesCache* capCache );
6666
~QgsWMSServer();
6767

0 commit comments

Comments
 (0)
Please sign in to comment.