|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
DescriptionThis article presents a mini Web server with ASP support. When writing these classes I was inspired by an article from MSDN Magazine 'A Client-side Environment for ASP Pages ' by Dino Esposito. Although I didn't use any of the code from this MSDN article (mainly because it was written in VB) it was very helpful to get me started. One problem of Dino's solution is, that it is using the msscript.ocx (Microsoft Script Control), which is not available on all Windows system (you must download and install it separately from Internet Explorer). So in this article I present you a MFC solution that uses the Microsoft Scripting Engine COM interface. Features
Known limitations
Major classes usedCScriptEngineThis is a wrapper class around the COM interface of Microsoft's Scripting Engine. It simply converts all calls to the COM interface to easy to use MFC functions.CAspParserThis class implements the ASP parser. It attaches the interfaces to the script engine and prepares the ASP page for execution. First all HTML code is converted to ASP code (Response.Write lines), so the resulting page contains only ASP code (= vbscript code).
The Script Engine then executes this code and all output is written to the Response buffer.
Any calls to Response or Request objects will be routed to my CResponseObject and
CRequestObject classes.
In the case of a web server this response buffer will be send back to the web browser.
CResponseObjectThis class provides theIResponse interface to the scripting engine.
The IReponse is used by ASP to write data from a script to the output HTML page. Only the most common used properties and methods are implemented.
CRequestObjectThis class provides theIRequest interface to the scripting engine.
The IRequest is used by ASP to read data from various collections into the script.
The following collections are (partly) implemented:
CCookie and CCookieEnumImplementation of theICookie interface to support cookies.
This code is partly based the ATL class CCookie from Microsoft VC++ 7.0.
CCookieCollection and CCookieCollectionEnumThis is an attempt to duplicate the behaviour of the ASPIRequestDictionary interface to support cookies.
CListenSocketThis socket accepts all incoming connections.
When a client connects to the server, CClientThreadThis thread will handle all communication between the client and the server using
CClientSocketThis socket class will process all incoming request and send back the response (files) to the client. All the other classes are just UI related. Contacting the AuthorPlease send any comments or bug reports to me via email. For updates to this article (and many other articles), check my site: http://www.pablovandermeer.nl.Revision history
|
||||||||||||||||||||||