Home    News    Product    Order    Forum    Feedback    Partner    Profile  © Neatware 2000
 Neatware Snaml
Search
  Output
Home  : Last Update: Wed Apr 12 20:05:10 2000

 
Snaml -- XML

 
Snaml Basic
      Introduction
      Syntax
      Control
      Types
      Modules
      Status
Snaml HTML
      HTML
      Structure
      Link
      Objects
      Text
      Font
Snaml CSS
      CSS
      Script
Snaml CGI
      CGI
      Variables
      Output
      Form
      Application
Snaml XML
      XML
      Document
      EBNF
  1. Output

    CGI program works as a filter. It gets input from client and output the processed result. Usually CGI program outputs a HTML file. It is possible to return binary data or send HTTP status codes. _cgi command is on the header of HTTP of a CGI program. The simplest header is 'Content-type: text/html'. It specifies that the output has a HTML format. The 'Content-length' header specifies the length (in bytes) of a binary data. 'Expires' header specifies the expire date and time of a document for reloading.

    In addition, 'Status' specifies the status of a request. It includes three-digit numerical status code. Usually, value 200 indicates success; 204 is no response; 301 means document moved; 400 has a bad request; 401 is unauthorized; 403 is forbidden; 404 represents not found; 500 has internal server error; 501 means not implemented, and so on.

    The rarely used 'Location' header specifies the server redirection; 'Pragma' header controls document cache; and 'Refresh' header lets client reload document. Finally, 'Set-Cookie' header stores a tag data on the client for tracing. The 'Location' and 'Status' must be used in a complete header specification.

    When a CGI program returns a complete HTTP header, there is no overhead for server. Its output is directly sent to the client. Therefore, server can not intercept the output errors. In the NCSA server, CGI program must have a file name with nph- prefix for complete header.

    #!/usr/local/bin/snaml
    _cgi "Content-type: text/html"
    _html
    _head
      _title 
        _quote "CGI Environment Variables" 
      title_ 
    head_
    _body
      # list environment variables 
      foreach key [array::names ::env] {
        _quote "env($key) = $::env($key)"
        _br
      }
    body_
    html_
        

  2. Example

    The status of Neatware web site is:

    env(GATEWAY_INTERFACE) = CGI/1.1 
    env(DOCUMENT_ROOT) = /home/neatware/HTML 
    env(SERVER_PORT) = 80 
    env(HTTP_HOST) = www.neatware.com 
    env(REMOTE_ADDR) = 209.148.144.12 
    env(HTTP_CONNECTION) = Keep-Alive 
    env(HTTP_PRAGMA) = no-cache 
    env(SERVER_NAME) = www.neatware.com 
    env(SERVER_PROTOCOL) = HTTP/1.0 
    env(REMOTE_PORT) = 1215 
    env(REQUEST_METHOD) = GET 
    env(SERVER_SOFTWARE) = Apache/1.2.6 FrontPage/3.0.4 
    env(REMOTE_HOST) = 209.148.144.12 
    env(QUERY_STRING) = 
    env(HTTP_USER_AGENT) = Mozilla/3.0Gold (Win95; I) 
    env(PATH) = /usr/local/bin:/usr/bin:/bin 
    env(SCRIPT_NAME) = /cgi/status.cgi 
    env(SCRIPT_FILENAME) = /home/neatware/HTML/cgi/status.cgi 
    env(HTTP_ACCEPT) = image/gif, image/x-xbitmap, 
      image/jpeg, image/pjpeg, */* 
        

Output

Example

     
Home  : Last Update: Wed Apr 12 20:05:10 2000
Search
  Output
 Neatware Snaml
Home    News    Product    Order    Forum    Feedback    Partner    Profile  © Neatware 2000