httpd4Mac v123a
Thank you for taking an interest in 'httpd4Mac' (for Macintosh) now at version ALPHA 1.2.3 This program used to be called just 'httpd', but that caused some confusion, so I have renamed it 'httpd4Mac'. httpd4Mac is a simple program that allows you to use your Mac as a WWW server.
This home.html file is an HTML version of the file called 'About httpd4Mac...' that used to come with this program.
To see the latest httpd4Mac news and be able to download development versions of httpd4Mac (untested versions of the code) which may have bug fixes relevant to you, you could check out the experimental home page for httpd4Mac. Feel free to try this page out, but be aware that it is a public machine, sometimes the service may not be available and if people complain about the machine being slow, it may be stopped.
v123a is basically a release of the development version which has been running successfully for some time now on the server mentioned above.
The following areas are covered in this file:-
Index
This program is supplied free with absolutely no warranty and may do unthinkable damage
to your machine or data, for which I will accept no liability. Having said that, I didn't write
it to do that, but you must satisfy yourself it will not do any damage before using it.
You can do whatever you want with it except:-
- Distribute it without this file 'About httpd v12a'
- Charge money for it (fair duplication/floppy costs excluded)
Back to index
'httpd4Mac' is an fba (Faceless Background Application) that implements a minimal http server.
It currently supports the GET and HEAD methods, with full or simple requests. It ignores
'Accept' fields from the client. NB The http spec does not allow such a thing as a simple
HEAD request. The only simple method is GET. But seeing as the CERN server accepts it (and
the guy who invented WWW wrote that program) I thought I should also.
WHAT DOES THAT MEAN ?
That means it should work as a fairly straightforward WWW server. You should be able to write pages
with images, and have separate image, sound and movie files. What it does not (yet) support are
clickable images or forms and other interactive pages. I may write the code to support this later
but it is not planned at the moment. I have tried using MacWeb and X-Mosaic and X-Netscape to
retreive pages and they appear to work OK.
A Faceless-Background-App (FBA or Background-Only-App (BOA) as the name suggests runs in the
background. When you launch it you will see it go grey, but it will not appear to have run.
No menu will appear, nor will any windows. It will not appear in the application menu either.
This is perfectly normal, but unless you set the prefs file to notify you about major events,
you will not know if it is running or not.
At some stage I may code a foreground version which will have a menu and text window. This
will not be available for some time though.
Back to index
There is one other http server I know of for the Mac which is not free. The aim of 'httpd4Mac'
is to provide a free http server, which implements enough to serve out pages on your mac,
without it putting an enormous load on the machine. It is designed to be lightweight
and fast.
It may not be much good if you expect to have loads of pages and images, or if you want to
do more than just serve out static pages of HTML. At this stage I do not know how many pages
and what sort of load it can reasonably handle. Perhaps someone could tell me how it fares.
It is not a port of either CERN's or NCSA's for UNIX. It does not use the common code library.
The only reason I gave it a similar name was because I couldn't be bothered to think of a
diferent one.
Back to index
You will need a Mac running at least Sys 7, with MacTCP version 2.xx an internet connection, some memory and preferably a hard disk. I think that should do it.Back to index
Just launch it. You may need to read the section about memory allocation as well. It will look for its config/prefs file firstly in its own folder, then in the
system/prefs folder. If it does not find it, it creates it own from default info and quits.
This default prefs file can be edited to set up httpd4Mac how you want. The app will still
look 'greyed out' as if it is still running. This is normal. Just double click it again
when you wish to re-launch.
You will find this self-created prefs file in the preferences folder (within System folder)
You can place this prefs files in the same folder as httpd4Mac or leave it in the prefs folder.
I prefer keeping it with the app. Re-launch when you have edited the prefs file.
If httpd4Mac finds a prefs file, it checks the version as it is reading it in. If the notify option is on within the prefs file and the version is out of date, httpd4Mac will notify you. If you have an out of date prefs file, this means you may not be using the latest features of httpd4Mac.
You can let httpd4Mac create an up to date version for you by hiding your current prefs file (eg move out of httpd4Mac's folder or system folder). Re-launch the app and you will get the latest version.
Use a text editor to edit the prefs file. There are comments within it to help you. It
would probably help if you knew a bit about servers, http etc, but the sample prefs will work
so if you know nothing except how to write WWW pages then you could just re-launch. Apologies
for the fact that some of the configuration options don't work yet. Occasionally I refer to
the prefs file as a config file, but I'll try to avoid that.
Back to index
The partition is set at 500K. In fact httpd4Mac may run in a partition
of ~200K + size of largest file expected to be served out by httpd4Mac. ie If you have a
100K image file that can be accessed, then the partition should be at least 300K. It may
run with considerably less though. The memory requirements can depend on many variables.
If you do not set enough memory you may get problems.
The best way to find out the ideal partition size is to start httpd4Mac with the debug
option on with verbose messages, then force it to quit immediately. If you do not have
a process management utility, then just restart your Mac. When you examine the debug log
file you will see some lines showing a memory analysis. As long as there is enough free
memory to hold the largest file you expect to serve, plus a bit spare (say 10%/5K which
ever is larger, this will probably do. However you will get better results the more memory
you allocate.
To allocate more memory use the Get Info function from the Finder File menu.
Back to index
- dnr
- This option tells httpd4Mac to do a reverse DNS look up on each connection it receives when logging. If you are not logging this makes no difference. If this option is off the server may run a bit faster. If an error occurs when looking up the machine name, then only the IP number will be recorded. Log info is actually queued while the client request is being serviced, the actual writing to a log file being deferred until later. Should httpd4Mac be forced to shut down before all logging is complete, it is rushed through without looking up names, so you may find just a list of numbers occasionally at the end of the log file.
- mime_def
- Allows you to associate siffices and/or Mac file Types with a MIME Type, read about MIME below.
- create_access_log
- Attempts to create a new log file each time httpd4Mac is launched. If it fails logging is disabled. If an old file exists it is renamed with a .bak extension. (If a .bak file exists it is simply deleted) If this renaming process fails then again logging is disabled. If this option is off, but a file is found with the correct name (eg httpd_access_log) then log info is simply appended to this file.
Back to index
MIME stands for Multipurpose Internet Mail Extensions. While most operating Systems now revolve
around the idea of a file as a basic unit of storage on a disk, none has really defined
a standard way of identifying a particular file type or format. Various OS have their own
methods though. Apple incorporates a file type into the file header, meaning you can have
any file name and change it, but the contents are still regarded by the OS as having not changed.
UNIX users rely on file suffices (eg .html) and sad DOS users rely on 3-letter
suffices (eg .htm) Mac users can also use suffices if they want.
The idea of MIME (I think) was to fill that gap and provide a OS-Independent method of
identifying information types, like GIF image files for instance. RFCs 1521 - 1524 describe
MIME, but it was really meant not to be incorporated into OS, but used when transferring
files from machine to machine by E-Mail.
As the World Wide Web uses many different file types and should be almost platform independent
I guess it made sense for the designers to choose MIME. In fact the http spec allows for
a MIME dialogue to take place between client and server, with the client saying 'I know about
xxx format' and the server saying 'The file you are getting is xxx format'
The idea of the mime_def directive is for you to tell httpd4Mac what mac file suffices and/or what
mac filetypes you are associating with what type of MIME format. Some examples are given in the
sample prefs file.
When httpd4Mac receives a request it works its way through the list of
mime_def directives, until it finds a match. Unless you know exactly what type of Mac
file that, say your scanner software produces, you may want to just stick with suffices. Mac text files
always have a file type of 'TEXT' though. httpd4Mac alway slips in a default def of
AnyFileType & AnySuffix = text/plain, for those types that do not match at the end of the list.
eg You can assume that the list always ends (internally) with
mime_def '*' & * = text/plain 7
You can put a wildcard character (*) in the mime_def line to match against anything.
httpd4Mac converts all URLs it receives into lower case and then attempts to match to a MIME
def. Make sure your mime_def suffices are in lower case !
NB There are some MIME types which have 'application' in them. You cannot use most of these with
httpd4Mac to deliver a Mac application to a client. This is because a Mac application uses
both the resource and data fork of the file, but httpd4Mac serves only the data fork. What
you have to do is convert the app to a bin-hex text file and define a MIME type that maps
.hqx to application/mac-binhex40. See the section on Files that can be served
Back to index
Just copy http4Mac for each 'server' you wish to run. Place the copies in separate folders and
create separate prefs files, also placing these in the folders. Set them up to run on different
TCP ports and then launch them all.
Make sure you set them up to serve on different TCP ports. Although it will not detect multiple
servers on the same port and will appear to run fine, you may get some unexpected results.
Back to index
httpd4Mac can potentially serve any file in the same folder as the app. This is the same if you
launch it by means of an alias (Say by putting an alias in the startup items folder), the files
served will be only those in the same folder as the app. If the URL '/' is requested (ie
'http://host.name/') httpd4Mac looks for the file 'home.html'.
'/' delimiters in the URL indicate sub-dirs in the usual manner (even though the specs say
the use of the same delimter as is used for UNIX directories is co-incidence)
You can happily use the '.' and '..' format for relative URLs, well, with the clients
I tried anyway. You cannot (yet) put folder aliases in the app folder to serve out files from
elsewhere. All httpd4Mac understands at the moment is normal folders and files. It does not
distinguish between text, sound, or image files, as regards data, but will send different MIME headers accordng to the MIME definitions.
Make sure of course that sound/image files you serve out match what the client expects, the
standard format seems to be Sun ULaw sounds format and GIF image format.
You can use httpd4Mac to serve out Mac-specific files for Mac users only (eg applications). The trick is to convert them to their bin-hex equivalent first (using Bin-Hex4.0). This will give you a '.hqx' file. Using the mime_def directive create a mime type 'application/mac-binhex40' that will map to all '.hqx' files.
On the client side to have to set up the browser so that it understands this new MIME type and suffix and that it launches a program called 'Stuffit Expander' when it receives such a file. This would probably be done under helper applications setup in your browser. Stuffit Expander can be obtained from your fav ftp site.
Back to index
If you don't know I'm not going to explain it here. There is a web site offering Help on HTML which I used to learn and this also has references to other sites.
WWW pages are actually just text file written in a language called HTML, and include pointers
to the image and sounds files etc. These files can be local to the machine or served out from
a remote machine. Some client programs like MacWeb, come with local files written in HTML
explaining how to set it up. These are often set up as the home page as default. You'll
get an idea about HTML simply by looking at those files with a text editor.
Back to index
- Error logging
- Prevent serving out of logs and prefs file etc.
- Clickable image support
- Support for Finder aliases (+ maybe remote volumes)
- Better caching
Back to index
- Speed improvements
- Understand client accept fields and act on them, maybe
- Do prefs file syntax check
- A version that runs in foreground and prints log output to a window.
- A configuration program with proper User Interface to allow easy configuration. May allow remote changing of configuration by Program Linking.
- An option to give directory listings in HTML
Back to index
- Support Applescript or anything that might be needed for interactive pages ie Search Functions. Clickable images are coming though !
- Support additional methods.(eg POST for fill out forms)
This is mainly because I do not understand the CGI interface or how things like Applescript/MacPERL would drive/be driven by httpd4Mac, but also because of time. If someone can point me to a good source for explaining this, then it may be a possibility. I know there is a mailing list for MacPERL, but I have not had time to enquire further yet.Back to index
- At present there is nothing to stop you requesting the debug info or prefs file (or even httpd4Mac itself !). Such action might have some very weird if not dangerous results, I would not recommend it.
- httpd4Mac takes a little time to get going. Usually access is not possible until about 10 seconds or so after start-up. The reason is because httpd4Mac relinquishes control ASAP and does its initialisation slowly in the background. The reason being if the app is in your startup items folder, the boot process does not appear to be slowed down by it.
- httpd4Mac uses a crude caching mechanism to store files that have previously been requested. Basically an item is cached until the copy is a certain age, no check is made to see if the file has changed. This is fine if you do not change the pages pages often, but if you do you may wish to set this lifetime to a lower value. A better caching system will be in future versions. The cache life is controlled in the prefs file.
Back to index
This is my first TCP programme. It was developed on Think C v7. I made use of some
utilities, which you also find useful if you have any problems.
- MacsBug
- Apple's low level debugger
- ZapTCP
- Apple extension, helps when TCP apps crash unexpectedely
- MacTCPwatcher
- Utility from Peter Lewis for testing MacTCP functions
- ZoneRanger
- Utility from Joshua Golub, used for examing memory
- ProcessFinder
- Utility from Edward Harp, used to kill the background app without rebooting
I may release the source code for this app later, when I have had a chance to tidy it
up a bit.
It was developed on a Mac IIci, running Sys 7.1, MacTCP 2.0.4, with 20Meg of RAM. You
won't need that much though. It will not run on a 68000 machine. It does not use any
floating point code. It has also been run for many weeks now on a Centris
610, again Sys 7.1, MacTCP 2.0.4
I have made some changes to the code which should allow a native PPC version. Actually I've already made it, but it just crashes all the time, so I haven't bothered to release it just yet :-). However I have had mail from two or three people indicating it is already being used successfully on Power Macs under emulation.
Back to index
FROM 1.0a TO 1.1a (Released 17 Jan 1995)
- You now get a notification telling you when httpd is running and ready for access.
- An option to limit the life of cached items is now in the prefs file.
- Bug fixed that meant if you requested a URL with lower 'ASCII-value' than the first request of the day it crashed. By ASCII-value I mean comparing the ASCII values of the individual characters as you would if you were sorting alphabetically. ie 'bug' is less than 'home' and 'help' is less than 'home'
FIXES/IMPROVEMENTS FROM 1.1a TO 1.2a (Released 28 Feb 1995)
- A bug that caused a bus error when httpd4Mac quits is gone.
- HEAD method is now supported
- MIME support
- Access logging is done, with DNS lookup if needed.
- URLs are no longer case sensitive.
- Change of format of debugging file, more messages added. Each line now peceeded with function name
- Some general improvements in the way some things are done.
CHANGES FROM v12a TO v123a
- Taken out a few bugs that meant the cache did not flush correctly. This was very irritating if you were trying to use httpd4Mac for WWW development.
- In addition some fixes have been added that help prevent the debug log being filled with the same message over and over again.
- Cured a memory leak which occurred when non-existent pages were requested.
- Fixed a bug that caused loss of some log info at quit time.
- Fixed a problem with long MIME-Types
Back to index
So far the only incompatability brought to my attention is a program called 'autodoubler'
(thanks to phardman@ssci.liv.ac.uk (Peter Hardman)) Compressed files get sent
in compressed form. It appears they do not get uncompressed on the fly as they should. I have
also had one E-Mail suggesting problems with Sys 7.5.1, but no further information was forthcoming on that....Back to index
I will always place new versions on the info-mac archives at Stanford. I do not plan to
post them elsewhere yet, so latest copies can be obtained there.Back to index
httpd4Mac is my first piece of freeware and I would be pleased to know it is being used at all.
Please send me any comments you have. Of course useful comments that would lead to bug fixing
would be appreciated. I always read my E-Mail and I usually reply. However if I get loads of E-Mail, I may not be able to reply. It may be better
to post on USENet. I often read comp.sys.mac.comm, plus c.s.m.programmer and sometimes post. Obviously a good place to post now would be on comp.infosystems.www.servers.mac I do read this newsgroup.
Before you either send out E-Mail or USENet postings you might wish to ty a few things.
:-
- Switch on the notification option in the prefs file.
- Also switch verbose debugging
- Read this page more thoroughly.
Some of this information may explain what the problem is. Also it may help me when trying to fix it.
I have sometimes referred to this program as shareware, sorry if that has caused confusion. It
is freeware, you have no obligation to me regardless of what you want to use it for, but it
would be nice to hear from you.
Bill Melotti
Rm2.09, R68
Rutherford Appleton Laboratory
Chilton, Nr Didcot
OXON
OX11 OQX
UNITED KINGDOM
Bill Melotti 25 May 1995
bill.melotti@rl.ac.uk