Skip to content

Commit bf583c7

Browse files
committed
Merge pull request #2830 from elpaso/server-fix-info_format2
[bugfix][server] text/plain as default info_format
2 parents 3a8c1c7 + 3df100f commit bf583c7

File tree

5 files changed

+58
-5
lines changed

5 files changed

+58
-5
lines changed

src/server/qgshttprequesthandler.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ void QgsHttpRequestHandler::setGetFeatureInfoResponse( const QDomDocument& infoD
446446
}
447447
else //unsupported format, set exception
448448
{
449-
setServiceException( QgsMapServiceException( "InvalidFormat", "Feature info format '" + mFormat + "' is not supported. Possibilities are 'text/plain', 'text/html' or 'text/xml'." ) );
449+
setServiceException( QgsMapServiceException( "InvalidFormat", "Feature info format '" + infoFormat + "' is not supported. Possibilities are 'text/plain', 'text/html' or 'text/xml'." ) );
450450
return;
451451
}
452452

src/server/qgswmsserver.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ void QgsWMSServer::executeRequest()
267267
return;
268268
}
269269

270-
QString infoFormat = mParameters.value( "INFO_FORMAT" );
270+
QString infoFormat = mParameters.value( "INFO_FORMAT", "text/plain" );
271271
mRequestHandler->setGetFeatureInfoResponse( featureInfoDoc, infoFormat );
272272
}
273273
//GetContext

tests/src/python/test_qgsserver.py

+23-3
Original file line numberDiff line numberDiff line change
@@ -140,14 +140,16 @@ def responseComplete(self):
140140
self.assertEqual(response, expected)
141141

142142
# WMS tests
143-
def wms_request_compare(self, request):
143+
def wms_request_compare(self, request, extra=None, reference_file=None):
144144
project = self.testdata_path + "test+project.qgs"
145145
assert os.path.exists(project), "Project file not found: " + project
146146

147147
query_string = 'MAP=%s&SERVICE=WMS&VERSION=1.3&REQUEST=%s' % (urllib.quote(project), request)
148+
if extra is not None:
149+
query_string += extra
148150
header, body = [str(_v) for _v in self.server.handleRequest(query_string)]
149151
response = header + body
150-
f = open(self.testdata_path + request.lower() + '.txt')
152+
f = open(self.testdata_path + (request.lower() if not reference_file else reference_file) + '.txt')
151153
expected = f.read()
152154
f.close()
153155
# Store the output for debug or to regenerate the reference documents:
@@ -168,8 +170,26 @@ def test_project_wms(self):
168170
for request in ('GetCapabilities', 'GetProjectSettings'):
169171
self.wms_request_compare(request)
170172

171-
# WMS INSPIRE tests
173+
# Test getfeatureinfo response
174+
self.wms_request_compare('GetFeatureInfo',
175+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
176+
'info_format=text%2Fhtml&transparent=true&' +
177+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
178+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
179+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
180+
'wms_getfeatureinfo-text-html')
181+
182+
# Test getfeatureinfo default info_format
183+
self.wms_request_compare('GetFeatureInfo',
184+
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
185+
'transparent=true&' +
186+
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
187+
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
188+
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
189+
'wms_getfeatureinfo-text-plain')
190+
172191
def wms_inspire_request_compare(self, request):
192+
"""WMS INSPIRE tests"""
173193
project = self.testdata_path + "test+project_inspire.qgs"
174194
assert os.path.exists(project), "Project file not found: " + project
175195

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Content-Length: 360
2+
Content-Type: text/html; charset=utf-8
3+
4+
<HEAD>
5+
<TITLE> GetFeatureInfo results </TITLE>
6+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
7+
</HEAD>
8+
<BODY>
9+
<TABLE border=1 width=100%>
10+
<TR><TH width=25%>Layer</TH><TD>testlayer èé</TD></TR>
11+
</BR><TABLE border=1 width=100%>
12+
<TR><TH>Feature</TH><TD>2</TD></TR>
13+
<TR><TH>id</TH><TD>3</TD></TR>
14+
<TR><TH>name</TH><TD>three</TD></TR>
15+
<TR><TH>utf8nameè</TH><TD>three èé↓</TD></TR>
16+
<TR><TH>geometry</TH><TD>Point (913204.9128 5606011.4565)</TD></TR>
17+
</TABLE>
18+
</BR>
19+
</TABLE>
20+
<BR></BR>
21+
</BODY>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Content-Length: 157
2+
Content-Type: text/plain; charset=utf-8
3+
4+
GetFeatureInfo results
5+
6+
Layer 'testlayer èé'
7+
Feature 2
8+
id = '3'
9+
name = 'three'
10+
utf8nameè = 'three èé↓'
11+
geometry = 'Point (913204.9128 5606011.4565)'
12+

0 commit comments

Comments
 (0)