Home arrow ASP arrow Page 4 - HTTP Tunneling Revealed: Part 1/3
ASP

HTTP Tunneling Revealed: Part 1/3


What do the iNet control, XMLHTTP and web services have in common? They all use HTTP tunneling. In this 3 part series, Adnan gets under the hood and shows us exactly what HTTP tunneling is.

Author Info:
By: Adnan Masood
Rating: 4 stars4 stars4 stars4 stars4 stars / 50
October 17, 2002
TABLE OF CONTENTS:
  1. · HTTP Tunneling Revealed: Part 1/3
  2. · What is HTTP Tunneling?
  3. · More on iNET and XMLHTTP
  4. · ASPTear In Action
  5. · A ServerXMLHTTP Example
  6. · Conclusion

print this article
SEARCH DEVARTICLES

HTTP Tunneling Revealed: Part 1/3 - ASPTear In Action
(Page 4 of 6 )

This example shows the basic functionality of authentication and handling post requests using ASPTear. Its written by the manufacturer. Source code for the included file asptearinclude.asp can be found here.

<!-- #include file="asptearinclude.asp" -->
<html>
<head>
<META NAME="generator" CONTENT="Allaire HomeSite 4.0">
<title>Retrieval of POST page</title>
</head>
<body>
<%
Dim xObj, strResult, strUrl

' create the object
Set xobj = CreateObject("SOFTWING.ASPtear")

On Error Resume Next

' set a referrer, don't cache pages, supply a custom user agent and a timeout
xObj.Referrer = "http://www.vatican.va/"
xObj.ForceReload = True
xObj.UserAgent = "Mozilla/4.0 (compatible; MSIE 5.0b2; Windows NT)"
xObj.ConnectionTimeout = 45

strUrl = Request.ServerVariables("SCRIPT_NAME")
strUrl = Left(strUrl,InStrRev(strUrl,"/")) & "formpost.asp"
strUrl = "http://" & Request.ServerVariables("SERVER_NAME") & strUrl

' URL, action, payload, filename, username, password
strResult = xobj.Retrieve(strUrl, Request_POST, "test=it", "", "")
HandleError

Response.Write "<font color=""red"">" & strResult & "</font>"
Response.Write "<br><b>Headers:</b><br><PRE>" & xObj.Headers & "</PRE>"
%>

</body>
</html>


Some of the less known components include Flicks Software's OCXHttp. It's an MFC written COM component with Installshield to avoid the registration hassle. With full support for GET, HEAD and POST requests, it can be used to set accept headers, user agent, content type, accept ranges, status text, cookies - including multiple cookies on one file, etc. They mention that it uses the Inet control, which others have avoided because of the documented problems with WinInet.dll, I never understood why.

Instantiating and using OCXHTTP is similar and simple as others, but since this article focuses on the evolution of distributed EDI, I think it justifies writing something about every available effort. Similar to others, OCXHTTP has standard GET, POST and HEAD functionality, as well as methods like combineURL, to add relative and base URL formatting into one. It has authentication, and methods like FlagReload / FlagDontCache to handle the caching, session re-use and FlagUseExistingConnect, optimization, custom flags, setting user agent (browser), timeouts and more.

The MSXML Revolution

Microsoft XMLHTTP: Released as part of Internet Explorer 5.0 (and later), or IIS 5 (and later) and created lot of change in the development vision. As a default configured HTTP component, it was stated as "superglue for the web". This suite was originally for the XML DOM manipulation, but it included the XMLHTTP object for URI stream handling. This object was developed extensibly enough to send GET/POST/Head requests and retrieve the XML/HTML or binary data as result. It came as the MSXML 3.0 parser.

Microsoft ServerXMLHTTP: Was actually a replacement for XML HTTP for better performance on busy web servers. It was claimed to make the server more reliable as compared to its precursor.

Below I demonstrate how XMLHTTP can be used for implementing the HTTP GET method -- in this case Google. The mega search engine, Google, if provided with a search phrase in the query string, returns the search results , i.e. http://www.google.com/search?q=web+services where web services is the search phrase.

This example is for educational purposes only. For commercial usage, one must read the terms and conditions for affiliate programs provided:

<%@ Page aspcompat=true %>
<%
Dim objXMLHTTP, xml
' Create an xmlhttp object:
xml = Server.CreateObject("Microsoft.XMLHTTP")

' Version 3.0 of XMLHTTP, use:
' Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")

' Opens the connection to the remote server.
xml.Open ("GET", "http://www.google.com/search?q=web+services", False)
' Actually Sends the request and returns the data:
xml.Send
'Display the HTML and Text
'Response.Write ("<h1>The HTML text</h1><xmp>")
'Response.Write (xml.responseText)
'Response.Write ("</xmp>")
Response.Write ("<h1>This is generated results from google using XMLHTTP </h1>") Response.Write (xml.responseText)
xml = Nothing
%>


XMLHTTP's GET Request Results

For ServerXMLHTTP, I have an interesting example. BAA Plc provides live flight information for UK airports. If we provide a flight number in the query string, it displays the status of flight i.e. Scheduled time, Coming from, Flight Number, Status and Terminal. In our case it's BA719 from Zurich. The query string seems long, but when I executed it without the airport number, the error result was:

DTWA000E: Net.Data detected an internal error DTWL018E: Net.Data detected a null value in parameter airport in function DTW_UPPERCASE.

... exposing the system modules and those parameter errors that not handled properly. Anyway, the query string with the flight number is shown below:

http://shop.baa.co.uk/cgi-bin/ncommerce3/ ExecMacro/flights/arrivals.d2w/ report?flightnumber=BA719&comingfrom= &hour=Hour&min=Min&hourselect=0 &minselect=0&airport=LHR&timeframe=&terminalselect=0&terminal=All
blog comments powered by Disqus
ASP ARTICLES

- Central Scoreboard with Flash and ASP
- Calorie Counter Using WAP and ASP
- Creating PGP-Encrypted E-Mails Using ASP
- Be My Guest in ASP
- Session Replacement in ASP
- Securing ASP Data Access Credentials Using t...
- The Not So Ordinary Address Book
- Adding and Displaying Data Easily via ASP an...
- Sending Email From a Form in ASP
- Adding Member Services in ASP
- Removing Unconfirmed Members
- Trapping HTTP 500.100 - Internal Server Error
- So Many Rows, So Little Time! - Case Study
- XDO: An XML Engine Class for Classic ASP
- Credit Card Fraud Prevention Using ASP and C...

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials