GET request of XML page

I have a RFID reader, which I can call by a HTTP request on address for example:

http://192.168.1.15/status.xml

There is a basic authentication, when I run the address above in chrome browser and then I get a response:

<status>
<netbios>NANO RFID </netbios>
<mac>E8EB1B487A52</mac>
<id>1E009BF6CA</id>
<newId>0</newId>
<cnt>1</cnt>
<resetFlag>1</resetFlag>
<enable>1</enable>
<httpClientStatus>0</httpClientStatus>
<out>0</out>
<in>1</in>
<model>RFID NANO</model>
<fw>0.46</fw>
<hw>1.0</hw>
</status>

When I have tried the http request node, i get this error : RequestError: Parse Error: Invalid header token : http://192.168.1.15/status.xml

When I have checked the headers of the status.xml page, i can see this:
image
image

This is configuration of the node:

The question is - how to get the http request node working? Thanks for help!

What version of Node-RED and node JS are you running? Disable strict didn't work properly prior to node-red v3.1.0

Also, try to show us the raw response from the request - I suspect the device is responding with poorly formatted headers (chrome is more forgiving)

Hello, i am running node red v.3.1.0 and Node JS version 20.9.0.

The response headers I see in chrome is :
HTTP/1.1 200 OK
Connection: close
Content-Type: text/xml
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
Access-Control-Max-Age "1000"
Access-Control-Allow-Headers "x-requested-with, Content-Type, origin, authorization, accept, client-security-token"
Cache-Control: no-cache

Your earlier post:

Your raw post:

Several of them headers are invalid (no : colon) - you should see if the device has a firmware update (or report it to the device maintainers)

That's why Chrome is only showing 4 parsed headers in the image.

This may be an upstream issue with got library or may be Node-RED needs to tell got to ignore invalid headers.

Unfortunately I am away from computers for the next week so can't help further at this point. Hopefully someone else on the forum can help further until I am able to look deeper into the issue.

If this is blocking you and you cannot wait, then you might want to try running cURL via the exec node or importing fetch in a function node.

1 Like

I was trying to use exec node, i set it up like this:

image

I run this command: curl http://192.168.1.15/status.xml -u "admin:admin00"

But the exec node is returning error 8... When i try to run the command in command line in windows, i got:
curl: (8) Header without colon

That backs up my previous statement!

Have you looked for updated firmware? Contacted the device manufacturer?

That would seem to confirm what @Steve-Mcl said - the server is sending an invalid set of headers without : in. Curl error 8 is also "weird reply from server" so yes... need you to fix the server.

1 Like

Such a strict policy :)... I am communicating with manufacturer, I hope they will help.They are from Poland...

yeah I mean the http standard has only been around since 1999 - not like people haven't had a chance to read it yet... :wink:

3 Likes

I think, that developers in China have their own opinion on this standard :). I got new FW for the reader, so I am going to test it now...

So the uppdate of FW helped. Now, the http server is returing good headers and both solution - using http request node and using curl is working OK. Thanks for help.

1 Like

Thank goodness for the power of standards :wink:

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.