The Latest...

The trace attribute of cfhttp

Posted: September 20, 2013 in Web Design

I occasionally find myself using the <cfhttp> tag for link testing.  In our CMS at work, I added a feature to check for valid links in topics, and flag the pages in the database to which a page was no longer associated (sometimes pages will get moved or deleted, but the database entry will remain, like some sort of e-zombie).  There's a tool that checks for these missing pages and deletes the entries, but the other day I noticed a "bug".

If the page has been redirected to a new location, the <cfhttp> tag sees the redirect as a valid link.  Even though the header is sent back as a 301 (Moved Permanently), <cfhttp> reports 200, OK.  This is obviously not ideal.  After doing some debugging, I looked at the tag options for <cfhttp>.  I'd always known about the head and get methods, but I found one I'd never used before.  method="trace".

Using the trace method, <cfhttp> reports the redirects back as 501 errors (Not Implemented?).  I edited the CMS so that rather than checking for a 301 code, I checked for the absense of a 200, and voila! The zombies are eradicated!

I took a look at the livedocs, and here's what it says about "trace":

TRACE: requests that the server echo the received HTTP headers back to the sender in the response body. Trace requests cannot have bodies. This method enables the ColdFusion application to see what is being received at the server, and use that data for testing or diagnostic information

Interesting...  or not.  Despite that rather cryptic explanation (cryptic for me at least), the thing works, so I can live with the livedocs description, and trace doesn't seem any slower than head, which is what I used previously.

Add Comment




Click to reload a new image.

< Back to blog

cydebar...

If you pick up a starving dog and make him prosperous, he will not bite you; that is the principal difference between a dog and a man.

- Mark Twain


Page style: dark / light


Featured Pic


Recent Rides

View all


News


Previous Posts

2015

2014

2013


Categories


Valid XHTML 1.0 Strict Valid CSS!