Do not create xml or json when request does not look like xml or json
This commit is contained in:
parent
3fcfec451a
commit
2b57ba0806
1 changed files with 7 additions and 1 deletions
|
@ -27,6 +27,9 @@ class MockRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static GPathResult inputToXml(String text) {
|
private static GPathResult inputToXml(String text) {
|
||||||
|
if (!text.startsWith('<')) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return new XmlSlurper().parseText(text)
|
return new XmlSlurper().parseText(text)
|
||||||
} catch (Exception _) {
|
} catch (Exception _) {
|
||||||
|
@ -36,7 +39,7 @@ class MockRequest {
|
||||||
|
|
||||||
private static GPathResult inputToSoap(GPathResult xml) {
|
private static GPathResult inputToSoap(GPathResult xml) {
|
||||||
try {
|
try {
|
||||||
if (xml.name() == 'Envelope' && xml.Body.size() > 0) {
|
if (xml != null && xml.name() == 'Envelope' && xml.Body.size() > 0) {
|
||||||
return getSoapBodyContent(xml)
|
return getSoapBodyContent(xml)
|
||||||
} else {
|
} else {
|
||||||
return null
|
return null
|
||||||
|
@ -51,6 +54,9 @@ class MockRequest {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object inputToJson(String text) {
|
private static Object inputToJson(String text) {
|
||||||
|
if (!text.startsWith('[') && !text.startsWith('{')) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
return new JsonSlurper().parseText(text)
|
return new JsonSlurper().parseText(text)
|
||||||
} catch (Exception _) {
|
} catch (Exception _) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue