Version 126 of TclHttpd

Updated 2006-11-27 02:42:22

TclHttpd is a tcl based web server. The author is Brent Welch. It currently resides at sourceForge [L1 ], which also hosts its modestly active mailing list [L2 ].

 What: Tcl Httpd server
 Where: http://tclhttpd.sf.net/ 
 Description: A Tcl http web server.  Works out of the box as a web server,
        but is designed to be a Tcl application server.  Supports distributing
        HTML plus Tcl templates.
        Currently at 3.5.1.
 Updated: 05/2004
 Contact: See web site

More than a web server, TclHttpd is a platform for building Tcl applications with an HTTP interface to them. It so happens that it runs as a standalone web server "out of the box", but it is designed with extensibility in mind. You can find distributions at [L3 ] or [L4 ]. Included in the distribution is a copy of a book chapter (from 3rd edition of Practical Programming in Tcl and Tk) that describes the features of the server [L5 ].


New Release:

The 3.5.1 release (05/2004) fixes many bugs, adds new features and includes a Starkit distribution and a bundle distribution (batteries included.)

It can be found here:

CVS Snapshots: A nightly snapshot of tclhttpd CVS source is available as a tar.bz2 here: [L6 ] and in ZIP form here: [L7 ]. If you find a bug, it might be worth checking one of these out in case it's been fixed.


Tclhttpd Pages:

Tclhttpd - Getting Started how to begin to use Tclhttpd

Tclhttpd Domains lists the kinds of 'domains' Tclhttpd supports.

Tclhttpd Examples for worked examples, gems, mini-applications using Tclhttpd.

TclHttpd Templates for hints and tips about the tclhttpd .tml template system.

TclHttpd: The .tml File explains the use of /.tml files

TclHttpd Needs for projects and flights of fancy about what would improve the already amazing TclHttpd.

TclHttpd Applications for testimonials and descriptions of applications built around Tclhttpd.

Tclhttpd Hints and Tips for questions, problems, etc.

Tclhttpd as a Unix service, Tclhttpd as a Windows service and Tclhttpd as a starkit show how to deploy Tclhttpd.

Starting Tclhttpd in a slave interpreter discusses embedding Tclhttpd into other applications, web-enabling them.

Starting Problems for specific problems starting tclhttpd

minimal tclhttpd discusses techniques for cutting down Tclhttpd to bare bones. There's also a 250-line form of Tclhttpd called mini [L8 ].

Mini-Tutorial: Content type and file extension - Tclhttpd and content type

aku's Low-level documentation (written in doctools) for httpd.tcl, the protocol engine.

Other macro processing s/w can be found under Template And Macro Processing.


When trying to run Tclhttpd under Windows XP I get the following error, no matter if I use the Starkit or the normal distribution:

    could't open "/tmp/tclhttpd.default": no such file or directory

WJR A quick fix is to create a tmp folder on the root of the drive where TclHttpd is installed (e.g. c:\tmp). This is a bug, on Windows tclhttpd.default should probably be put in the the Windows equivalent (e.g. c:\temp).

I reported the bug.

CMcC This bug has been fixed for months, as noted in the sf bug report.

WJR Are you referring to bug ID 1030323? This problem still occurs in 3.5.1. Should I try the CVS version?

CMcC definitely ... there's a nightly snapshot at the top of this page.

Peter Newman 17 December 2004: This bug may have been removed (from the CVS) months ago, but it's still in the latest downloadable versions (source and tclkit, at least). And affects Windows 98SE (and presumably every other version of Windows,) too. It generates a fatal error, thus preventing the latest downloadable versions of TclHttpd from even starting (under Windows).

But you can easily fix it by making the changes shown on the sourceforge CVS in:-

 tclhttpd/lib/auth.tcl
     Revision 1.21
     Diff to previous 1.20
 and;
     Revision 1.20
     Diff to previous 1.19

The easiest way to do this to to just download Revision 1.21, and replace your existing auth.tcl with it.


dzach 2006-9-1 I can't get a .tml file to render a utf-8 page right using the Doc_Dynamic method of tclhttpd. The HTML part of the following test-utf8.tml file is valid XHTML, validated with the W3C validator:

 [Doc_Dynamic]
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
   <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
   <title>utf-8 test</title>
 </head>
 <body xml:lang="el" lang="el">
 <p>
        Good morning in Greek:<br/>
        Kalyµe'ra!<br/>
 <br/>
        Internationa Phonetic Association (IPA) phonetics<br/>
        writer    'r.aI*R
 </p>
 </body>
 </html>

When this template is served by tclhttpd, the greek and IPA parts appear garbage in the browser. If I take out the Doc_Dynamic line, and therefore allow tclhttpd to cache the html page, the browser shows the non ASCII portions correctly.

More to that: if I do an encoding convertto utf-8 with the page content, I get the correct display. So obviously, a conversion to utf-8 has to be made somewhere, before the result is sent to the client, when using the Doc_Dynamic template technics. I am looking for an answer in the code, but if anyone knows better...

(A day later) If my observations of the problem are correct and not a result of my particular tcl setup, it seems that the issue might be in the processing done in the slave interpreter.The place where the processed template is returned is the end of the TemplateInstantiate proc. By converting the contents to utf-8, my problem seems to be solved (not fully tested it though).

Look for the code:

    set dynamic [interp eval $interp {uplevel #0 {set page(dynamic)}}]
    if {!$dynamic} {

        # Cache the result

        catch {file delete -force $htmlfile}
        if {[catch {open  $htmlfile w} out]} {
            set dynamic 1
            Log $sock "Template" "no write permission"
        } else {
            puts -nonewline $out $html
            close $out
        }
    }
    return $html
 }

Substitute the return command with:

 #
 # return $html
 #
   return [encoding convertto utf-8 $html]
 }

This of course is a hack, and it propably works only for utf-8, but not for the numerous 8-bit encodings supported either by tcl or the browser. Anyway, in the absense of a proper solution, it may be useful to someone else too. Has anyone else been able to duplicate the problem with the test-utf8.tml given above?


User contributions


As one wag put it, "tclhttpd is the best tcl 7.4 app in existence."


a tclhttpd scripted document


RLH 2006-11-26: Is there any thought in seeing how the stuff coming in 8.5 can make TclHttpd better/faster?


[ Category Application | Category Mailing List | Category Package | Category Internet | Category TclHttpd Category Webserver ]