Data returned by the CF.http function

The CF.http function returns an object that contains properties, also known as attributes, that you reference to access the contents of the file returned, header information, HTTP status codes, and so on. The following table shows the available properties:
Property
Description
Text
A Boolean value indicating whether the specfied 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, macromedia.com returns the following header :
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=.macromedia.com
Connection: close
Content-Type: text/html
Filecontent
File contents, for text and MIME files.
Mimetype
MIME type. Examples of content types include "text/html", "image/png", "image/gif", "video/mpeg", "text/css", and "audio/basic".
Responseheader
Response header. If there is one instance of a header key, this value can be accessed as a simple type. If there is more than one instance, values are put in an array in the responseHeader structure.
Statuscode
HTTP error code and associated error string. Common HTTP status codes returned in the response header include the following:
400: Bad Request
401: Unauthorized
403: Forbidden
404: Not Found
405: Method Not Allowed

Referencing HTTP Post parameters CF.http

In order to pass HTTP Post parameters in the CF.http function, you must construct an array of objects and assign this array to a variable named params. The following arguments can only be passed as an array of objects in the params argument of the CF.http function.
Parameter
Description
name
The variable name for data that is passed
type
Transaction type:
  • URL
  • FormField
  • Cookie
  • CGI
  • File
value
Value of URL, FormField, Cookie, File, or CGI variables that are passed

In the following example, the CF.http function passes HTTP Post parameters in an array of objects.

function postWithParamsAndUser()
{
  // Setup 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");
}

Comments