Skip to content
Permalink
Browse files

Merge pull request #2830 from elpaso/server-fix-info_format2

 [bugfix][server] text/plain as default info_format
  • Loading branch information
elpaso committed Feb 22, 2016
2 parents 3a8c1c7 + 3df100f commit bf583c7236a53dea5b6f885e8d0d80c405083074
@@ -446,7 +446,7 @@ void QgsHttpRequestHandler::setGetFeatureInfoResponse( const QDomDocument& infoD
}
else //unsupported format, set exception
{
setServiceException( QgsMapServiceException( "InvalidFormat", "Feature info format '" + mFormat + "' is not supported. Possibilities are 'text/plain', 'text/html' or 'text/xml'." ) );
setServiceException( QgsMapServiceException( "InvalidFormat", "Feature info format '" + infoFormat + "' is not supported. Possibilities are 'text/plain', 'text/html' or 'text/xml'." ) );
return;
}

@@ -267,7 +267,7 @@ void QgsWMSServer::executeRequest()
return;
}

QString infoFormat = mParameters.value( "INFO_FORMAT" );
QString infoFormat = mParameters.value( "INFO_FORMAT", "text/plain" );
mRequestHandler->setGetFeatureInfoResponse( featureInfoDoc, infoFormat );
}
//GetContext
@@ -140,14 +140,16 @@ def responseComplete(self):
self.assertEqual(response, expected)

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

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

# WMS INSPIRE tests
# Test getfeatureinfo response
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
'info_format=text%2Fhtml&transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
'wms_getfeatureinfo-text-html')

# Test getfeatureinfo default info_format
self.wms_request_compare('GetFeatureInfo',
'&layers=testlayer%20%C3%A8%C3%A9&styles=&' +
'transparent=true&' +
'width=600&height=400&srs=EPSG%3A3857&bbox=913190.6389747962%2C' +
'5606005.488876367%2C913235.426296057%2C5606035.347090538&' +
'query_layers=testlayer%20%C3%A8%C3%A9&X=190&Y=320',
'wms_getfeatureinfo-text-plain')

def wms_inspire_request_compare(self, request):
"""WMS INSPIRE tests"""
project = self.testdata_path + "test+project_inspire.qgs"
assert os.path.exists(project), "Project file not found: " + project

@@ -0,0 +1,21 @@
Content-Length: 360
Content-Type: text/html; charset=utf-8

<HEAD>
<TITLE> GetFeatureInfo results </TITLE>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
</HEAD>
<BODY>
<TABLE border=1 width=100%>
<TR><TH width=25%>Layer</TH><TD>testlayer èé</TD></TR>
</BR><TABLE border=1 width=100%>
<TR><TH>Feature</TH><TD>2</TD></TR>
<TR><TH>id</TH><TD>3</TD></TR>
<TR><TH>name</TH><TD>three</TD></TR>
<TR><TH>utf8nameè</TH><TD>three èé↓</TD></TR>
<TR><TH>geometry</TH><TD>Point (913204.9128 5606011.4565)</TD></TR>
</TABLE>
</BR>
</TABLE>
<BR></BR>
</BODY>
@@ -0,0 +1,12 @@
Content-Length: 157
Content-Type: text/plain; charset=utf-8

GetFeatureInfo results

Layer 'testlayer èé'
Feature 2
id = '3'
name = 'three'
utf8nameè = 'three èé↓'
geometry = 'Point (913204.9128 5606011.4565)'

0 comments on commit bf583c7

Please sign in to comment.
You can’t perform that action at this time.