CFHTTP  
 
 

The CFHTTP tag allows you to execute POST and GET operations on files. Using CFHTTP, you can execute standard GET operations as well as create a query object from a text file. POST operations allow you to upload MIME file types to a server, or post cookie, formfield, URL, file, or CGI variables directly to a specified server.

 
 
  Syntax  
 
<CFHTTP URL="hostname"
    PORT="port_number"
    METHOD="get_or_post"
    USERNAME="username"
    PASSWORD="password"
    NAME="queryname"
    COLUMNS="query_columns"
    PATH="path"
    FILE="filename"
    DELIMITER="character"
    TEXTQUALIFIER="character"
    RESOLVEURL="Yes/No"
    PROXYSERVER="hostname">
</CFHTTP>

 
 
  Note  
 

Terminate CFHTTP POST operations with </CFHTTP>. Termination is not required with CFHTTP GET operations.

URL

Required. Full URL of the host name or IP address of the server on which the file resides.

PORT

Optional. The port number on the server from which the object is being requested. Default is 80. When used with RESOLVEURL, the URLs of retrieved documents that specify a port number are automatically resolved to preserve links in the retrieved document.

METHOD

Required. GET or POST. Use GET to download a text or binary file, or to create a query from the contents of a text file. Use POST to send information to a server page or a CGI program for processing. POST requires the use of a CFHTTPPARAM tag.

USERNAME

Optional. When required by a server, a valid username.

PASSWORD

Optional. When required by a server, a valid password.

NAME

Optional. The name to assign to a query when a query is to be constructed from a file.

COLUMNS

Optional. The column names for a query. If no column names are specified, defaults to the columns listed in the first row of a text file.

PATH

Optional. The path to the directory in which a file is to be stored. If a path is not specified in a POST or GET operation, a variable is created (CFHTTP.FileContent) that you can use to present the results of the POST operation in a CFOUTPUT.

FILE

Required in a POST operation if PATH is specified. The filename to be used for the file that is accessed. For GET operations, defaults to the name specified in URL. Enter path information in the PATH attribute.

DELIMITER

Required for creating a query. Valid characters are a tab or comma. Default is a comma ( , ).

TEXTQUALIFIER

Required for creating a query. Indicates the start and finish of a column. Should be appropriately escaped when embedded in a column. For example, if the qualifier is a quotation mark, it should be escaped as """". If there is no text qualifier in the file, specify a blank space as " ". Default is the quote mark ( " ).

RESOLVEURL

Optional. Yes or No. Default is No. For GET and POST operations, when Yes, any page reference returned into the FileContent internal variable will have its internal URLs fully resolved, including port number, so that links remain intact. The following HTML tags, which can contain links, will be resolved:

  • IMG SRC
  • A HREF
  • FORM ACTION
  • APPLET CODE
  • SCRIPT SRC
  • EMBED SRC
  • EMBED PLUGINSPACE
  • BODY BACKGROUND
  • FRAME SRC
  • BGSOUND SRC
  • OBJECT DATA
  • OBJECT CLASSID
  • OBJECT CODEBASE
  • OBJECT USEMAP

PROXYSERVER

Optional. Host name or IP address of a proxy server.

 
 
  Usage  
 

Note the following:

  • HTTP GET -- A user can specify a URL that points to a text or binary file. The file will be downloaded and its contents stored in a CF variable or in a file so that the user can manipulate the data. The internal variable FileContent is available for text and MIME file types. The MimeType variable is available for all file manipulations. These variables can be accessed in the following manner:

    #CFHTTP.FileContent#

    #CFHTTP.MimeType#

  • GET file into a query -- To download a file in a ColdFusion page so that a query can be built using the file, the file must be either comma-separated or tab-delimited. Although risky, text qualification may be omitted. The file will be parsed and an appropriate query built from it. Columns may be specified in the attribute list so that the client can override the columns specified in the file. There is error checking within the tag that prevents a user from either entering an invalid column name or using an invalid column name that was specified in the original file. If such an illegal filename is encountered, the illegal characters are stripped. Such action could produce duplicate column names, so duplicate columns are renamed and inserted into the query header. The query has all of the functionality of a standard CFQUERY object.
  • HTTP POST -- CFHTTPPARAM tags can be nested inside a CFHTTP tag in a POST operation. The browser can be pointed to a URL specifying a CGI executable or a ColdFusion page. Since multiple CFHTTPPARAM tags can be nested in one CFHTTP tag, you can construct a multipart/form-data style post. A file content variable is created and this can be used in a CFOUTPUT. If PATH and FILE are specified, the data returned from the server is saved to the specified location.
  • Authentication -- CFHTTP supports Windows NT Basic Authentication for both GET and POST operations. However, Basic Authentication will not work if your Web server has enabled Windows NT Challenge/Response (Microsoft IIS).
  • Encryption -- To verify the encryption version used with SSL, access the schannel.dll file in the windows\system directory and display its properties. The Version tab lists a Description item, which displays one of the following:
    • US and Canada -- 128 bit encryption
    • Export -- 40 bit

      SSL is not supported by ColdFusion running on UNIX.





 
 
BackUp LevelNext
 
 

allaire     AllaireDoc@allaire.com
    Copyright © 1998, Allaire Corporation. All rights reserved.