Click here to Skip to main content
13,549,157 members
Click here to Skip to main content
Add your own
alternative version


76 bookmarked
Posted 7 Apr 2000

W3Mfc v1.11

, 7 Apr 2000
Rate this:
Please Sign up or sign in to vote.
A collection of freeware MFC classes to implement a simple Web server.
  • Download source files - 34 Kb
  • Introduction

    Welcome to W3Mfc, a collection of freeware MFC classes to implement a simple Web server.

    The idea behind is W3Mfc was originally to learn about the Http protocol and how it is implemented on Win32. It is not intended to be a replacement for IIS or Apache. Instead it is designed as a tool for learning or in cases where deployment of a solution on IIS would be considered overkill or your product must run on 95/98 in addition to NT.

    For detailed information about the HyperText Transfer Protocol you should read RFC 1945, You can download this from a number of sites by searching for RFC and 1945 on

    Another document that these classes refer to is RFC 2045 which defines MIME.

    The classes which constitute W3Mfc are:

    This class contains the settings which are used to configure the web server. Example member variables in this class include the virtual directories and the their default filenames. If you are developing a stand alone web server based on W3Mfc, you could for example store all the variables for the CHttpServerSettings instance in an ini file or in the registry.

    This is the actual class which implements the web server. It has a number of very simple functions to allow you to control the state of the web server such as Start and Stop. Internally a background thread is spun off to handle the client connections.

    This is a simple C++/MFC encapsulation of an SDK socket.

    This class helps in the handling of sending request headers when returning the HTTP responses to clients. It provides a number of methods to allow standard Http headers to be added to the client response.

    This class is used when returning client responses. It is used to determine to mime type of a file given its extension type. This information is taken from the registry and is cached in this class. For example files of .htm or .html will normally be of mime type "text/html".

    This class represents a request from a client. It contains information such as the URI of the request, the Http Verb used and the Http version used for the request. A member of this type is stored in the CHttpClient class.

    This class is used in the CHttpServer class to handle client connections. It handles the parsing of client requests and returning the appropriate response. A number of virtual functions are provided to allow end user customisation.

    To Do
    Contacting the Author


    • HTTP/1.0 compliant.
    • Uses the Windows registry to determine mime type thus simplifying configuration.
    • Supports passthrough plaintext authentication for files located on NTFS volumes.
    • Supports running under a configurable user account.
    • Supports binding to a specific IP address.
    • Supports multiple virtual directories.
    • Supports directory listing.
    • Server name returned can be easily configured.
    • Supports server redirection by means of the HTTP 301 status code.
    • Consumes very little system memory and CPU resources.
    • Compact and easy to follow implementation.
    • The interface provided is synchronous which provides an easier programming model than using asynchronous sockets.
    • The code does not rely on the MFC socket classes. These classes have a number of shortcomings, one of which causes problems when they are used in NT services.
    • The code can be used in a console application without any problems.
    • The classes are fully Unicode compliant and include Unicode built options in the workspace file.


    • To use the class in your code the following modules in your project:
      • base64.cpp/h
      • HttpClient.cpp/h
      • HttpMimeManager.cpp/h
      • HttpResponseHeader.cpp/h
      • HttpSocket.cpp/h
      • W3Mfc.cpp/h
      You will also need to copy over all the resources from the w3mfc.rc file into your resource file.
    • Your code will need to include MFC either statically or dynamically.
    • You will need to have a functioning winsock stack installed and correctly initialised prior to starting the web server. Depending on your application, this will involve calling either WSAStartup() or AfxSocketInit() at startup of your application.
    • You will also need to have afxtempl.h ,winsock.h or afxsock.h and afxpriv.h in your precompiled header. The code will work just aswell in a GUI or console app. The code should also work in a multithreaded application, although it has not be explicitly tested in this scenario.
    • To see the class in action, have a look at the code in InitInstance() in the module main.cpp on how to start up and stop the server.


    V1.0 (4th May 1999)
    • Initial public release.

    V1.1 (29th June 1999)

    • Implemented support for "HEAD" command.
    • Sample provided now also displays the HTTP verb used.
    • Sample provided now also displays the date and time of each request.
    • Now fully supports multiple virtual directories.
    • Now fully supports URL's with encoded characters.
    • Implemented support for "DELETE" command.
    • Now returns an "Allow:" HTTP header.
    • Timeout for requests is now 90 seconds if built for debug.
    • Now supports directory listing.
    • User name is now displayed in the log window.

    V1.11 (29th February 2000)

    • Fixed a number of VC 6 level 4 warnings.
    • Now empties any passwords transmitted once they are used.
    • Now implements W3C Common Logfile logging to the console window.

    To Do

    • Support for CGI.
    • Support for ISAPI.
    • Support for NSAPI.
    • HTTP/1.1 support.
    • TransmitFile support.
    • Integrated search tool.
    • Support for NCSA and Apache Server Side Includes (SSI).
    • Multithreading / thread pool support to improve performance.


    • Support for SSL.
    • NT authentication.
    • PCT support.
    • Integrated Certificate manager.


    • Support Apache compatible common logfile format log files.
    • W3C extended log format.
    • Log to ODBC database.
    • Daily log files.
    • Log file cycling.
    • Log file archiving.
    • Customizable log file formats.
    • Real-time performance counters.
    • NT Event Log logging

    Contacting the Author

    PJ Naughter
    29 February 2000


    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here


    About the Author

    PJ Naughter
    United States United States
    No Biography provided

    You may also be interested in...

    Comments and Discussions

    GeneralObtaining MIME type for unregistered file types using FindMimeFromData() Pin
    ejg12310-Nov-08 13:41
    memberejg12310-Nov-08 13:41 
    GeneralRead Response optimisize Pin
    thomasCAE13-Feb-07 10:48
    memberthomasCAE13-Feb-07 10:48 
    GeneralBug in Transmit Directory Pin
    thomasCAE16-Nov-05 2:13
    memberthomasCAE16-Nov-05 2:13 
    GeneralBug in CThreadPoolServer Pin
    thomasCAE16-Nov-05 2:01
    memberthomasCAE16-Nov-05 2:01 
    GeneralBug HttpCGI.cpp of W3Mfc 1.72 Pin
    Gregoire9-Oct-05 6:08
    memberGregoire9-Oct-05 6:08 
    GeneralISAPIMap Pin
    rgordon9922-Sep-03 18:10
    memberrgordon9922-Sep-03 18:10 
    GeneralRe: ISAPIMap Pin
    pjnaughter22-Sep-03 23:12
    memberpjnaughter22-Sep-03 23:12 
    GeneralRFC 2045 Pin
    Chester Lu22-Sep-03 11:18
    memberChester Lu22-Sep-03 11:18 
    GeneralRe: RFC 2045 Pin
    pjnaughter22-Sep-03 12:17
    memberpjnaughter22-Sep-03 12:17 
    GeneralWorking minimized Pin
    PatrickL12-Aug-03 19:30
    memberPatrickL12-Aug-03 19:30 
    GeneralRe: Working minimized Pin
    pjnaughter12-Aug-03 22:46
    memberpjnaughter12-Aug-03 22:46 
    GeneralRe: Found a solution ! Pin
    PatrickL13-Aug-03 9:33
    memberPatrickL13-Aug-03 9:33 
    Questionwhat is the difference between http 1.0 & http1.1 Pin
    mathieu ruellan10-Dec-02 22:27
    sussmathieu ruellan10-Dec-02 22:27 
    AnswerRe: what is the difference between http 1.0 & http1.1 Pin
    R. Reyes21-Feb-03 1:46
    memberR. Reyes21-Feb-03 1:46 
    GeneralLatest version. Pin
    Brian Delahunty19-Jun-02 5:38
    subeditorBrian Delahunty19-Jun-02 5:38 
    GeneralGreat Job Pin
    slashp11-Jun-02 10:32
    memberslashp11-Jun-02 10:32 
    QuestionHow to start it? Pin
    -= Matt Newman =-1-Nov-01 13:55
    member-= Matt Newman =-1-Nov-01 13:55 
    AnswerRe: How to start it? Pin
    P J Naughter31-Jan-02 23:48
    memberP J Naughter31-Jan-02 23:48 
    GeneralA BUG!! Pin
    Varun Shoor16-Jun-00 5:25
    sussVarun Shoor16-Jun-00 5:25 
    GeneralRe: A BUG!! Pin
    P J Naughter31-Jan-02 23:49
    memberP J Naughter31-Jan-02 23:49 
    Generalhttp://localhost:90/.... Pin
    Masaaki Onishi8-Jun-00 17:11
    sussMasaaki Onishi8-Jun-00 17:11 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    Permalink | Advertise | Privacy | Terms of Use | Mobile
    Web04 | 2.8.180515.1 | Last Updated 8 Apr 2000
    Article Copyright 2000 by PJ Naughter
    Everything else Copyright © CodeProject, 1999-2018
    Layout: fixed | fluid