HTTP defines communication by a client and a WWW server. All HTTP 1.0 transactions follow a similar general format:
The client contacts the server at a designated port number (by default this port number is 80, at TECFAMOO it is 7778 (for E_Web) or 7777 (for WOO). Next it sends a document request with a method indicating which document (or program) to fetch and with which protocol. HTTP 1.0 defines three main methods:
<HEAD>....</HEAD>of a HTML document.
Here is a typical example of a GET file request to a standard www server
GET /tecfamoo/welcome.html HTTP/1.0and here the same to our E_Web interface:
GET /4848 HTTP/1.0
Next, the client will send optional header information to tell the server more about its configuration, the server's internet machine host name or number, the document formats it will accept, etc. Here is a typical request from a client with the ``GET method'':
GET /4848 HTTP/1.0 Connection: Keep-Alive User-Agent: Mozilla/3.01 (X11; I; SunOS 5.4 sun4m) Pragma: no-cache Host: tecfa.unige.ch:7778 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*
A typical request from a client with the ``POST method'':
POST /cgi/4848 HTTP/1.0 Referer: http://tecfa.unige.ch:7778/4848 Connection: Keep-Alive User-Agent: Mozilla/3.01 (X11; I; SunOS 5.4 sun4m) Host: tecfa.unige.ch:7778 Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */* Content-type: application/x-www-form-urlencoded Content-length: 42 name=Daniel&age=old&string=Hello+there+%21In section 8.7.2 you will see how user data is encoded with CGI.
The server also replies by first sending a status line , header information about itself and the contents, follwed by a blank line and the contents.
The status line contains three fields: HTTP version, status code, and a more human readable description. Status code is a 3 digit number and there exist a lot of them. Here are a few examples:
|200 OK||The client's request was successful|
|and server's response contains the requested data|
|302 Moved Temporarily||The requested URI must be taken as indicated in the ``Location'' header,|
|but the URL is fine for reuse|
|404 Not Found||The requested document was not found|
|500 Internal Server Error||You wrote some bad CGI that breaks:)|
Here is a typical reply from the E_Web interface:
HTTP/1.0 200 ok Date: Wed, 16 Apr 97 22:54:42 GMT Server: E_WEB (E_MOO-Web-Server/1.2d - Not WOO) (LambdaMOO 1.8.0p5) Content-type: text/html <title>Query results</title> <h1>Query results</h1> ......
Here is another one from E_Web that shows a 500 status internal error. It also shows that debugging CGI code is quite easy with E_Web.
HTTP/1.0 500 internal error Server: E_WEB (E_MOO-Web-Server/1.2d - Not WOO) (LambdaMOO 1.8.0p5) Date: Thu, 17 Apr 97 11:06:09 GMT MIME-version: 1.0 Content-type: text/html <title>Error #500 internal error (http://tecfamoo.unige.ch:7778/cgi/4848)</title> <h1>Error #500 internal error</h1>" ...........
The formated content as seen by the user will be like the following (references to moo verbs are links!)
Error #500 internal error URL requested: http://tecfamoo.unige.ch:7778/cgi/4848 Reference code: #-6034:861271377 If you feel that you shouldn't have gotten this error, please report it to WebMaster. POST attempt tracebacked with: 4848:cgi_query, line 9: Variable not found (E_VARNF) ... called from 4361:html_cgi, line 23 ... called from 4361:http_request, line 6 ... called from $ehttpd:POST, line 19 ... called from $ehttpd:handle_request, line 22 (End of traceback for task 1285009894)After completing the request, the server will close the connection.
Now in order to write dynamic responses to user requests you need to learn how to write CGI programs.