AspHTTP allows you to GET/POST/HEAD documents using the HTTP protocol.
- GET, HEAD and POST request methods
- Response headers are exposed
- Accept headers are modifiable
- Adjustable timeout
- Proxy support
- Custom User-Agent headers
- Custom Content-Type headers for POST
- Supports authentication areas (Basic only, NOT NTLM)
- Retrieves URLs to a file including binary files
- Allows custom HTTP request headers
Changes in AspHTTP 3.5
- Better support for MTS. Transactions are not supported in the 3.0 release but you should be able to incorporate AspHTTP into MTS packages without any problems. 3.5 also has performance optimizations over 3.0.
To use this ASP component move the DLL into a subdirectory (like \winnt\system32 for NT or \windows\system for Win95). Change to the directory where you move the DLL before registering the component.
To register the component on the system type:
Simple HTTP Example
Using the component is as simple as
- Creating the object
- Setting a single property
- Calling the GetURL method
The following code demonstrates how to use AspHTTP from VBScript.Set HttpObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://www.myfinancialpage.com/qrtresults.html" strResult = HTTPObj.GetURL
The variable named strResult now contains a string representing the document results from a GET of http://www.myfinancialpage.com/qrtresults.html.
AspHTTP allows you to post data back to the Web server. The following example demonstrates a POST request:Set HttpObj = Server.CreateObject("AspHTTP.Conn") HTTPObj.Url = "http://www.myfinancialpage.com/scripts/update3.asp" HTTPObj.PostData = "suid=jimb&pwd=macabre&id=32&val=1.5" HTTPObj.RequestMethod = "POST" strResult = HTTPObj.GetURL
The variable named strResult now contains a string representing the document results from a POST to http://www.myfinancialpage.com/scripts/update3.asp.
About purchasing AspHTTP
- Licensing is on a per server CPU basis. The product is available for purchase from http://www.serverobjects.com/products.htm
- Users can upgrade for free for minor version changes. For example, upgrades from version 1.00 to 1.99 are free. The upgrade from 1.99 to 2.0 may carry an additional license fee.
- The latest version of the components are always available at http://www.serverobjects.com/products.htm. If a fee is associated with obtaining the upgrade it will be noted on that page.
Stop all IIS related services such as Gopher, FTP and W3SVC. Uninstalling the old DLL is not necessary. If the DLL has been loaded you will get an error message saying the file is in use by another process. Stop that process and then copy the file. Restart the necessary services.
Frequently Asked Questions
What are the common installation problems? See http://www.serverobjects.com/TechComm.htm for a list of problems and solutions. Download TShoot, our troubleshooting utility from http://www.serverobjects.com/utils/tshoot.zip. I call GetURL but nothing is returned. Check the Error and Response properties for possible failures or response values that won't show up the the GetURL return value. AspHTTP returns results that are different from what I get when I use browser xyz. Set AspHTTP.UserAgent to the browser type you are testing against. Many Web sites customize the resultant HTML based on the UserAgent value. How do I get just a URL's headers, but not the content. HTTPObj.RequestMethod = "HEAD" Does AspHTTP currently support SSL / https?
Not yet. No eta is available for this feature.
My proxy uses both a user name and password. How do I set that with AspHTTP? Set the ProxyPassword property to the username and password seperated by only a colon. Example:
HTTPObj.ProxyPassword = "proxyusername:proxypassword"
If you require technical support please see our tech support page at http://www.serverobjects.com/support.htm
Accept The Accept property indicates what kind of MIME types can be accepted by the requesting program.
HTTPObj.Accept = "*/*"
Authorization The Authorization header allows you to retrieve URLs that are located in authenticated areas. To use the Authorization property set this property to the username and password, seperated by a colon ":", for the password protected area.
HTTPObj.Authorization = "jimb:superbmr"
BinaryData Returns the data available from the GetURL request in binary form. You can use this property to grab binary data such as images off another server.
Response.ContentType = "image/gif"
Set HTTPObj = Server.CreateObject("AspHTTP.Conn")
HTTPObj.Url = "http://www.microsoft.com/library/images/gifs/toolbar/write.gif"
ContentType The ContentType property allows you to specify custom content-type headers during a POST operation.
ContentType = "application/x-www-form-urlencoded"
Error Reports any errors that may occur during the request. FollowRedirects FollowRedirects tells the component to follow redirect responses from the HTTP server.
HTTPObj.FollowRedirects = true
Headers The Headers property contains the response headers from the HTTP request after the request has been completed by a call to the GetURL method.
HTTPLog Filename where HTTP transaction data can be logged.
HTTPObj.HTTPLog = "c:\httplog.txt"
MaxRedirects Sets the maximum number of times an HTTP redirection will be allowed. The default value is 3. (version >= 3.51). Port The Port property indicates which port to contact the HTTP server on.
HTTPObj.Port = 80
PostData The PostData property should be set to the values of the data that you want to post to the server for a post request.
HTTPObj.PostData = "suid=jimb&act=upd"
Protocol The Protocol property indicates what version of HTTP the request should be made using. By default Protocol is HTTP/1.0
HTTPObj.Protocol = "HTTP/1.1"
Proxy The proxy property contains the address and port of the proxy server seperated by a colon.
HTTPObj.Proxy = "address.net:2001"
ProxyPassword Sets the HTTP Proxy password for HTTP proxy servers that require authentication. Only basic authentication is currently supported. RequestMethod The RequestMethod property indicates what type of HTTP request should be made to the server. Legal values are "GET", "POST" and "HEAD".
HTTPObj.RequestMethod = "POST"
RegisteredUser The RegisteredUser property indicates the name the component is licensed to.
Response.Write "This component is licensed to " & HTTPObj.RegisteredUser
Response The Response property contains the HTTP response after a request has been received from a Web server. SaveFileTo The SaveFileTo allows you to retrieve files of any type and have them automatically saved to a local server disk. This allows you to retrieve binary files such as images, as well as text files, like HTML files. To use the SaveFileTo property set the value of SaveFileTo to the name of the local directory and file name where the requested URL should be saved. Be sure the user has security rights that allow the writing of the file. Set this property before the call to GetURL if you wish to save to a file.
HTTPObj.SaveFileTo = "c:\images\3rdqrtr.jpg"
TimeOut The timeout property determines how long the component should wait for a response from the HTTP server. The default timeout is 60 seconds.
HTTPObj.TimeOut = 45
URL The URL property should be set to the URL you wish the request to operate upon. URLs should be preceded with http://.
HTTPObj.URL = "http://www.myfinancial.com/scripts/update3.asp"
UserAgent The UserAgent property allows the component to impersonate browsers by sending a UserAgent header in the request.
HTTPObj.UserAgent = "Mozilla Compatible (MS IE 3.01 WinNT)"
Version The version property indicates the internal version of the AspHTTP component.
Response.Write "The component version is " & HTTPObj.Version
AspHTTP Component Methods
Method Parameters Return Value Description GetURL None String GetURL returns the reponse of the HTTP request. This value is a string value and the component currently does not support binary return values such as GIF or JPEG images. AddExtraHeader String None Adds a custom HTTP header to the request. Custom headers may include simulated browser headers such as IE's display resolution headers.
HTTPObj.AddExtraHeader ("Cookie: ASPSESSIONID=EKKDDPSDKCCPZRNA; path=/kb")
ClearExtraHeaders None None Clears any HTTP request headers that were set using AddExtraHeader. GetHeader String String Get's the value of a specific header after GetURL has been called. If multiple headers have the same value GetHeader returns the first. To search all headers see GetHeaders.
strCookie = HTTPObj.GetHeader("Set-Cookie")
You could then on subsequent calls return the same cookie as follows:
if strCookie <> "" then
HTTPObj.AddExtraHeader "Cookie: " & strCookie
GetHeaders None String Returns all Header values for manual parsing. Header values are CrLf separated. GetHREFs None Variant array of Strings After a call to GetURL you can call GetHREFs to parse any <a href=""> tags in the HTML. GetHREFs returns a variant array of strings that you can further parse or display. See HREFList.asp for example code that uses this method. GetHREFs was added in version 2.4. URLDecode strValue String Decodes an URL encoded string URLEncode strValue String Encodes an string to a legal URL value.
HTTPObj.URL = "http://www.test_xyz.com?" & HTTPObj.URLEncode("avalue=this is a value with spaces")
© Copyright 1997, 1998, 1999, 2000 by ServerObjects Inc.