|
ASP
Components >> AdvHTTP
|
see also CF_HTTP |
Download | Buy |
AdvHTTP |
Make
requests and collect information from foreign servers and
let your web based applications download faster. Use the HTTP
component to interact with web services or other applications.
Programmatically submit forms or collect information from
other web pages. There are no limitations in what you can
do in HTTP with this component. Will let you set the user
agent name, set referrer, set protocol version as HTTP/1.0,
set proxy server settings. This control provides easy, high-level
access to the complete HTTP client protocol. Retrieving pages,
submitting forms along with multiple form variables and multiple
files, etc, are well supported. Your web-based applications
will download faster. It provides these operations.
|
Get
for performing Get method of HTTP. |
|
Post for performing Post method for HTTP.
|
|
Supports Windows NT Basic Authentication
for both GET and POST operations. |
|
Capable of using Secure Sockets Layer (SSL)
for negotiating secured transactions. |
|
Handles proxy.
|
|
No limitations in number of connections. |
|
Text and binary data. |
|
ASPFusion
also provides ColdFusion custom tag CF_HTTP written on
AdvHTTP component. This helps coldfusion developers in making
a better understanding, in case they are using AdvHTTP component.
Sample code for C++, ASP and CF is provided
with the component.
Example
(ASP):
<% set Obj = Server.CreateObject("AdvHTTP.HTTP")
%>
Example (ColdFusion):
<CFOBJECT
Class="AdvHTTP.HTTP" Action="Create" Name="Obj">
AdvHTTP Properties
Property |
Description |
Cookies
|
This
property 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 property is set
as TRUE then component will automatically process cookies
FALSE if this property is
set as FALSE then component will not process cookies
Example (ASP):
<% Obj.Cookies =
false %>
Example (ColdFusion):
<CFSET Obj.Cookies = false>
|
ErrorReason |
Reports
any error that occurred during the request.
Example (ASP):
<% if Obj.IsError = 1 then
Response.Write
Obj.ErrorReason
else
No Error
Occurred
end if %>
Example (ColdFusion):
<CFIF #Obj.IsError# EQ 1>
<CFOUTPUT>#Obj.ErrorReason#</CFOUTPUT>
<CFELSE>
<CFOUTPUT>No
Error Occurred</CFOUTPUT>
</CFIF>
|
FollowRedirects |
This
property is used to follow redirect responses from the
HTTP server. Valid values are
TRUE (default)
if this property is set as TRUE then component will
automatically follow redirects
FALSE if this property is
set as FALSE then component will not follow any redirect
Example (ASP):
<% Obj.FollowRedirects
= false %>
Example (ColdFusion):
<CFSET Obj.FollowRedirects = false >
|
IsError
|
Returns
1 if any error occurred during the request otherwise
0.
Example (ASP):
<% if Obj.IsError = 1 then
Response.Write
Obj.ErrorReason
else
No Error
Occurred
end if %>
Example (ColdFusion):
<CFIF #Obj.IsError# EQ 1>
<CFOUTPUT>#Obj.ErrorReason#</CFOUTPUT>
<CFELSE>
<CFOUTPUT>No
Error Occurred</CFOUTPUT>
</CFIF>
|
MaxRedirects |
This
property 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.
Example (ASP):
<% Obj.MaxRedirects
= 2 %>
Example (ColdFusion):
<CFSET Obj.MaxRedirects = 2>
|
Password
|
It
is used to specify password if required by server, a
valid password.
Example (ASP):
<% Obj.Password
= "mypassword" %>
Example (ColdFusion):
<CFSET Obj.Password = "mypassword">
|
Path
|
The
path to the directory in which a file is to be stored.
If a path is not specified in a GET or POST methods,
then variable FileContent is created.
Example (ASP):
<% Obj.Path = "c:\myfolder"
%>
Example (ColdFusion):
<CFSET Obj.Path = "c:\myfolder">
|
Port
|
The
port number on the server from which the object is being
requested. Default port is 80.
Example (ASP):
<% Obj.Port = 2080
%>
Example (ColdFusion):
<CFSET Obj.Port = 2080>
|
Protocol
|
The
protocol property indicates what version of HTTP should
be used in request. Default value is HTTP/1.0.
Example (ASP):
<% Obj.Protocol
= "HTTP/1.1" %>
Example (ColdFusion):
<CFSET Obj.Protocol = "HTTP/1.1">
|
ProxyPort
|
The
port number on the proxy server from which the object
is being requested. Default port is 80.
Example (ASP):
<% Obj.ProxyPort
= 8080 %>
Example (ColdFusion):
<CFSET Obj.ProxyPort = 8080>
|
ProxyServer |
The
proxy server address.
Example (ASP):
<% Obj.ProxyServer
= "domain.com" %>
Example (ColdFusion):
<CFSET Obj.ProxyServer = "domain.com">
|
Referrer
|
Address
of a string that specifies the address (URL) of the
document from which the URL in the request was obtained.
Example (ASP):
<% Obj.Referrer
= "addressURL" %>
Example (ColdFusion):
<CFSET Obj.Referrer = "addressURL">
|
SaveToFile |
Required
if PATH is specified. The filename to be used for the
file that is accessed.
Example (ASP):
<% Obj.SaveToFile
= "testing.htm" %>
Example (ColdFusion):
<CFSET Obj.SaveToFile = "testing.htm">
|
URL
|
Full
URL of the host name or IP address of the server on
which the file resides.
Example (ASP):
<% Obj.URL = "http://www.aspfusion.net"
%>
Example (ColdFusion):
<CFSET Obj.URL = "http://www.aspfusion.net">
|
UserAgent
|
User
agent request header.
Example (ASP):
<% Obj.UserAgent
= "useragent" %>
Example (ColdFusion):
<CFSET Obj.UserAgent = "useragent">
|
UserName
|
It
is used to specify user name if required by a server,
a valid user name.
Example (ASP):
<% Obj.UserName
= "myusername" %>
Example (ColdFusion):
<CFSET Obj.UserName = "myusername">
|
AdvHTTP Methods
Method |
Parameter |
Return Value |
Description |
CGI
|
1.
CGI Variable Name
2. CGI Variable Value |
None
|
Post
CGI variables with specified name and value.
Example (ASP):
<% Obj.CGI "myvariable",
"this is value" %>
Example (ColdFusion):
<CFSET Obj.CGI("cgi_test", "cgi_test_value")>
|
Cookie
|
1.
Cookie Variable Name
2. Cookie Variable Value |
None
|
Post
cookie variables with specified name and value.
Example (ASP):
<% Obj.Cookie "mycookie",
"my cookie value" %>
Example (ColdFusion):
<CFSET Obj.Cookie("cookie_test", "cookie_test_value")>
|
File
|
1.
File Variable Name
2. File Path
|
None
|
Post
the specified file with specified name.
Example (ASP):
<% Obj.File "file1",
"c:\myfolder\myfile.exe" %>
Example (ColdFusion):
<CFSET Obj.File("file1", "c:\myfolder\myfile.exe")>
|
FileEx |
1. File
Variable Name
2. File Path
3. File Content Type |
None |
Post the
specified file with specified name and content type.
Example (ASP):
<% Obj.FileEx "file1",
"c:\myfolder\myfile.exe", "application/octet-stream"
%>
Example (ColdFusion):
<CFSET Obj.FileEx("file1",
"c:\myfolder\myfile.exe" ,"application/octet-stream")>
|
FormField
|
1.
Form Variable Name
2. Form Variable Value |
None
|
Post
form fields with specified name and value.
Example (ASP):
<% Obj.FormField
"submit", "submit value" %>
Example (ColdFusion):
<CFSET Obj.FormField("form_test", "form_test_value")>
|
Get
|
None
|
Object
|
Perform
GET method. If a path is not specified in a GET method,
then variable with name FileContent is created.
Example (ASP):
<% set Result = Obj.Get()
Response.Write
Result.CurrentURL
Response.Write
Result.MIMEType
Response.Write
Result.Header
Response.Write
Result.FileContent
set Result = nothing %>
Example (ColdFusion):
<CFSET Result = Obj.Get()>
<CFOUTPUT>
#Result.MIMEType#
#Result.Header#
#Result.FileContent#
</CFOUTPUT>
WHERE in Get object
CurrentURL |
contains current URL.
|
MIMEType |
contains MIME type.
|
Header |
contains raw response header.
|
FileContent |
contains contents of the file.
|
|
Post
|
None
|
Object
|
Perform
POST method. If a path is not specified in a POST method,
then variable with name FileContent is created.
Example (ASP):
<% set Result = Obj.Post()
Response.Write
Result.MIMEType
Response.Write
Result.Header
Response.Write
Result.FileContent
set Result = nothing %>
Example (ColdFusion):
<CFSET Result = Obj.Post()>
<CFOUTPUT>
#Result.MIMEType#
#Result.Header#
#Result.FileContent#
</CFOUTPUT>
WHERE in Post object
MIMEType |
contains MIME type.
|
Header |
contains raw response header.
|
FileContent |
contains contents of the file.
|
|
URLField
|
1.
URL Variable Name
2. URL Variable Value |
None
|
Post
form fields with specified name and value.
Example (ASP):
<% Obj.URLField
"acion", "action value" %>
Example (ColdFusion):
<CFSET Obj.URLField("url_test", "url_test_value")>
|
|
|