User Guide
cfhttp 181
Building a query from a delimited text file
The cfhttp tag can create a ColdFusion query object form the response body. To do so, the
response body must consist of lines of text, with each line having fields that are delimited by a
character that identifies the column breaks. The default delimiter is a comma (,). The response
data can also use a text qualifier; the default is a double quotation mark ("). If you surround a
string field in the text qualifier, the field can contain the delimiter character. To include the text
qualifier in field text, escape it by using a double character. The following line shows a two-line
request body that is converted into a query. It has three comma-delimited fields:
Field1,Field2,Field3
"A comma, in text","A quote: ""Oh My!""",Plain text
Run the following code to show how ColdFusion treats this data:
<cfhttp method="Get"
url="127.0.0.1:8500/tests/escapetest.txt"
name="onerow">
<cfdump var="#onerow#"><br>
Column names can be specified in three ways:
• By default, ColdFusion uses the first row of the response as the column names.
• If you specify a comma-delimited columns attribute, ColdFusion uses the names specified in
the attribute as the column names. Set
firstRowAsHeaders="No" if the first row of the
response contains data. Otherwise, ColdFusion ignores the first row.
• If you do not specify a columns attribute and set firstrowasheaders="No", ColdFusion
generates column names of the form Column_1, Column2, etc.
The
cfhttp tag checks to ensure that column names in the data returned by the tag start with a
letter and contain only letters, numbers, and underscores (_).
ColdFusion checks for invalid column names. Column names must start with a letter. The
remaining characters can be letters, numbers, or underscores (_). If a column name is not valid,
ColdFusion generates an error.
Notes
• For the ColdFusion MX Administrator timeout and the URL timeout to take effect, you must
enable the timeout in the ColdFusion MX Administrator, Server Settings page. For more
information, see Configuring and Administering ColdFusion MX.
• The cfhttp tag supports Basic Authentication for all operations. However, Basic
Authentication does not work if your web server has Windows NT Challenge/Response
(Microsoft IIS) enabled.
• The cfhttp tag uses SSL to negotiate secure transactions.
• If you put the HTTP response body in a file, ColdFusion does not put it in the
CFHTTP.FileContent variable or generate a query object. If you do not put the response body
in a file, ColdFusion puts it in the CFHTTP.FileContent variable; if you specify a
name
attribute ColdFusion generates a query object.
• The cfhttp tag does not support NTLM or Digest Authentication with proxy servers. If a
proxy server requires authentication, it must allow Basic Authentication.
Example
<!--- This example displays the information provided by the Macromedia
Designer & Developer Center XML feed,