Friday, July 11, 2008

HTTP is a Built-In ColdFusion Scope?

While using cfhttp yesterday, I noticed something interesting.

I was running a small test page that made a cfhttp calls and then used cfdump to display the results to the screen. Though the script executed without error, the results seemed wrong... and yet very familiar. It took me a second before I realized why. The results looked exactly like a dump of the CGI scope. So I went back and checked my code and found that I had accidentally dumped HTTP instead of CFHTTP:


<cfdump var="#HTTP#">


Based on the results, HTTP seems to be a built-in scope. I was a little surprised because I could not recall reading anything about a scope by that name. Curious, I used a few of the underlying java methods to examine the HTTP and CGI objects more closely. Sure enough java reported the two objects were both instances of the class coldfusion.runtime.CgiScope and that the two were equal.


<cfoutput>
HTTP.equals(CGI) = #HTTP.equals(CGI)#<br>
HTTP.getClass() = #HTTP.getClass().getName()#<br>
CGI.getClass() = #CGI.getClass().getName()#
</cfoutput>



So apparently HTTP is another another way of referencing the CGI scope. Now while I strongly suspect that is _not_ new to ColdFusion, it was certainly news to me ;-)

0 comments:

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Header image adapted from atomicjeep