Home Site Map Buy Email
AdvSMTP
AdvIMAP4
AdvPOP3
AdvFile
AdvZIP
AdvGraphGenerator
AdvLDAP
AdvHTTP
AdvDSN
AdvDirectory
AdvRegistry
AdvMX
ASP Components >> AdvHTTP >> CF_HTTP
Download | Buy
CF_HTTP

CF_HTTP

The CF_HTTP tag allows you to perform POST and GET operations related to HTTP. Using CF_HTTP, you can perform standard GET operations. POST operations allows you to upload MIME file types to a server, or post cookie, formfield, URL, file, or CGI variables directly to a specified server.

See also CF_HTTPPARAM.

Syntax

<CF_HTTP URL="hostname"
    PORT="port_number"
    METHOD="get_or_post"
    USERNAME="username"
    PASSWORD="password"
    PATH="path"
    FILE="filename"
    PROXYSERVER="hostname"
    PROXYPORT="port_number"
    USERAGENT="user_agent"
    REFERRER="referrer"
    PROTOCOL="protocol"
    COOKIES="boolean"
    FOLLOWREDIRECTS="boolean"
    MAXREDIRECTS="max_number_of_redirects">
</CF_HTTP>

URL

Required. Full URL of the host name or IP address of the server on which the file resides.

PORT

Optional. The port number on the server from which the object is being requested. If no port is specified then a default port 80 is used to send request.

METHOD

Required. GET or POST. Use GET to download a text or binary file. Use POST to send information to a server, which allows you to upload MIME file types to a server, or post cookie, formfield, URL, file, or CGI variables.

USERNAME

Optional. When required by a server, a valid username.

PASSWORD

Optional. When required by a server, a valid password.

PATH

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 (CF_HTTP.FileContent) that you can use to present the results of the GET or POST operation in a CFOUTPUT.

FILE

Required in a POST operation if PATH is specified. The filename to be used for the file that is accessed.

PROXYSERVER

Optional. The proxy server address.

PROXYPORT

Optional. The port number on the proxy server from which the object is being requested. If no port is specified then a default port 80 is used to send request.

USERAGENT

Optional. User agent request header.

REFERRER

Optional. Address of a string that specifies the address (URL) of the document from which the URL in the request was obtained.

PROTOCOL

Optional. The protocol property indicates what version of HTTP should be used in request. Default value is HTTP/1.0.

COOKIES

Optional. This parameter is used to set flag whether to add cookie headers to requests or add returned cookies to the cookie database. Valid values are

  • TRUE (default) if this parameter is set as TRUE then tag will automatically process cookies
  • FALSE if this parameter is set as FALSE then tag will not process cookies

FOLLOWREDIRECTS

Optional. This parameter is used to follow redirect responses from the HTTP server. Valid values are

  • TRUE (default) if this parameter is set as TRUE then tag will automatically follow redirects
  • FALSE if this parameter is set as FALSE then tag will not not follow any redirect

MAXREDIRECTS

Optional. This parameter is used to set maximum number of times an HTTP redirection will be allowed. The default value is -1, which means follow all possible redirects. This property is effective in case FollowRedirects is set as TRUE.

Usage

Note the following:

  • HTTP GET A user can specify a URL that points to a text or binary file. The file will be downloaded and its contents stored in a CF variable or in a file so that the user can manipulate the data. The internal variable FileContent is available for text and MIME file types. The MimeType variable is available for all file manipulations. In addition, Header allows you to see the response headers. These variables can be accessed in the following manner.

    #CF_HTTP.CurrentURL#

    #CF_HTTP.FileContent#

    #CF_HTTP.MimeType#

    #CF_HTTP.Header#

  • HTTP POST CF_HTTPPARAM tags can be nested inside a CF_HTTP tag in a POST operation. Since multiple CF_HTTPPARAM tags can be nested in one CF_HTTP tag, you can construct a multipart/form-data style post. A FileContent variable is created and this can be used in a CFOUTPUT. If PATH and FILE are specified, the data returned from the server is saved to the specified location.
  • Authentication CF_HTTP supports Windows NT Basic Authentication for both GET and POST operations.
  • Encryption CF_HTTP is capable of using Secure Sockets Layer (SSL) for negotiating secured transactions.

    See the following table for all the variables returned by CF_HTTP.

    CF_HTTP Variables 
    Variable Name Description
    #CF_HTTP.CurrentURL# contains current URL.
    #CF_HTTP.FileContent# contains contents of the file.
    #CF_HTTP.MimeType# contains MIME type.
    #CF_HTTP.Header# contains raw response header.

Example

<!--- This example shows the use of CF_HTTP
to pull information from a web page --->

<HTML>
<HEAD>
	<TITLE>CF_HTTP Example</TITLE>
</HEAD>
<BODY>

<H3>CF_HTTP Example</H3>

<P>This example shows the ability of CF_HTTP to pull the contents
of a web page from the Internet, and shows how you can 
get the following information by using CF_HTTP variables.</P>

<CF_HTTP URL="http://www.aspfusion.net" METHOD="GET">
</CF_HTTP>

<CFOUTPUT>
    CurrentURL: #cf_http.currenturl#<BR>
    FileContent: #cf_http.filecontent#<BR>
    MIMEType: #cf_http.mimetype#<BR>
    Header: #cf_http.header#<BR>
</CFOUTPUT>

</BODY>
</HTML>