Payload being truncated when returned by a http node

776 views
Skip to first unread message

Andrew Taylor

unread,
Oct 14, 2015, 9:30:44 AM10/14/15
to Node-RED

Basically, my http output contents is getting truncated if do a http request in my flow


A picture speaks a thousand words, so here are some test flows with their outputs:




Basically, I'm requesting a URL in the http request node (http://ipinfo.io/9.20.0.0/region), and then attempting to add it into a template, which is then returned to the user via the http node. For some reason, the payload string gets truncated when returned to the browser, whereas the debug node prints the correct text. The comment nodes above show the output I see in each case. I'm using the default Template with the moustache variable replacement text.

If I get a shorter string back from the http request, I get less text back.
I get GB\n for /country, then only get "Thi".
For "England\n" I get "This is ", so it looks like the http data length is being overridden by the http request's data length, and truncated. I get everything in the last flow because the two are the same length.

Should this work? I was hoping that I could include fetching various data from different webservices in the contents of my page.

p.s. I'm using a Node-RED environment in Bluemix, created 2 weeks ago from the Node-RED boilerplate application install

Nicholas O'Leary

unread,
Oct 14, 2015, 9:33:32 AM10/14/15
to Node-RED Mailing LIst
You need to add a Change node after your HTTP Request node to delete the msg.headers property. This is how the response headers from the request node are being passed to the http response node and overriding what headers get sent back - including content-length.

Nick

--
http://nodered.org
---
You received this message because you are subscribed to the Google Groups "Node-RED" group.
To unsubscribe from this group and stop receiving emails from it, send an email to node-red+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Taylor

unread,
Oct 14, 2015, 9:52:36 AM10/14/15
to Node-RED
Excellent, thanks Nick!

I tried stashing the .req and .res variables, but it seems the .headers one was the one I needed :)
Reply all
Reply to author
Forward
0 new messages