Open rg2011 opened 5 months ago
I've tested with
req.get('content-type').includes('application/soap+xml')
but doesn't work.
I've tested with
req.get('content-type').includes('application/soap+xml')
but doesn't work.
Hi Alvaro. I understand you were able to replicate the issue with a test, or something like the snippet:
export TAB=$'\t'
curl -H "Content-Type: application/soap+xml;${TAB}charset=utf-8" "http://<iota json ip>:7897/iot/json/attrs/payload?i=<deviceid>&k=<apikey>" -d '<?xml version="1.0"?><body><attrib>value</attrib></body>"
But changing req.is
to req.get('content-type').includes(...)
was not enough to fix it. Is that right?
I am working in a forked branch, and found some other changes are needed too. Let me open a PR so we can discuss the details more easily.
IoT Agent JSON version the issue has been seen with
3.1.0
Bound or port used (API interaction)
Southbound (Devices data API)
NGSI version
NGSIv2
Are you running a container?
Yes, I am using a contaner (Docker, Kubernetes...)
Image type
normal
Expected behaviour you didn't see
This is a follow-up to issue https://github.com/telefonicaid/iotagent-json/issues/759. The XML service integration still fails because the client includes a
"\t"
character in the Content-Type header.When sending a measure with content-type
"application/soap+xml;\tcharset=utf-8"
to/iot/json/attrs/<name of attrib>
, the request should be accepted according to https://github.com/telefonicaid/iotagent-json/pull/771Unexpected behaviour you saw
The IoT Agent replies inmediately with "400 Bad Content".
This is because the
type-is
module, used internally by express, fails to match this content-type toapplication/soap+xml
:This causes the following checks to fail:
https://github.com/telefonicaid/iotagent-json/blob/db402996729536d42e94ce70101bdfd896a793ea/lib/bindings/HTTPBinding.js#L75-L83
https://github.com/telefonicaid/iotagent-json/blob/db402996729536d42e94ce70101bdfd896a793ea/lib/bindings/HTTPBinding.js#L109-L115
And also an internal test in the
bodyparser-xml
dependency, which performs its own content-type check, matching to['*/xml', '+xml']
by default:Removing the
\t
makestype-is
recognize the content-type properly:I did open an issue upstream: https://github.com/jshttp/type-is/issues/52
But I don't expect a fix to reach express anytime soon, so maybe we would need a workaround.
Steps to reproduce the problem
Configs
Log output