BuildersPlanet.comBuildersPlanet Home Page
Host Your Site Here
Marketplace Job Bank Buy/Sell Community News Services
 HOME  >  Services > Web Hosting > Support > ASPHTTP 3.x Instant Feedback


AspHTTP 3.x

About AspHTTP

AspHTTP allows you to GET/POST/HEAD documents using the HTTP protocol.

Features include:

  1. GET, HEAD and POST request methods
  2. Response headers are exposed
  3. Accept headers are modifiable
  4. Adjustable timeout
  5. Proxy support
  6. Custom User-Agent headers
  7. Custom Content-Type headers for POST
  8. Redirection
  9. Supports authentication areas
  10. Retrieves URLs to a file including binary files
  11. Allows custom HTTP request headers

Simple HTTP Example

Using the component is as simple as

  1. Creating the object
  2. Setting a single property
  3. 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.

POSTing Data

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.

Frequently Asked Questions

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"

Technical Support

If you require technical support please see our tech support page at http://www.serverobjects.com/support.htm

AspHTTP Properties

Accept The Accept property indicates what kind of MIME types can be accepted by the requesting program.

Example:

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.

Example:

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.

Example:

<%
Response.ContentType = "image/gif"
Set HTTPObj = Server.CreateObject("AspHTTP.Conn")
HTTPObj.Url = "http://www.microsoft.com/library/images/gifs/toolbar/write.gif"
HTTPObj.GetURL
Response.BinaryWrite HTTPObj.BinaryData
%>

ContentType The ContentType property allows you to specify custom content-type headers during a POST operation.

Example:

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.

Example:

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.

Example:

Response.Write HTTPObj.Headers

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.

Example:

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.

Example:

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

Example:

HTTPObj.Protocol = "HTTP/1.1"

Proxy The proxy property contains the address and port of the proxy server seperated by a colon.

Example:

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".

Example:

HTTPObj.RequestMethod = "POST"

RegisteredUser The RegisteredUser property indicates the name the component is licensed to.

Example:

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 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.

Example:

HTTPObj.SaveFileTo = "c:\images\3rdqrtr.jpg"

TimeOut The timeout property determines how long the component should wait for a response from the HTTP server.

Example:

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://.

Example:

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.

Example:

HTTPObj.UserAgent = "Mozilla Compatible (MS IE 3.01 WinNT)"

Version The version property indicates the internal version of the AspHTTP component.

Example:

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.
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.

Example:

strCookie = HTTPObj.GetHeader("Set-Cookie")

You could then on subsequent calls return the same cookie as follows:

if strCookie <> "" then
  HTTPObj.AddExtraHeader "Cookie: " & strCookie
end if

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.

Example:

HTTPObj.URL = HTTPObj.URLEncode("http://www.test_xyz.com?avalue=this is a value with spaces")

 

© Copyright 1997, 1998, 1999, 2000 by ServerObjects Inc.

Home|Contact Us|Hosting Terms

© Copyright 1999-2000. BuildersPlanet.com All rights reserved..
By using this site you accept our terms  and privacy policy.
For comments or problems, email Webmaster@buildersplanet.com or call 831-335-0475