Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Also accept collection URLs with ending slash
Fixed #33203
  • Loading branch information
elpaso committed Dec 7, 2019
1 parent 2672c74 commit 9af6301
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/server/services/wfs3/qgswfs3handlers.h
Expand Up @@ -176,7 +176,7 @@ class QgsWfs3CollectionsHandler: public QgsWfs3AbstractItemsHandler
void handleRequest( const QgsServerApiContext &context ) const override;

// QgsServerOgcApiHandler interface
QRegularExpression path() const override { return QRegularExpression( R"re(/collections(\.json|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections(\.json|\.html|/)?$)re" ); }
std::string operationId() const override { return "describeCollections"; }
std::string summary() const override
{
Expand All @@ -203,7 +203,7 @@ class QgsWfs3DescribeCollectionHandler: public QgsWfs3AbstractItemsHandler
QgsWfs3DescribeCollectionHandler( );
void handleRequest( const QgsServerApiContext &context ) const override;

QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+?)(\.json|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+?)(\.json|\.html|/)?$)re" ); }
std::string operationId() const override { return "describeCollection"; }
std::string summary() const override { return "Describe the feature collection with ID {collectionId}."; }
std::string description() const override { return "Metadata about a feature collection."; }
Expand All @@ -222,7 +222,7 @@ class QgsWfs3CollectionsItemsHandler: public QgsWfs3AbstractItemsHandler
public:
QgsWfs3CollectionsItemsHandler( );
void handleRequest( const QgsServerApiContext &context ) const override;
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items(\.geojson|\.json|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items(\.geojson|\.json|\.html|/)?$)re" ); }
std::string operationId() const override { return "getFeatures"; }
std::string summary() const override { return "Retrieve features of feature collection {collectionId}."; }
std::string description() const override
Expand Down Expand Up @@ -251,7 +251,7 @@ class QgsWfs3CollectionsFeatureHandler: public QgsWfs3AbstractItemsHandler
public:
QgsWfs3CollectionsFeatureHandler( );
void handleRequest( const QgsServerApiContext &context ) const override;
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items/(?<featureId>[^/]+?)(\.json|\.geojson|\.html)?$)re" ); }
QRegularExpression path() const override { return QRegularExpression( R"re(/collections/(?<collectionId>[^/]+)/items/(?<featureId>[^/]+?)(\.json|\.geojson|\.html|/)?$)re" ); }
std::string operationId() const override { return "getFeature"; }
std::string description() const override { return "Retrieve a feature with ID {featureId} from the collection with ID {collectionId}; use content negotiation or specify a file extension to request HTML (.html or GeoJSON (.json)."; }
std::string summary() const override { return "Retrieve a single feature with ID {featureId} from the collection with ID {collectionId}."; }
Expand Down
8 changes: 8 additions & 0 deletions tests/src/python/test_qgsserver_api.py
Expand Up @@ -405,6 +405,11 @@ def test_wfs3_collections_content_type(self):
response = QgsBufferServerResponse()
self.server.handleRequest(request, response, project)
self.assertEqual(response.headers()['Content-Type'], 'text/html')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections')
request.setHeader('Accept', 'text/html')
response = QgsBufferServerResponse()
self.server.handleRequest(request, response, project)
self.assertEqual(response.headers()['Content-Type'], 'text/html')

def test_wfs3_collection_json(self):
"""Test WFS3 API collection"""
Expand Down Expand Up @@ -433,6 +438,9 @@ def test_wfs3_collection_html(self):
project.read(unitTestDataPath('qgis_server') + '/test_project_api.qgs')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections/testlayer%20èé.html')
self.compareApi(request, project, 'test_wfs3_collection_testlayer_èé.html')
request = QgsBufferServerRequest('http://server.qgis.org/wfs3/collections/testlayer%20èé/')
request.setHeader('Accept', 'text/html')
self.compareApi(request, project, 'test_wfs3_collection_testlayer_èé.html')

def test_wfs3_collection_items(self):
"""Test WFS3 API items"""
Expand Down

0 comments on commit 9af6301

Please sign in to comment.