[Questions & Answers]
[Mac WWW FAQ]

CGI Questions

What is a CGI?

CGI (Common Gateway Interface) is a means for web servers to communicate with other applications to get specialized information for the client. On the Macintosh, the web server uses an AppleEvent to send information about the client's request to the CGI. The CGI then does its custom processing and returns a result to the web server in the form of a reply to the AppleEvent. The web server then passes the result on to the client.


What is the difference between CGI and ACGI?

CGI is a synchronous protocol, ACGI is Asynchronous. What this means is that a CGI application ties up the web server until it is done (only applicable to non-threaded servers) and an ACGI lets the server carry on with responding to connections and returns its result to the server when it's done.

ACGI is usually preferable to CGI. Almost any application that can run as a CGI can run as an ACGI. Try switching your CGIs to ACGI, test them to see that they still work, then smile at the ease of this (not guaranteed for every program, but the vast majority work this way).


How can I have my CGI make the client retrieve another document, graphic or other file? (URL redirection)

You need to use URL redirection. Your CGI should return a header as follows:

HTTP/1.0 302 Found
Location: URL

URL must be the complete (not partial or relative) URL specifying the file the client should retrieve.

For example, returning the following HTTP header would cause the client to access the URL "http://www.nisto.com/grant/":

HTTP/1.0 302 Found
Location: http://www.nisto.com/grant/


Why doesn't my CGI work through a proxy server?

The $ gets translated to %24 with CERN HTTPd, and the web server doesn't translate it back. This is because the CERN proxy server is broken (this may be fixed in more recent versions).

As a possible solution, rewrite the CGI to check the url for '%24' and convert it, or report it as a proxy server error.


How can I use HyperCard as a CGI?

There are two methods available:

  1. Put a CGI AppleEvent handler in your "Home" stack.
  2. Have HyperCard already running and have a stack with a CGI AppleEvent handler open.


See Also


[Contents]
[Index]
[Feedback]
[Previous]
[Next]


Copyright ©1994-1998 Grant Neufeld.
Mac WWW FAQ, Nisto and nisto.com are trademarks of Grant Neufeld.