Skip to content

Commit 5d2c035

Browse files
committedOct 12, 2017
[Server] Request handler reads the document root attributes to expose parameters
1 parent b8ebbc1 commit 5d2c035

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed
 

‎src/server/qgsrequesthandler.cpp

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,27 @@ void QgsRequestHandler::parseInput()
241241
setupParameters();
242242

243243
QDomElement docElem = doc.documentElement();
244-
if ( docElem.hasAttribute( QStringLiteral( "version" ) ) )
245-
{
246-
mRequest.setParameter( QStringLiteral( "VERSION" ), docElem.attribute( QStringLiteral( "version" ) ) );
247-
}
248-
if ( docElem.hasAttribute( QStringLiteral( "service" ) ) )
244+
// the document element tag name is the request
245+
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
246+
// loop through the attributes which are the parameters
247+
// excepting the attributes started by xmlns or xsi
248+
QDomNamedNodeMap map = docElem.attributes();
249+
for ( int i = 0 ; i < map.length() ; ++i )
249250
{
250-
mRequest.setParameter( QStringLiteral( "SERVICE" ), docElem.attribute( QStringLiteral( "service" ) ) );
251+
if ( map.item( i ).isNull() )
252+
continue;
253+
254+
QDomNode attrNode = map.item( i );
255+
QDomAttr attr = attrNode.toAttr();
256+
if ( attr.isNull() )
257+
continue;
258+
259+
QString attrName = attr.name();
260+
if ( attrName.startsWith( "xmlns" ) || attrName.startsWith( "xsi:" ) )
261+
continue;
262+
263+
mRequest.setParameter( attrName.toUpper(), attr.value() );
251264
}
252-
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
253265
mRequest.setParameter( QStringLiteral( "REQUEST_BODY" ), inputString );
254266
}
255267
}

0 commit comments

Comments
 (0)
Please sign in to comment.