3-1-Tags:CFHttp
last edited by
lmajano
on 23-Aug-2009
cfhttp
Description
Lets you execute HTTP POST and GET operations on files. Using cfhttp, you can execute standard GET operations and create a query object from a text file. POST operations lets you upload MIME file types to a server, or post cookie, formfield, URL, file, or CGI variables directly to a specified server.
Category
Other
Implemented
Usage Syntax
<cfhttp url="String" [result="String"] [addtoken="Boolean"] [port="number"] [method="String"] [username="String"] [multipart="Boolean"] [getAsBinary="String"] [password="String"] [name="String"] [columns="String"] [path="String"] [file="String"] [delimiter="String"] [textQualifier="String"] [resolveURL="Boolean"] [proxyServer="String"] [proxyPort="number"] [proxyUser="String"] [proxyPassword="String"] [userAgent="String"] [throwOnError="Boolean"] [redirect="Boolean"] [timeout="number"] [charset="String"] [firstrowasheaders="Boolean"] />
[] = Optional attribute
Attributes
| Name | Type | Required | Default | Description |
| url | String | Yes | Full URL of the host name or IP address of the server on which the file resides. The URL must be an absolute URL, including the protocol (http or https) and hostname. It may optionally contain a port number. Port numbers specified in the url attribute override the port attribute. | |
| result | String | No | return variable name, default "cfhhtp" | |
| addtoken | Boolean | No | if yes add urltoken as cookie | |
| port | number | No | The port number on the server from which the object is 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. If a port number is specified in the url attribute, the port value overrides the value of the port attribute. | |
| method | String | No | 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 | String | No | When required by a server, a valid username. | |
| multipart | Boolean | No | ||
| getAsBinary | String | No | ||
| password | String | No | When required by a server, a valid password. | |
| name | String | No | The name to assign to a query if the a query is constructed from a file. | |
| columns | String | No | Specifies the column names for a query when creating a query as a result of a cfhttp GET. By default, the first row of a text file is interpreted as column headings. If there are column headers in the text file from which the query is drawn, do not specify this attribute except to overwrite them. When duplicate column heading names are encountered, ColdFusion appends an underscore character to the duplicate column name to make it unique. If there are no column headers in the text file, or to override those in the file, you must specify the columns attribute. However ColdFusion never treats the first row of the file as data, even if you specify the columns attribute. | |
| path | String | No | 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 display the results of the POST operation in a cfoutput. | |
| file | String | No | The filename to be used for the file that is accessed. For GET operations, defaults to the name pecified in url. Enter path information in the path attribute. | |
| delimiter | String | No | Required for creating a query. Options are a tab or comma. Default is a comma. | |
| textQualifier | String | No | 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 double quotation mark, it should be escaped as """". If there is no text qualifier in the file, specify it as " ". Default is the double quotation mark ("). | |
| resolveURL | Boolean | No | Yes or No. Default is No. For GET and POST operations, if Yes, page reference returned into the fileContent internal variable has its internal URLs fully resolved, including port number, so that links remain intact. | |
| proxyServer | String | No | Host name or IP address of a proxy server. | |
| proxyPort | number | No | The port number on the proxy server from which the object is 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. | |
| proxyUser | String | No | When required by a proxy server, a valid username. | |
| proxyPassword | String | No | When required by a proxy server, a valid password. | |
| userAgent | String | No | User agent request header. | |
| throwOnError | Boolean | No | Boolean indicating whether to throw an exception that can be caught by using the cftry and cfcatch tags. The default is NO. | |
| redirect | Boolean | No | Boolean indicating whether to redirect execution or stop execution. The default is Yes. If set to No and throwOnError = "yes", execution stops if cfhttp fails, and the status code and associated error message are returned in the variable cfhttp.statuscode. To see where execution would have been redirected, use the variable cfhttp.responseHeader[LOCATION]. The key LOCATION identifies the path of redirection. ColdFusion will follow up to five redirections on a request. if this limit is exceeded, ColdFusion behaves as if redirect = "no". | |
| timeout | number | No | A value, in seconds. When a URL timeout is specified in the browser, the timeout attribute setting takes precedence over the ColdFusion Administrator timeout. The ColdFusion server then uses the lesser of the URL timeout and the timeout passed in the timeout attribute, so that the request always times out before or at the same time as the page times out. If there is no URL timeout specified, ColdFusion takes the lesser of the ColdFusion Administrator timeout and the timeout passed in the timeout attribute. If there is no timeout set on the URL in the browser, no timeout set in the ColdFusion Administrator, and no timeout set with the timeout attribute, ColdFusion waits indefinitely for the cfhttp request to process. | |
| charset | String | No | set the charset for the call. | |
| firstrowasheaders | Boolean | No | sets if first row of csv is file |
SideBar
User Login
Comments (