Return XML-RPC answer only to XML-RPC request
This prevents to answer an XML-RPC fault to a request which only set xml as accepted mimetype. issue7913 review66481002
This commit is contained in:
1 parent
55619becda
commit
e5bf50805d
1 file changed
+14
-9
@@ -9,7 +9,7 @@ from decimal import Decimal
|
||||
|
||||
from werkzeug.wrappers import Response
|
||||
from werkzeug.utils import cached_property
|
||||
from werkzeug.exceptions import BadRequest
|
||||
from werkzeug.exceptions import BadRequest, InternalServerError
|
||||
|
||||
from trytond.protocols.wrappers import Request
|
||||
from trytond.exceptions import TrytonException
|
||||
@@ -167,12 +167,17 @@ class XMLProtocol:
|
||||
|
||||
@classmethod
|
||||
def response(cls, data, request):
|
||||
if isinstance(data, TrytonException):
|
||||
data = client.Fault(data.code, str(data))
|
||||
elif isinstance(data, Exception):
|
||||
data = client.Fault(255, str(data))
|
||||
if isinstance(request, XMLRequest):
|
||||
if isinstance(data, TrytonException):
|
||||
data = client.Fault(data.code, str(data))
|
||||
elif isinstance(data, Exception):
|
||||
data = client.Fault(255, str(data))
|
||||
else:
|
||||
data = (data,)
|
||||
return Response(client.dumps(
|
||||
data, methodresponse=True, allow_none=True),
|
||||
content_type='text/xml')
|
||||
else:
|
||||
data = (data,)
|
||||
return Response(client.dumps(
|
||||
data, methodresponse=True, allow_none=True),
|
||||
content_type='text/xml')
|
||||
if isinstance(data, Exception):
|
||||
return InternalServerError(data)
|
||||
return Response(data)
|
||||
Reference in new issue
Block a user