CFHTTP "Connection Failures" issues with Gzip

Posted by Dan on Mar 13, 2006 @ 9:52 PM

I've been playing around with Port80's Gzip compression filter, httpZip, on my development server and realized I was having a problems with CFHTTP calls. A quick search on Google pulled up a blog post by Steven Erat titled Workaround for CFHTTP and Compressed HTTP Response from IIS.

My problem differed slightly in that the very first request to a URL (via a CFHTTP request) works fine, but subsequent hits return a "Connection Failure" error. Unfortunately Steven's suggestion didn't work for me, but after some playing around with syntax I was able to come up with some solutions that do work:

  1. When configuring httpZip, set up all compressed mime types to exclude anything with the header "ColdFusion" and "CFSCHEDULE". This will fix the issue with any default CFHTTP calls (Schedule Tasks, CFCACHE, or CFHTTP calls where no "user agent" is specified) If you're manually setting the "user agent" in the CFHTTP call, see one of the following solutions.
  2. NOTE:
    After some more testing, it appears CFMX 7 reports the user agent string of "CFSCHEDULE" and not "ColdFusion". This means you should also add the "CFSCHEDULE" string along with the string "ColdFusion" to your MIME type exceptions list.
  3. Pass in a <cfhttpparam type="header" name="Accept-Encoding" value="*" />. For some reason Steve's suggestion did not work for my setup, but passing in the asterisks value did work. Including this header information prevented me from getting the "Connection Failure" message again.
  4. The last method is to add custom header to the page serving up content, which tells the httpZip ISAPI filter to ignore compressing the request: <cfheader name="httpZip" value="no-compression" />. You could use this technique and have all your CFML pages look for the custom header labelled "Gzip-Disabled". If the custom header exists and is set to "true", you then could execute the CFHEADER tag to tell the ISAPI filter not to compress the page. This would give you the ability to dynamic control the compression of httpZip from within your code.
  5. NOTE:
    You could pass in the httpZip to your initial call and just pass that value back to the CFHEADER output stream, but that opens your page up to be controlled from an outside source. I prefer to just allow the compression to be enabled or disabled on request.
Categories: HTML/ColdFusion


  • Nice! I added:

    <cfhttpparam type="header" name="Accept-Encoding" Value="no-compression">

    and I was able to get the data back from Thomson (formerly CCBN).
  • Rock on !!! Number 3 (no-compression) worked for me!
  • yes no-compression works for get but what about post? i realize this post is 4 years old , Ben your cfhttpsession doesnt pass the proper header to do this , im trying to fix it :-(

Comments for this entry have been disabled.