Navigation Menu

Skip to content

Commit

Permalink
[Server] Request handler reads the document root attributes to expose…
Browse files Browse the repository at this point in the history
… parameters
  • Loading branch information
rldhont committed Oct 12, 2017
1 parent b8ebbc1 commit 5d2c035
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions src/server/qgsrequesthandler.cpp
Expand Up @@ -241,15 +241,27 @@ void QgsRequestHandler::parseInput()
setupParameters();

QDomElement docElem = doc.documentElement();
if ( docElem.hasAttribute( QStringLiteral( "version" ) ) )
{
mRequest.setParameter( QStringLiteral( "VERSION" ), docElem.attribute( QStringLiteral( "version" ) ) );
}
if ( docElem.hasAttribute( QStringLiteral( "service" ) ) )
// the document element tag name is the request
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
// loop through the attributes which are the parameters
// excepting the attributes started by xmlns or xsi
QDomNamedNodeMap map = docElem.attributes();
for ( int i = 0 ; i < map.length() ; ++i )
{
mRequest.setParameter( QStringLiteral( "SERVICE" ), docElem.attribute( QStringLiteral( "service" ) ) );
if ( map.item( i ).isNull() )
continue;

QDomNode attrNode = map.item( i );
QDomAttr attr = attrNode.toAttr();
if ( attr.isNull() )
continue;

QString attrName = attr.name();
if ( attrName.startsWith( "xmlns" ) || attrName.startsWith( "xsi:" ) )
continue;

mRequest.setParameter( attrName.toUpper(), attr.value() );
}
mRequest.setParameter( QStringLiteral( "REQUEST" ), docElem.tagName() );
mRequest.setParameter( QStringLiteral( "REQUEST_BODY" ), inputString );
}
}
Expand Down

0 comments on commit 5d2c035

Please sign in to comment.