Migration to Lucee – issue with HTTP variable

Some of the websites we are taking care of are old. By old, I mean the websites written over ten years ago. It is not easy to migrate them to the modern version of ColdFusion and it is even harder to migrate to Lucee 🙂

One of the common issues we are facing is the absence of the HTTP variable scope. In the old versions of ColdFusion, the HTTP scope was used to provide environmental variables providing the context of the current request. The example contents of the HTTP scope looks like this:

<cfdump  var="#http#">
The properties that are used in most cases are related to the server name and script name (http.server_name, http.script_name) but also referer (http.http_referer) and sometimes server port (http.server_port). When we try to use the same in Lucee we get:

Fortunately, the solution to this issue is simple – we should use ‘CGI’ scope instead. Here is the sample CGI scope dump:

I removed some of the variables to make the screenshot more readable, but you should get the idea. Most of the variables are exactly the same.

If you are switching from ColdFusion 10, MX, or earlier, you may find the short versions of HTTP variables, such as ‘http.referer’ or ‘http.host’. In these rare cases, you will have not only to switch from HTTP scope to CGI scope but also to adjust the variable names.