Skip to content

Commit

Permalink
Merge pull request #35825 from rduivenvoorde/qgisserveroutput
Browse files Browse the repository at this point in the history
Qgisserveroutput
  • Loading branch information
rldhont committed Apr 30, 2020
2 parents 578ab85 + f60812a commit d3a7a65
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions src/server/qgis_mapserver.cpp
Expand Up @@ -205,12 +205,6 @@ int main( int argc, char *argv[] )
else
{
const int port { tcpServer.serverPort() };
std::cout << QObject::tr( "QGIS Development Server listening on http://%1:%2" )
.arg( ipAddress ).arg( port ).toStdString() << std::endl;

#ifndef Q_OS_WIN
std::cout << QObject::tr( "CTRL+C to exit" ).toStdString() << std::endl;
#endif

QAtomicInt connCounter { 0 };

Expand Down Expand Up @@ -239,6 +233,12 @@ int main( int argc, char *argv[] )
server.initPython();
#endif

std::cout << QObject::tr( "QGIS Development Server listening on http://%1:%2" )
.arg( ipAddress ).arg( port ).toStdString() << std::endl;
#ifndef Q_OS_WIN
std::cout << QObject::tr( "CTRL+C to exit" ).toStdString() << std::endl;
#endif

// Starts HTTP loop with a poor man's HTTP parser
tcpServer.connect( &tcpServer, &QTcpServer::newConnection, [ & ]
{
Expand Down
4 changes: 2 additions & 2 deletions src/server/qgsserver.cpp
Expand Up @@ -397,7 +397,7 @@ void QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &res
// Project is mandatory for OWS at this point
if ( ! project )
{
throw QgsServerException( QStringLiteral( "Project file error" ) );
throw QgsServerException( QStringLiteral( "Project file error. For OWS services: please provide a SERVICE and a MAP parameter pointing to a valid QGIS project file" ) );
}

if ( ! params.fileName().isEmpty() )
Expand All @@ -415,7 +415,7 @@ void QgsServer::handleRequest( QgsServerRequest &request, QgsServerResponse &res
else
{
throw QgsOgcServiceException( QStringLiteral( "Service configuration error" ),
QStringLiteral( "Service unknown or unsupported" ) );
QStringLiteral( "Service unknown or unsupported. Current supported services (case-sensitive): WMS WFS WCS WMTS SampleService, or use a WFS3 (OGC API Features) endpoint" ) );
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wcs/qgswcs.cpp
Expand Up @@ -74,7 +74,7 @@ namespace QgsWcs
if ( req.isEmpty() )
{
throw QgsServiceException( QStringLiteral( "OperationNotSupported" ),
QStringLiteral( "Please check the value of the REQUEST parameter" ), 501 );
QStringLiteral( "Please add or check the value of the REQUEST parameter" ), 501 );
}

if ( QSTR_COMPARE( req, "GetCapabilities" ) )
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wfs/qgswfs.cpp
Expand Up @@ -78,7 +78,7 @@ namespace QgsWfs
if ( req.isEmpty() )
{
throw QgsServiceException( QStringLiteral( "OperationNotSupported" ),
QStringLiteral( "Please check the value of the REQUEST parameter" ), 501 );
QStringLiteral( "Please add or check the value of the REQUEST parameter" ), 501 );
}

if ( QSTR_COMPARE( req, "GetCapabilities" ) )
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wms/qgswms.cpp
Expand Up @@ -91,7 +91,7 @@ namespace QgsWms
if ( req.isEmpty() )
{
throw QgsServiceException( QgsServiceException::OGC_OperationNotSupported,
QStringLiteral( "Please check the value of the REQUEST parameter" ), 501 );
QStringLiteral( "Please add or check the value of the REQUEST parameter" ), 501 );
}

if ( ( mVersion.compare( QLatin1String( "1.1.1" ) ) == 0 \
Expand Down
2 changes: 1 addition & 1 deletion src/server/services/wmts/qgswmts.cpp
Expand Up @@ -72,7 +72,7 @@ namespace QgsWmts
if ( req.isEmpty() )
{
throw QgsServiceException( QStringLiteral( "OperationNotSupported" ),
QStringLiteral( "Please check the value of the REQUEST parameter" ), 501 );
QStringLiteral( "Please add or check the value of the REQUEST parameter" ), 501 );
}

if ( QSTR_COMPARE( req, "GetCapabilities" ) )
Expand Down
18 changes: 9 additions & 9 deletions tests/src/python/test_qgsserver.py
Expand Up @@ -330,8 +330,8 @@ def test_requestHandler(self):
request = QgsBufferServerRequest('http://somesite.com/somepath', QgsServerRequest.GetMethod, headers)
response = QgsBufferServerResponse()
self.server.handleRequest(request, response)
self.assertEqual(bytes(response.body()), b'<ServerException>Project file error</ServerException>\n')
self.assertEqual(response.headers(), {'Content-Length': '54', 'Content-Type': 'text/xml; charset=utf-8'})
self.assertEqual(bytes(response.body()), b'<ServerException>Project file error. For OWS services: please provide a SERVICE and a MAP parameter pointing to a valid QGIS project file</ServerException>\n')
self.assertEqual(response.headers(), {'Content-Length': '156', 'Content-Type': 'text/xml; charset=utf-8'})
self.assertEqual(response.statusCode(), 500)

def test_requestHandlerProject(self):
Expand All @@ -340,8 +340,8 @@ def test_requestHandlerProject(self):
request = QgsBufferServerRequest('http://somesite.com/somepath', QgsServerRequest.GetMethod, headers)
response = QgsBufferServerResponse()
self.server.handleRequest(request, response, None)
self.assertEqual(bytes(response.body()), b'<ServerException>Project file error</ServerException>\n')
self.assertEqual(response.headers(), {'Content-Length': '54', 'Content-Type': 'text/xml; charset=utf-8'})
self.assertEqual(bytes(response.body()), b'<ServerException>Project file error. For OWS services: please provide a SERVICE and a MAP parameter pointing to a valid QGIS project file</ServerException>\n')
self.assertEqual(response.headers(), {'Content-Length': '156', 'Content-Type': 'text/xml; charset=utf-8'})
self.assertEqual(response.statusCode(), 500)

def test_api(self):
Expand All @@ -350,23 +350,23 @@ def test_api(self):
# Test as a whole
header, body = self._execute_request("")
response = self.strip_version_xmlns(header + body)
expected = self.strip_version_xmlns(b'Content-Length: 54\nContent-Type: text/xml; charset=utf-8\n\n<ServerException>Project file error</ServerException>\n')
expected = self.strip_version_xmlns(b'Content-Length: 156\nContent-Type: text/xml; charset=utf-8\n\n<ServerException>Project file error. For OWS services: please provide a SERVICE and a MAP parameter pointing to a valid QGIS project file</ServerException>\n')
self.assertEqual(response, expected)
expected = b'Content-Length: 54\nContent-Type: text/xml; charset=utf-8\n\n'
expected = b'Content-Length: 156\nContent-Type: text/xml; charset=utf-8\n\n'
self.assertEqual(header, expected)

# Test response when project is specified but without service
project = self.testdata_path + "test_project_wfs.qgs"
qs = '?MAP=%s' % (urllib.parse.quote(project))
header, body = self._execute_request(qs)
response = self.strip_version_xmlns(header + body)
expected = self.strip_version_xmlns(b'Content-Length: 206\nContent-Type: text/xml; charset=utf-8\n\n<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">\n <ServiceException code="Service configuration error">Service unknown or unsupported</ServiceException>\n</ServiceExceptionReport>\n')
expected = self.strip_version_xmlns(b'Content-Length: 326\nContent-Type: text/xml; charset=utf-8\n\n<ServiceExceptionReport >\n <ServiceException code="Service configuration error">Service unknown or unsupported. Current supported services (case-sensitive): WMS WFS WCS WMTS SampleService, or use a WFS3 (OGC API Features) endpoint</ServiceException>\n</ServiceExceptionReport>\n')
self.assertEqual(response, expected)
expected = b'Content-Length: 206\nContent-Type: text/xml; charset=utf-8\n\n'
expected = b'Content-Length: 326\nContent-Type: text/xml; charset=utf-8\n\n'
self.assertEqual(header, expected)

# Test body
expected = self.strip_version_xmlns(b'<ServiceExceptionReport version="1.3.0" xmlns="http://www.opengis.net/ogc">\n <ServiceException code="Service configuration error">Service unknown or unsupported</ServiceException>\n</ServiceExceptionReport>\n')
expected = self.strip_version_xmlns(b'<ServiceExceptionReport >\n <ServiceException code="Service configuration error">Service unknown or unsupported. Current supported services (case-sensitive): WMS WFS WCS WMTS SampleService, or use a WFS3 (OGC API Features) endpoint</ServiceException>\n</ServiceExceptionReport>\n')
self.assertEqual(self.strip_version_xmlns(body), expected)

# WCS tests
Expand Down

0 comments on commit d3a7a65

Please sign in to comment.