O'Reilly logo

Programming ColdFusion MX, 2nd Edition by Rob Brooks-Bilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieving Information

cfhttp uses the HTTP GET method to initiate a one-way request for information from a remote server. The transaction mimics the one that a standard web browser uses to request a web page. The only difference is that in the case of cfhttp, the requested page is stored in a ColdFusion variable or in a query object, as opposed to being displayed in the user’s browser. Let’s look at the different ways in which you can use cfhttp to request information from a remote server.

Saving Information to a Variable

In its most simplistic form, cfhttp can grab an entire file (either plain text or HTML) and store it in a single variable called cfhttp.FileContent. You can access and manipulate the information stored in cfhttp.FileContent as you can with any other ColdFusion variable. cfhttp.FileContent is only one return variable made available by the cfhttp tag. All cfhttp operations return a structure called cfhttp that contains information returned by the target server. Depending on the HTTP operation performed (as defined by the method attribute) as well as the response returned by the target server, the cfhttp structure may or may not contain values for the following keys:

cfhttp.charset

Character encoding specified by the response Content-Type header.

cfhttp.errorDetail

In the event of a connection failure, contains details related to the failure. If no failure occurs, this key contains an empty string.

cfhttp.fileContent

Contains the response body resulting from ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required