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.

This tag may have a body.

This tag is also supported within <cfscript>

<cfhttp url=string encodeurl=boolean compression=string result=string addtoken=boolean port=number method=string username=string password=string preauth=boolean multipart=boolean multiparttype=string getasbinary=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=any charset=string firstrowasheaders=boolean authtype=string workstation=string domain=string clientcert=string clientcertpassword=string cachedwithin=object ><!--- body --->[</cfhttp>]
Attribute Description
string, required

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.

boolean, optional

if set to true (default value) URL encodes the value of the attribute "URL" if necessary (no double encoding is happening).

This setting has no influence on the values from httpparam type="url", for this use the attribute "encoded" from httpparam

Alias: encoded, encode

string, optional

Informs the target webserver to disable compression for the response. Possible values are:

  • true (default): compression enabled
  • false: compression disabled
  • none (deprecated): use "false" instead
string, optional

return variable name, default "cfhttp"

boolean, optional

if yes add urltoken as cookie

number, optional

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.

string, optional


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.

string, optional

When required by a server, a valid username.

string, optional

When required by a server, a valid password.

boolean, optional

If set to true (default), Lucee sends the basic authentication (username password) always (Preemptive Basic Authentication)

I set to false the authentication is only send when the server ask for it (status code 401).

boolean, optional

Tells Lucee to send all data specified by cfhttpparam type="formField" tags as multipart form data, with a Content-Type of multipart/form-data.

string, optional

This attribute has been deprecated, use instead the attribute "multipart".

* deprecated *
string, optional
  • false: If CFML does not recognize the response body type as text, convert it to a CFML object.
  • auto: If CFML does not recognize the response body type as text, convert it to CFML Binary type data.
  • true: always convert the response body content into CFML Binary type data, even if CFML recognizes the response body type as text.
string, optional

The name to assign to a query if the a query is constructed from a file.

string, optional

Specifies the column names for a query when creating a query as a result of a cfhttp GET.

string, 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 display the results of the POST operation in a cfoutput.

string, optional

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.

string, optional

Used only when creating a query from an http request that returns data in a CSV format.

This value specifies the Field delimiter for the CSV data.

Only the first character is used.

Default is a comma.

string, optional

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 (").

boolean, optional

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.

string, optional

Host name or IP address of a proxy server.

number, optional

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.

string, optional

When required by a proxy server, a valid username.

string, optional

When required by a proxy server, a valid password.

string, optional

Use a custom User-Agent request header.

boolean, optional

Boolean indicating whether to throw an exception that can be caught by using the <cftry> and <cfcatch> tags.

The default is NO.

boolean, optional

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.

Lucee will follow up to five redirections on a request. if this limit is exceeded, Lucee behaves as if redirect = "no".

any, optional

A value, in seconds.

When a URL timeout is specified in the browser, the timeout attribute setting takes precedence over the Lucee 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, Lucee takes the lesser of the Lucee 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 Lucee Administrator, and no timeout set with the timeout attribute, Lucee waits indefinitely for the cfhttp request to process.

string, optional

Sets the charset for the call.

boolean, optional

sets if first row of csv is file

string, optional

Authentication type for a request with username and password, valid values are "BASIC" (default) and "NTLM"

string, optional

The workstation the authentication request is originating from.

Essentially, the computer name for this machine. This attribute is only used when authentication type is "NTLM"

string, optional

The domain to authenticate within. this attribute is only used when authentication type is "NTLM"

string, optional

The full path to a PKCS12 format file that contains the client certificate for the request.

string, optional

Password used to decrypt the client certificate.

object, optional

Supported values are:

  • String "request" (If original content was created within the current request, cached content data is used.)
  • a timespan (created with function CreateTimeSpan)

To use cached data, the tag must be called with the exact same arguments.



<cfhttp url="https://www.google.com" method="get" result="myresult">
<cfdump var="#myresult#">
<cfhttp url="https://www.google.com" method="get" result="myresult">
    <cfhttpparam type="url" name="q" value="Lucee">
<cfdump var="#myresult#">


http url="https://www.google.com" method="get" result="myresult";
//You can also pass parameters in script format
http url="https://www.google.com/search" method="get" result="myresult"{
    httpparam type="url" name="q" value="Lucee";

See also