MacHTTP Questions and Answers
- Q: How come my scripts and CGI applications don't work from my form? It just shows
junk on the screen.
A: If you use the "Open Local" or "Open File" command from your WWW client
running on the same Mac as MacHTTP to open your form, you'll never get this to work.
Opening a file directly with the client, without connecting to the MacHTTP server first
means that the client is using a "file://" URL instead of a "http://" URL to access the
file. If you don't have a complete URL specified as the action procedure in your form,
the client has no idea how to run your CGI script or application.
- Q: How come MacHTTP doesn't index directories automatically like Unix servers?
A: This is a HUGE security hole in Unix servers. It means clients can access ANY file
in a directory. MacHTTP doesn't want to be responsible for allowing a malicious user to
crawl all over your hard drive, looking at stuff in every directory. You can accomplish
this same functionality with a few lines of AppleScript code. See the examples that come
with MacHTTP for details.
- Q: Can MacHTTP serve up a default file when a directory is accessed?
A:Yes! A file named the same as the INDEX file specified in your MacHTTP.config file
can be present in each directory in your MacHTTP document tree. Accessing a URL that points
to a folder name will return the default document in the folder instead.
- Q: Am I stuck with serving HTML files for my INDEX, ERROR, and NOACCESS files?
A:No. MacHTTP will serve any type of document that has a suffix mapping in the
MacHTTP.config file for these 3 special files. Scripts and CGIs are especially handy for
handling ERROR condititions, since they have access to information like the URL of the
non-existent file and the page that referenced that URL. This is handy when generating
automatic replies to clients, rather than simply returning a generic error message.
- Q: My SCRIPT or CGI doesn't run. I get nothing on my client's screen.
A:Your script or CGI is is failing before it returns a result to MacHTTP.
Try running the script or CGI interactively, using the Script Editor. Pass dummy
arguments or pre-defined variables to get the script to run. It also helps to use
AppleScript's try...on error construct to trap errors, so something is always
returned to MacHTTP.
- Q: MacHTTP can't find files on my other drive, even though I have an alias to its folders
in MacHTTP's document tree. What's up?
A: MacHTTP can only resolve aliases to individual files, not folders or disks.
- Q: How do I return a complete HTML document or GIF from a script or CGI application?
A: URL redirection is the trick. The "Found 302" HTTP response code makes this possible.
See the HTTP/1.0 standard
for details. Return this status code and a "Location:" header field with a complete URL to
the document you want to return.
- Q: How can I retrieve MacHTTP's status window if it's moved off the screen somehow?
A: Launch MacHTTP and hold down the mouse button while MacHTTP starts. This will reset
MacHTTP's window to its default position.
MacHTTP Frequently Asked Questions
- This is a separate site, managed by Grant Neufeld, which has detailed answers to some
of the more detailed MacHTTP questions.