Find out what I'm doing, Follow Me :)

Bug in CFHTTP when used inside CFLOOP


Recently came across a really bizarre issue with CFHTTP. Look at the code below:

<cfset variables.protocols = "https://,http://">
<cfset = "">
<cfloop list="#variables.protocols#" index="protocol">
    <cfhttp url="" method="get" timeout="10"/>
    <cfoutput>Status: #cfhttp.StatusCode#<br></cfoutput><cfflush>

See anything wrong with it? No? Well, here is the output I get:

Status: 200 OK
Status: Connection Failure. Status code unavailable.

And no, both the URL's are valid and you can access them through browser or with CFHTTP outside of CFLOOP. Turns out it's a bug in CFHTTP. When CFHTTP is used inside CFLOOP you can't follow an "https" request with "http" request. Huh? Ya, that's what I thought...

I was ready to file a bug report, but before doing that tested it in CF 9 to see what happens and voila, it works!

So, whatever the bug was, it's fixed in CF 9.