KJA consulting
 
KJA Home

Web Toys

Activex Components

Support Forum

Contact Us

Links & Resources

KHTTP Component:
Download Demo
  Buy It Now - Instant Download!

What can I do with a 'khttp component' ???

With the khttp component your webpage can get content from other websites. This is useful for showing stock tickers, weather information, news headlines, comparing prices from different online stores, getting real time shipping rates from UPS, write your own search engine submitter or web spider, download MP3s, images,etc. automatically -- The uses of this component are endless.

Who's Using Khttp? NASA, Charles Schwab, Ricoh, New Media, and more.

Documentation

Current version is 1.4.6
Click Here to View Recent Changes and Updates


Features:
  • Can be used from ASP pages, VBSCRIPT, or Visual Basic.
  • Custom HTTP Headers.
  • Binary and ASCII data transfers .
  • HTTP/HTTPS ( SSL ) get/post.
  • XML support ( works with EBAY Web Services API , UPS, others).
  • Host Header based get/post ( useful for discerning hosts residing on the same IP ).
  • simple HTTP Post integration for automating forms submissions.
  • Access password protected HTTP sites.
  • Access sites via any valid tcp port ( valid for both HTTP and HTTPS ).
  • Works using current system setting for firewalls.
  • Functions behind NAT servers.
  • Sample code included for all methods.

System requirements:

This component runs on Windows 95,98,NT,2000. It supports the following languages - ASP ( active server pages ) , Visual Basic, and VBScript. Minimum System: Pentium 90 with 32 meg ram

KHTTP Component:
Download Demo
  Buy It Now - Instant Download!

USAGE:
PROPERTIES TYPE
.content string
Gets the html page returned by the previous "openurl" call.
.contentlength integer
Gets the content length (in bytes) of the page returned by the previous "openurl" call. This property is only set if the HTTP header "CONTENT-LENGTH" was provided by the server.
.headers string
Gets the HTTP headers, delimited by crlf, of the page returned by the previous "openurl" call.
.username string
Sets the http username for protected sites.
.password string
Sets the http password for protected sites.
.port integer 0-65535
Sets the http port to connect with.

Defaults are:
443 for any url beginning with "https://"
80 for all other urls
.timeout integer 0-65535
Sets the http timeout in milliseconds.

Defaults is 30000 ( 30 seconds )
.transfermode integer 0-1
Sets the http transfer mode:

0 = ascii / text
1 = binary
Defaults is:
0 ascii mode

Notes: You must set "binarysaveas" using a full path and file name.

.binarysaveas String
Set the name of the file to save when performing a binary transfer. Binary data is not returned in the .content property and will only be saved to disc. The full path and file name is required.

example inet.binarysaveas = "c:\binaryfiles\image.gif"

.ignore_ssl_errors Integer 0-1
Many servers are configured with invalid SSL certificates. ( expired, wrong host, unknown CA, etc. ). While it is strongly suggested that you install a valid SSL certificate, this is not always an option.

Set this to 1 to ignore the following SSL certificate errors:

INVALID CA - means the certificate was created by a CA not known to your machine.
HTTP TO HTTPS ON REDIRECT - prevents errors when being redirected from HTTP to HTTPS sites.
HTTPS HTTP SUBMIT REDIRECT - prevents errors when posting to non SSL sites from SSL sites.
HTTPS TO HTTP ON REDIRECT - prevents errors when being redirected from SSL to non SSL sites.
CERTIFICATE COMMON NAME INVALID
- prevents errors when the CN does not match the certificate. This occurs when you're trying to use www.site.com's certificate on testserver.site.com.
CERTIFICATE DATE INVALID - self explanatory.
CERTIFICATE REVOKED - self explanatory.
CERTIFICATE INVALID - self explanatory.

example:

Dim inet
Set inet = CreateObject("khttp.inet")
dim url
url = "https://your_secure_domain/yourpage"
inet.ignore_ssl_errors =  1
response.write inet.openurl(url)
Set inet = nothing

.bypassUrlEncodeOnPost Integer 0-1
By default, khttp will encode the values used for http post. Some home brew and older cdi did not interpret urlencoded strings, so we've added the option to disable this feature. If your variables don't seem to post to a site, you may want to try this.

inet.bypassUrlEncodeOnPost = 0 DEFAULT
This will enable automatic urlencoding of post variables.

inet.bypassUrlEncodeOnPost = 1
This will disable automatic urlencoding of post variables.


METHODS RETURN VALUE
.openurl(url,optional_method) string
Returns a string that is the html page returned from the web server.

example:

Dim inet
Set inet = CreateObject("khttp.inet")
dim url
url = "http://yourdomain/yourpage"
response.write inet.openurl(url)
response.write inet.openurl(url,"GET")
response.write inet.openurl(url,"POST")

dim your_protected_url
your_protected_url = "http://yourdomain/yourprotectedpage"
inet.username = "your_username"
inet.password = "your_password"
response.write inet.openurl(your_protected_url)
response.write inet.content
response.write inet.contentlength
response.write inet.headers
Set inet = nothing

.urlencode(string) string
Returns a urlencoded string for use in querystrings.

example:

Dim inet
Set inet = CreateObject("khttp.inet")
response.write inet.urlencode("123+456 789")
Set inet = nothing

.clearpostvars() none
Clears the posting variables array. See example for addpostvars
.addpostvars(name,value) none
Adds a name/value pair to the array of variables that will get posted to the url if "POST" is the method.

example:

Dim inet
Set inet = CreateObject("khttp.inet")
dim url
url = "http://yourdomain/yourpage"
inet.addpostvars "test1","one"
inet.addpostvars "test2","two"
inet.openurl url,"POST"
response.write inet.content
inet.clearpostvars
inet.addpostvars "test3","three"
inet.openurl url,"POST"
response.write inet.content
inet.clearpostvars
Set inet = nothing

.clearHTTPHeaders() none
Clears the HTTP header string array. See example for addHTTPHeaders.
.addHTTPHeaders(name,value) none
Adds a name/value pair to the array of header variables. This can be used to send custom headers such as "HTTP_REFERER".

example:

Dim inet
Set inet = CreateObject("khttp.inet")
url = "http://www.rainfall.com/variables.asp"
inet.addHTTPHeaders "referer","http://www.rainfall.com/"
inet.addHTTPHeaders "User-Agent","khttp activex component"
inet.openurl url
display inet.content
inet.clearHTTPHeaders
Set inet = nothing

ADDITIONAL EXAMPLES
Binary File Transfer example
Note: You MUST have write permissions to the folder specified in inet.binarysaveas for this to work.

Dim inet
Set inet = CreateObject("khttp.inet")
url = "http://www.rainfall.com/mainimages/rf1_01_01.gif"
inet.transfermode = 1
inet.binarysaveas = server.mappath("rf1.gif")
inet.openurl url
display inet.content ' display a success/failure message
Set inet = nothing

SSL Example
Dim inet
Set inet = CreateObject("khttp.inet")
dim url
url = "https://your_secure_domain/yourpage"
response.write inet.openurl(url)
Set inet = nothing
Custom HTTP Port Example
Dim inet
Set inet = CreateObject("khttp.inet")
dim url
url = "http://yourdomain/yourpage"
inet.port = 8080
response.write inet.openurl(url)
Set inet = nothing
 
XML Example
This feature is an extension of the standard http POST method. To use this feature, use the same syntax as the POST example, but DO NOT call inet.addpostvars(). Instead, use the inet.xml property. The XML feature will work with Ebay's Web Services API. This feature was tested using the UPS website to return shipping rates. This requires a valid password from UPS. ( http://www.ups.com )

dim inet
dim xmlDocument ' you must supply a valid XML document
dim url

Set inet = CreateObject("khttp.inet")
url = "https://www.ups.com/ups.app/xml/Rate"
inet.xml = xmlDocument
inet.openurl url,"POST"
display inet.content
Set inet = nothing

Recent Updates:
v1.4.6 - 11/17/2004

Fixes a bug where certain downloaded binary files would be corrupted..

v1.4.3 - 11/04/2002

Solves some issues where khttp might not return control if a site was not responding in a timely fashion.

v1.4.2

Added additional property 'bypassUrlEncodeOnPost'. This addresses issues with some non-conforming http sites that do not properly parse urlencoded values.

Initially, khttp encoded all variables using the post method, so while most servers interpreted '%41' as 'A', some home brew CGI did not. We've now included an optional switch - see properties.

v1.4.1
Added ability to add custom cookies to http header and manual http redirection. This update may cause changes in your current khttp implementation if you previously had relied on autoredirection. Cookies are now handled entirely via http headers. refer to Netscape Cookie Reference for cookie header details if you wish to use cookies.

v1.4.0
added support for non-standard SSL certificates. This means khttp will now ignore SSL errors like invalid name, out of date, etc. Refer to the docs for usage.

Registered owners may request a free update here.