Draft of announcement message

Tim Bunce (Tim.Bunce@ig.co.uk)
Fri, 2 Jun 1995 21:31:42 +0100


I've been meaning to do this for ages.

I intend to post this to c.w.i.a.cgi early next week.

Comments welcome.

I have a minor update of the CGI::* modules to release soon. There are
no significant code changes, it's 99% documentation enhancements.

Tim.


--- snip ---

Newsgroups: comp.infosystems.www.authoring.cgi
Subject: ANNOUNCE: CGI Modules for Perl 5 - CGI::Base, CGI::Request and URI::URL


CGI::Base    - HTTP Daemon Common Gateway Interface (CGI) Base Class
CGI::MiniSvr - Adds to CGI::Base the ability to become a mini server
CGI::Request - Parse client request via a CGI interface
URI::URL     - Uniform Resource Locators (absolute and relative)

These modules have been developed and matured over the past few months
by the CGI-perl@webstorm.com and libwww-perl@ics.uci.edu mailing lists.

These modules are not quick hacks. Considerable design and development
effort has been spent on making them as complete and correct as practical.

They are available from http://web.nexor.co.uk/public/perl/contrib/lib/
HTML versions of the documentation is also available there.

All modules are object oriented and include self-test and/or example
code.  All modules can be freely used and distributed under the same
terms as perl itself.  All modules require Perl5.001e or later.


Highlights taken from the module pod help text:

CGI::Base:
   
  $cgi = new CGI::Base;       # reads vars from environment
   
  $cgi->var($name);           # get CGI variable value
  $cgi->var($name, $value);   # set CGI variable value
  @names  = $cgi->vars;       # lists standard CGI variables
   
  $mime_type  = $cgi->accept_best(@mime_types);
  $preference = $cgi->accept_type($mime_type);
   
  $cgi->pass_thru($host, $port); # forward request to server 
  $cgi->redirect($url);          # redirect client 
  $cgi->done($dump);     # end response, does NOT send </BODY>

  # Other functions (these may move to another module later):

  @escaped_texts = html_escape(@texts);   # '>' -> '&lt;' etc
  @texts         = html_br_lines(@texts); #  \n -> '<BR>'
  SendHeaders();  # send and flush HTTP header(s)   
  CGI::Base::Debug($level);


CGI::MiniSvr:    (is a sub-class of CGI::Base)
   
  $cgi = new CGI::MiniSvr;
  $cgi = new CGI::MiniSvr $port_or_path;
  $cgi = new CGI::MiniSvr $port_or_path, $timeout;
   
  $cgi->spawn;              # fork/detach from httpd
  $cgi->get;                # get input
  $cgi->done;               # send </BODY> and close connection


CGI::Request:
   
  # Simple interface: (combines SendHeaders, new and import_names)
   
  GetRequest($pkg);
  $req = GetRequest();
   
  print FmtRequest();     # same as: print $req->as_string
   
  # Full Interface:
   
  $req = new CGI::Request;    # fetch and parse request

  $field_value = $req->param('FieldName');
  @selected    = $req->param('SelectMultiField');

  @keywords = $req->keywords; # from ISINDEX

  print $req->as_string;  # format Form and CGI variables

  # import form fields into a package as perl variables!
  $req->import_names('R');
  print "$R::FieldName";
  print "@R::SelectMultiField";

  @value = $req->param_or($fieldname, $default_return_value);

  # Other Functions:

  CGI::Request::Interface($cgi);  # specify alternative CGI
  CGI::Request::Debug($level);    # log to STDERR (see CGI::Base)

  # Cgi-lib compatibility functions
  # use CGI::Request qw(:DEFAULT :cgi-lib); to import them

  &ReadParse(*input);
  &MethGet;
  &PrintHeader;
  &PrintVariables(%input);


URI::URL:

  # Constructors
  $url1 = new URI::URL 'http://www.perl.com/%7Euser/gisle.gif';
  $url2 = new URI::URL 'gisle.gif', 'http://www.com/%7Euser';
  $url3 = $url2->abs; # get absolute url using base
  $url4 = $url2->abs('http:/other/path');

  $url5 = newlocal URI::URL;                # pwd
  $url6 = newlocal URI::URL '/tmp';         # dir
  $url7 = newlocal URI::URL '/etc/motd';    # file

  $url8 = $url1;            # copy references
  $url  = $url8->clone;     # copy objects
 
  # Stringify URL
  $str1 = $url->as_string;  # complete escaped URL string
  $str2 = $url->full_path;  # escaped path+query+params+frag
  $str3 = "$url";           # use operator overloading (experimental)
 
  # Retrieving Generic-RL components:
  $scheme   = $url->scheme;
  $netloc   = $url->netloc;  # see user,password,host,port below
  $path     = $url->path;
  $params   = $url->params;
  $query    = $url->query;
  $frag     = $url->frag;
  
  # Retrieving Network location (netloc) components:
  $user     = $url->user;
  $password = $url->password;
  $host     = $url->host;
  $port     = $url->port;     # returns default if not defined
  
  # Retrieving other attributes:
  $base     = $url->base;
  
  # Setting fields:
  # All methods above can set field values for example:
  $url->scheme('http');
  $url->host('www.w3.org');
  $url->port($url->default_port);
  $url->path('/welcome.html');
  $url->query('protocol info');
  $url->base($url5);  # use string or object
  
  # Specify unsafe characters to be escaped for this url
  $url->unsafe('\x00-\x20"\$#%;<>?\x7E-\xFF');
  
  # General method to get/set field values:
  $value  = $url->elem($name [, $new_value ]);
  
  # Port numbers
  $defport= $url->default_port;  # default port for scheme
  
  # Escaping functions
  $escaped   = uri_escape($component);
  $component = uri_unescape($escaped);
 
  # Other functions
  URI::URL::strict(0);                    # disable strict schemes
  URI::URL::implementor;                  # get generic implementor
  URI::URL::implementor($scheme);         # get scheme implementor
  URI::URL::implementor($scheme, $class); # set scheme implementor
 

Please direct questions initially to this newsgroup and not the mailing
lists.  This is especially true of the CGI-Perl mailing list which is
chartered as being a list for _developers_ of CGI::* modules and is
_not_ intended to provide support for users of those modules. Only
people who are willing and able to contribute to the development of
these modules should join. This charter is sadly necessary to ensure
that the list and its members does not get swamped with support issues.
Please honour the charter or the list may die and further development
of these and other CGI modules will be harmed.


Regards,
Tim Bunce.

p.s. Please don't mail me directly about these modules as I am unlikely
to have the time to answer your mail. Sorry.