Do not create xml or json when request does not look like xml or json

This commit is contained in:
Dominik Przybysz 2017-05-30 12:54:36 +02:00
parent 3fcfec451a
commit 2b57ba0806

View file

@ -27,6 +27,9 @@ class MockRequest {
}
private static GPathResult inputToXml(String text) {
if (!text.startsWith('<')) {
return null
}
try {
return new XmlSlurper().parseText(text)
} catch (Exception _) {
@ -36,7 +39,7 @@ class MockRequest {
private static GPathResult inputToSoap(GPathResult xml) {
try {
if (xml.name() == 'Envelope' && xml.Body.size() > 0) {
if (xml != null && xml.name() == 'Envelope' && xml.Body.size() > 0) {
return getSoapBodyContent(xml)
} else {
return null
@ -51,6 +54,9 @@ class MockRequest {
}
private static Object inputToJson(String text) {
if (!text.startsWith('[') && !text.startsWith('{')) {
return null
}
try {
return new JsonSlurper().parseText(text)
} catch (Exception _) {