Whatever message this page gives is out now! Go check it out!
CF.http
({
method:"get or post",
url:"URL",
username:"username",
password:"password",
resolveurl:"yes or no",
params:arrayvar,
path:"path",
file:"filename"
})Arguments | Req/Opt | Description |
|---|---|---|
method | Required | One of two arguments:
|
url | Required | The absolute URL of the host name or IP address of the server on which the file resides. The URL must include the protocol (http or https) and host name. |
username | Optional | When required by a server, a username. |
password | Optional | When required by a server, a password. |
resolveurl | Optional | ForGetandPostmethods.
For GET and POST operations, if Yes, the page reference that is returned into the Filecontent property has its internal URLs fully resolved, including port number, so that links remain intact. The following HTML tags, which can contain links, are 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 |
params | Optional | HTTP parameters passed as an array of objects. Supports the following parameter types:
CF.httpparams are passed as an array of objects. Theparamsargument is required for POST operations. |
path | Optional | The path to the directory in which to store files. When using thepathargument, thefileargument is required. |
file | Optional | Name of the file that is accessed. For GET operations, defaults to the name specified in theurlargument. Enter path information in thepathargument. This argument is required if you are using thepathargument. |
CF.http({method:"method", url:"URL", username:"username", password:"password",
resolveurl:"yes or no", params:arrayvar,
path:"path", file:"filename"});CF.http(url);
CF.http(method, url);
CF.http(method, url, username, password);
CF.http(method, url, params, username, password);Do not use curly braces {} with positional arguments. |
Parameter | Description |
|---|---|
name | The variable name for data that is passed |
type | The transaction type:
|
value | Value of URL, FormField, Cookie, File, or CGI variables that are passed |
Property | Description |
|---|---|
Text | A Boolean value that indicates whether the specified URL location contains text data. |
Charset | The charset used by the document specified in the URL. HTTP servers normally provide this information, or the charset is specified in the charset parameter of the Content-Type header field of the HTTP protocol. For example, the following HTTP header announces that the character encoding is EUC-JP: Content-Type: text/html; charset=EUC-JP |
Header | Raw response header. For example: HTTP/1.1 200 OK Date: Mon, 04 Mar 2002 17:27:44 GMT Server: Apache/1.3.22 (Unix) mod_perl/1.26 Set-Cookie: MM_cookie=207.22.48.162.4731015262864476; path=/; expires=Wed, 03-Mar-04 17:27:44 GMT; domain=adobe.com Connection: close Content-Type: text/html |
Filecontent | File contents, for text and MIME files. |
Mimetype | MIME type. Examples of MIME types include text/html, image/png, image/gif, video/mpeg, text/css, and audio/basic. |
responseHeader | Response header. If there is only one header key, its value can be accessed as simple type. If there are multiple header keys, the values are put in an array in a responseHeader structure. |
Statuscode | HTTP error code and associated error string. Common HTTP status codes returned in the response header include: 400: Bad Request 401: Unauthorized 403: Forbidden 404: Not Found 405: Method Not Allowed |
function basicGet()
{
url = "http://localhost:8100/";
// Invoke with just the url. This is an HTTP GET.
result = CF.http(url);
return result.get("Filecontent");
}function postWithNamedArgs()
{
// Set up the array of Post parameters.
params = new Array();
params[1] = {name:"arg1", type:"FormField", value:"value1"};
params[2] = {name:"arg2", type:"URL", value:"value2"};
params[3] = {name:"arg3", type:"CGI", value:"value3"};
url = "http://localhost:8100/";
path = application.getContext("/").getRealPath("/");
file = "foo.txt";
result = CF.http({method:"post", url:url, username:"karl", password:"salsa",
resolveurl:true, params:params, path:path, file:file});
if (result)
return result.get("Statuscode");
return null;
}
// Example of a basic HTTP GET operation
// Shows that HTTP GET is the default
function basicGet()
{
url = "http://localhost:8100/";
// Invoke with just the url. This is an HTTP GET.
result = CF.http(url);
return result.get("Filecontent");
}
// Example showing simple array created to pass params arguments
function postWithParams()
{
// Set up the array of Post parameters. These are just like cfhttpparam tags.
params = new Array();
params[1] = {name:"arg2", type:"URL", value:"value2"};
url = "http://localhost:8100/";
// Invoke with the method, url, and params
result = CF.http("post", url, params);
return result.get("Filecontent");
}
// Example with username and params arguments
function postWithParamsAndUser()
{
// Set up the array of Post parameters. These are just like cfhttpparam tags.
params = new Array();
params[1] = {name:"arg2", type:"URL", value:"value2"};
url = "http://localhost:8100/";
// Invoke with the method, url, params, username, and password
result = CF.http("post", url, params, "karl", "salsa");
return result.get("Filecontent");
}