Tag <CFHTTP>
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.
Body
This tag may have a body.
Example
<cfhttp [addtoken="boolean"] [authtype="string"] [charset="string"] [columns="string"] [compression="string"] [delimiter="string"] [domain="string"] [encoded="boolean"] [file="string"] [firstrowasheaders="boolean"] [getasbinary="string"] [method="string"] [multipart="boolean"] [multiparttype="string"] [name="string"] [password="string"] [path="string"] [port="number"] [preauth="boolean"] [proxypassword="string"] [proxyport="number"] [proxyserver="string"] [proxyuser="string"] [redirect="boolean"] [resolveurl="boolean"] [result="string"] [textqualifier="string"] [throwonerror="boolean"] [timeout="number"] url="string" [useragent="string"] [username="string"] [workstation="string"]> [</cfhttp>]
This tag is also supported within cfscript
<cfscript> http [addtoken="boolean"] [authtype="string"] [charset="string"] [columns="string"] [compression="string"] [delimiter="string"] [domain="string"] [encoded="boolean"] [file="string"] [firstrowasheaders="boolean"] [getasbinary="string"] [method="string"] [multipart="boolean"] [multiparttype="string"] [name="string"] [password="string"] [path="string"] [port="number"] [preauth="boolean"] [proxypassword="string"] [proxyport="number"] [proxyserver="string"] [proxyuser="string"] [redirect="boolean"] [resolveurl="boolean"] [result="string"] [textqualifier="string"] [throwonerror="boolean"] [timeout="number"] url="string" [useragent="string"] [username="string"] [workstation="string"] { } </cfscript>
Attributes
The attributes for this tag are fixed. Except for the following attributes no other attributes are allowed.
Name | Type | Required | Description |
---|---|---|---|
addtoken | boolean | No | if yes add urltoken as cookie |
authtype | string | No | authentication type for a request with username and password, valid values are "BASIC" (default) and "NTLM" |
charset | string | No | set the charset for the call. |
columns | string | No | Specifies the column names for a query when creating a query as a result of a cfhttp GET. |
compression | string | No | Informs the target webserver to disable compression for the response. Possible values are: |
delimiter | string | No | Required for creating a query. Options are a tab or comma. Default is a comma. |
domain | string | No | The domain to authenticate within. this attribute is only used when authenication type is "NTLM" |
encoded | boolean | No | if set to true (default value) URL encodes the value of the attribute "URL" if necessary (no double encoding is happeing). This setting has no influence on the values from httpparam type="url", for this use the attribute "encoded" from httpparam |
file | string | No | 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. |
firstrowasheaders | boolean | No | sets if first row of csv is file |
getasbinary | string | No | - false: If CFML does not recognize the response body type as text, convert it to a CFML object. |
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. |
multipart | boolean | No | Tells Railo to send all data specified by cfhttpparam type="formField" tags as multipart form data, with a Content-Type of multipart/form-data. |
multiparttype | string | No | alias for multiparttype |
name | string | No | The name to assign to a query if the a query is constructed from a file. |
password | string | No | When required by a server, a valid password. |
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. |
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. |
preauth | boolean | No | if set to true (default), Railo sends the basic authentication (username password) always (Preemptive Basic Authentication), if set to false the authentication is only send when the server ask for it (status code 401). |
proxypassword | string | No | When required by a proxy server, a valid password. |
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. |
proxyserver | string | No | Host name or IP address of a proxy server. |
proxyuser | string | No | When required by a proxy server, a valid username. |
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. Railo will follow up to five redirections on a request. if this limit is exceeded, Railo behaves as if redirect = "no". |
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. |
result | string | No | return variable name, default "cfhhtp" |
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 ("). |
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. |
timeout | number | No | A value, in seconds. When a URL timeout is specified in the browser, the timeout attribute setting takes precedence over the Railo Administrator timeout. The 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, Railo takes the lesser of the Railo 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 Railo Administrator, and no timeout set with the timeout attribute, Railo waits indefinitely for the cfhttp request to process. |
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. |
useragent | string | No | User agent request header. |
username | string | No | When required by a server, a valid username. |
workstation | string | No | The workstation the authentication request is originating from. Essentially, the computer name for this machine. this attribute is only used when authenication type is "NTLM" |