CFHTTP Stream Feature LDEV-3377

I was looking at the changelog for 5.3.8.139, and saw this:

LDEV-3377- tag cfhttp stream support

In the bug comments it says:

I changed the tag as follow, if the attribute “result“ is set to an empty string, the data do not get loaded into memory and if the attribute “file“ exists the data get stored into that file (as before).
In short, set “result“ to an empty string to avoid data in memory.

What if I want to use other parts of the result such as the status code, or http headers?

Wouldn’t it be better if we had a new attribute that would just avoid loading filecontent into memory, but keep other parts of the result metadata available? I haven’t checked to see if those are available via the cfhttp.statusCode, but for scoping purposes I’d rather use the result attribute.

Thanks,

Pete Freitag
Foundeo Inc.

@pfreitag this was added as an experimental/hidden feature to Lucee 5.3.8. The goal was to add this feature without changing the tag itself in any way and do not break any existing code that did work before.

This was added for a user that was blocked by the limitation of that tag, he was running OutOfMemory because he did cfhttp calls for very large downloads.
using filecopy instead was not an option because the “http” virtual filesystem does not support authentication what he needed.
https://luceeserver.atlassian.net/browse/LDEV-3376

You will also see that this feature is not documented anywhere and it is highly possible we will remove it again in Lucee 6, if we have a proper solution for this.

I totally agree with your assessment, ATM i see 2 ways to implement this properly:

  1. [LDEV-3376] - Lucee
  2. extend the tag cfhttp or create a new function for http calls that gives more control over how the data are provided.

I personally would prefer a new function because i think the cfhttp tag already is for to overloaded with functionality that for example like reading csv files seem outdated.

I personally would like to see a solution like this:

http(url:"http://lucee.org",async:true,listener:function (statusCode,statusText,fileContent) {});

and depending on the arguments you define with the listener function the data get provided, so we only provide the data you are requesting.

4 Likes

Thanks for the feedback @micstriit

The new function idea looks cool, maybe it could be an extension even?

While we’re at it, we need a way to support remote http sessions, without looping over cookies!

2 Likes

@pfreitag @micstriit No new functionality is needed here IMO. Adobe CF has already solved this out-of-the-box and Lucee just needs to copy their implementation.

In Adobe CF, when you specify the path/file attribute, the following happens:

  • the HTTP response is streamed DIRECTLY to disk and never stored in memory
  • The standard cfhttp result is returned with request headers, etc
  • The fileContent variable is NOT populated since the file contents are not stored in memory.

https://luceeserver.atlassian.net/browse/LDEV-4357