afnix-nwg






nwg ‐ standard network working group module

The Standard Network Working Groupmodule is an original
implemtation of the recommendations proposed by the NWG and
currently found in the form of Request for Comments(RFC).
Most of the objects are used with networking application,
with the most common one beeing the Universal Resource
Identifier(URI) object.

     classTheuri
The Uriclass is a base class that parses a Uniform Resource
Identifieror uri string and provides methods to access
individual component of that uri. The implementation
conforms to RFC 3986. The URI components are the scheme, the
authority, the path, the query and the fragment. The class
also takes care of the character escaping.

const uri (afnix:www:Uri "http://www.afnix.org")

An uri can be broken into several components called the
scheme, the authority, the path, optionally the queryand the
fragment. The Uriclass provide a method to retrieve each
component of the parsed uri.

const uri (afnix:www:Uri "http://www.afnix.org/")
println (uri:get‐scheme)    # http
println (uri:get‐authority) # www.afnix.org
println (uri:get‐path)      # /


     Characterconversion
The Uriclass performs automatically the character conversion
in the input uri. For example, the +character is replaced by
a blank. The %character followed by two hexadecimal values
is replaced by the corresponding ASCII character. Note that
this conversion does now apply to the query string.

     Querystring
The get‐querymethod returns the query string of the uri. The
query string starts after the ?character. The query string
is a series of key‐pair values separated by the &character.

const uri (afnix:www:Uri
  "http://www.afnix.org?name=hello&value=world")
println (uri:get‐query) # name=hello&value=world

The module also provides the UriQueryclass that parses the
query string and store the result in the form of a property
list. The query string parse is particularly useful when
writing automated scripts.

# create a query string object
const qs (afnix:nwg:UriQuery (uri:get‐query))
# get the name value









                             ‐2‐


qs:get‐value "name"


     cgiManaginga
Managing a cgi request involves primarily the parsing of the
requesting uri. The uri generally contains the http referrer
as well as parameter which are stored in the form of a query
string. However, depending on the cgi method which can be of
type GETor POST, the treatment is somewhat different.

     protocolCheckingthe
In the presence of a cgi protocol, it is always a good idea
to check the protocol version, or at least to put an
assertion. The protocol version is normally CGI/1.1and is
stored in the GATEWAY_INTERFACEenvironment variable.

# check the cgi protocol
assert "CGI/1.1" (
  afnix:sys:get‐env "GATEWAY_INTERFACE")


     queryGettingthe
If the request method is GET, then the query string is
available in the environment variable QUERY_STRING. If the
request method is POST, the query string is available in the
input stream. The length of the query string is given by the
CONTENT_LENGTHenvironment variable. The following example
illustrates the extraction of the query string.

# check the cgi protocol
assert "CGI/.1" (
  afnix:sys:get‐env "GATEWAY_INTERFACE")
# initialize the query string
const query (afnix:sys:get‐env "QUERY_STRING")
# get the request method
const rqm (afnix:sys:get‐env "REQUEST_METHOD")
# check for a post request and update the query string
if (== rqm "POST") {
  # create a buffer from the content length
  const len (
    Integer (afnix:sys:get‐env "CONTENT_LENGTH"))
  # get the standard input stream and read content
  const is  (interp:get‐input‐stream)
  const buf (is:read len)
  # set the query string
  query:= (buf:to‐string)
}


     queryParsingthe
The UriQueryclass is designed to parse a cgi query string.
Once the string has been parsed, it is possible to perform a
query by key since the class operates with a property list.










                             ‐3‐


const query (
  afnix:www:UriQuery "name=hello&value=world")
query:length      # 2
query:get‐value "name"  # hello
query:get‐value "value" # world

The UriQueryclass is the foundation to build cgi script.
When the library is combined with the web application
management (wam)service, powerful applications can be built
easily.

     Specialfunctions
Several dedicated functions are available in the library as
a way to ease the object manipulations. Theses functions
operate mostly on uri and files as described below.

     Urifunctions
Several functions are designed to ease the uri manipulation.
Most of them operate on the uri name or their associated
system name. The normalize‐uri‐namefunction normalizes a
string argument by adding a uri scheme if missing in the
original string. If the function detects that the name
starts with a host name, the httpscheme is added. If the
function detects that the string starts with a path, the
filescheme is added. otherwise, the name argument is left
untouched. The system‐uri‐namefunction normalizes the string
argument by prioritizing the system name. The function
attempts to find a file that match the sring argument and
eventually build a uri file scheme. If the file is not fond,
the normalization process occurs with the normalize‐uri‐
namefunction.

# normalize a uri name
trans  unm "http://www.afnix.org"
assert unm (
  afnix:nwg:normalize‐uri‐name unm)
assert unm (
  afnix:nwg:normalize‐uri‐name "www.afnix.org")
assert unm (
  afnix:nwg:normalize‐uri‐name "//www.afnix.org")


     Mimefunctions
Mime functions are dedicated to easee the mainpulation of
media types or mime. A media type is defined by a string in
the form of a type and content value such as text/plain. The
mime‐value‐ppredicate returns true if a string mime value is
a valid media type. From a file perspective, the mime‐
extension‐ppredicate returns true if the string extension
has a valid media type associated to it. Finally, the
extension‐to‐mimefunction can be used to get the string mime
value associated with a file extension.

# check a media type









                             ‐4‐


assert true (afnix:nwg:mime‐value‐p "text/plain")
# check the mime extension predicate
assert true (afnix:nwg:mime‐extension‐p "txt")
# check the extension to mime
assert "text/plain" (
  afnix:nwg:extension‐to‐mime "txt")


     objectsHTTPtransaction
The concept of HTTP transactions is defined in RFC 2616. In
the client/server approach, a client issues a request which
is answered with a response. A special case arise when the
server is asked to perform some extra works, such like
executing a script. In this case, the answer is called a
reply which is formatted into a response when the server
does its job correctly.  The nature of the HTTP objects
determines how the associated stream behaves. With a HTTP
request, the object is filled by reading an input stream
when operating on the server side. On the other hand, the
request is filled by data when operating on the client side.
With a HTTP response, the opposite situation occurs. The
HTTP response is filled by reading an input stream when
operating on the client side and filled by data when
operating on the server side.

     HTTPprotocol
The HttpProtoclass is a base class designed to handle a HTTP
header that is found in both HTTP request and response. The
class is built around a property list that is filled either
by parsing an input stream or by processing specific
methods. The HttpProtodefines also some methods which are
often used with a HTTP request or response.

     HTTPresponse
The HttpResponseclass is a class designed to handle a HTTP
response. When operating on the client side, the response
object is built by reading an input stream. When operating
on the server side, the response object is built by calling
specific methods.

     serverCreatinga
A server response is created by specifying the response
status code. By default, a HTTP response is created with the
default media type text/html. If the media type needs to be
changed, it can be passed as the second argument to the
response constructor. By default, the empty constructor
creates an empty constructor with a valid status code.

#create a valid response
const hr (afnix:nwg:HttpResponse 200)

Once the server response is created, it can be augmented
with some headed values. Typically, a server will add some
information about the response, such like the content









                             ‐5‐


length, the modification time or a tag. The
HttpResponseprovides several methods that ease the
generation of these header values.

     clientCreatinga
A client response is created by binding an input stream to a
response object. During the construction, the input stream
is read and the HTTP protocol header is filled. It is also
during this phase that the status code is processed. It is
therefore important to ensure that a response object is
built correctly before attempting to access it.

# create a client response by stream
const hr (afnix:nwg:HttpResponse is)


     clientReadinga
When the response has been created, it is important to check
its status code. Most of the time, the response is valid and
its content can be read directly. The status‐ok‐ppredicate
returns true if the status code is valid. In such case, a
HTTP stream can be built in order to read the response.

# check that a response is valid
if (hr:status‐ok‐p) {
  # create a http stream
  const rs (afnix:nwg:HttpStream ht is)
  # read the response stream
  while (rs:eos‐p) (rs:read)
}

Before reading a http stream, it is important to detect and
verify the nature of the response content. The media‐type‐
ppredicate returns true if the media type is defined and the
get‐media‐typemethod returns the response type in the form
of a mime code such like text/html. Eventually, the
character set associated with the media type can also be
detected. The encoding‐mode‐ppredicate and the get‐encoding‐
modemethod can be used to detect the content encoding mode.
However, it is worth to note that the HttpStreamobject is
automatically sets with the proper encoding if it can be
found in the response header.

     responseSpecialclient
Certain response can sometime contains special status codes
that require a specific treatment. This is the case when the
response corresponds to a http redirection. In this case,
the new uri must be fetched to get the desired response. The
location‐ppredicate returns true if the response corresponds
to a http redirect and the get‐locationmethod can be used to
get the new location uri. If this situation arises, it is up
to the implementation to decide what to do with the new uri.
In most cases, a new request will be sent to the server.










                             ‐6‐


     Cookieobject
The Cookieobject is a special object that can be used during
a http session, to post data to the http client. The idea
behind cookiesis to be able to maintain some state, during
the user session for some time. A cookie is a name/valuepair
and eventually an expiration time. By default, the cookie
object are defined for one http client session, but this
behavior can be changed.

     Managingcookies
A cookie is created with a name/valuepair and eventually an
expiration time. Such expiration time is called the maximum‐
ageand is automatically formatted by the object. With two
arguments a session cookie is created. With a third argument
as an integer, the constructor set the maximum age in
seconds.

# create a cookie with name/value
const cookie (afnix:nwg:Cookie "cartid" "123456789")

The cookie implementation follows the recommendation of the
RFC‐2965 for http state management. The most important point
to remember is the interpretation of the maximum age that
differs from one cookie version to another. With version 1,
which is the default, the maximum age is defined relatively
in seconds, while it is absolute with version 0.The maximum
age is set either at construction or with the set‐max‐
agemethod. The set‐max‐agemethod sets the cookie life time
in seconds, in reference to the current time. A negative
value is always reset to ‐1 and defined a session cookie. A
0 value tells the http client to remove the cookie. The set‐
pathmethod defines the path for which this cookie apply.

     cookieAddinga
Once the cookie is defined, the set‐cookiemethod of the
HttpResponseobject can be used to install the cookie.
Combined with the writemethod, the cookie can be send to the
http client.



     Uri
The Uriclass is a base object used to parse or build a
uniform resource identifier as defined by RFC 3986. The URI
can be built by specifying each component or by parsing a
string. When a string is given in the constructor, the class
parses the string and extract all components. The uri
components are the scheme, the authority, the path, the
query and the fragment. The class also takes care of the
character escaping.

     Predicate

     uri‐p









                             ‐7‐


     Inheritance

     Object

     Constructors

     Uri(none)
     The Uriconstructor creates an empty uri object.

     Uri(String)
     The Uriconstructor create a uri object by value. The
     string argument is the uri to parse at the object
     construction.

     StringUri(String
     The Uriconstructor create a uri object by scheme host
     and port. The first argument is the uri scheme. The
     second argument is the uri host name. The third
     argument is the uri port. The uri base name can be
     reconstructed from this information.

     Methods

     noneparse‐>
     The parsemethod reset the uri object, parse the string
     argument and fill the uri object with the result.

     Stringget‐scheme‐>
     The get‐schememethod returns the scheme of the parsed
     uri object.

     Stringget‐authority‐>
     The get‐authoritymethod returns the authority part of
     the parsed uri.

     Stringget‐path‐>
     The get‐pathmethod returns the path of the parsed uri.

     Stringget‐path‐target‐>
     The get‐path‐targetmethod returns the path target of
     the parsed uri. The path target is the last element of
     the uri path.

     Stringget‐query‐>
     The get‐querymethod returns the complete query string
     of the parsed uri. Note that characters are not escaped
     when getting the string.

     Stringget‐fragment‐>
     The get‐fragmentmethod returns the complete query
     string of the parsed uri.

     Stringget‐base‐>
     The get‐basemethod returns the combined uri scheme and









                             ‐8‐


     authority.

     Stringget‐rname‐>
     The get‐rnamemethod returns the reference uri name with
     the combined uri scheme, authority and path all percent
     encoded.

     Stringget‐hname‐>
     The get‐hnamemethod returns the combined uri scheme,
     authority and path.

     Stringget‐aname‐>
     The get‐anamemethod returns the almost combined uri
     name with the scheme, authority, path and query.

     Uriadd‐path‐>
     The add‐pathmethod adds a path to the calling uri and
     returns a new uri with the new path added to the old
     one.

     Uriget‐href‐>
     The get‐hrefmethod returns a new uri by eventually
     combining the string argument. If the string argument
     correspond to an uri, the corresponding uri is built.
     Otherwise, the string argument is considered as a path
     to be added to the current uri in order to build a new
     uri.

     Stringget‐system‐path‐>
     The get‐system‐pathmethod returns the system path
     representation of the uri path. This function works
     only if the scheme if a file scheme.

     Stringget‐path‐encoded‐>
     The get‐path‐encodedmethod returns the uri in the
     encoded form. Normally the get‐pathremoves the percent‐
     encoded characters which might not be appropriate with
     some protocol such like the http protocol. The get‐
     path‐encodedreturns the original path. Note that
     getting the path with getpathand doing a percent coding
     might result in a different result since the internal
     representation uses normalized string.

     Stringget‐host‐>
     The get‐hostmethod returns the authority or path host
     name if any can be found with respect to the scheme.
     With a ftp, http or https scheme, the host is extracted
     from the authority. With a mailto scheme, the host is
     extracted from the path.

     Integerget‐port‐>
     The get‐portmethod returns the authority port if any
     can be found with respect to the scheme.










                             ‐9‐


     UriQuery
The UriQueryclass is a simple class that parses a uri query
string and build property list. during the parsing process,
a special transliteration process is done as specified by
RFC 3986. This class is primarily used with cgiscripts. Note
that the string to parse is exactly the one produced by the
get‐querymethod of the Uriclass.

     Predicate

     uri‐query‐p

     Inheritance

     Plist

     Constructors

     UriQuery(none)
     The UriQueryconstructor creates an empty uri query
     object.

     UriQuery(String)
     The UriQueryconstructor create a uri object by value.
     The string argument is the uri query string to parse at
     the object construction. The query string is the one
     obtained from the get‐querymethod of the Uriclass.

     Methods

     noneparse‐>
     The parsemethod reset the uri query object, parses the
     string argument and fill the property list object with
     the result.

     Stringget‐query‐>
     The get‐querymethod returns the original query string.

     UriPath
The UriPathclass is a class designed for the management of
file system path associated with a uri. Typically, this
class will be used with a http server or client when an
association between a uri and a file name needs to be made.
The general operation principle is to associate a path with
a uri authority. The uri path is then concatanated to
produce a new path. If the uri path is empty, it can be
eventually replaced by a file name, known as the diretory
index in the http terminology.

     Predicate

     uri‐path‐p











                            ‐10‐


     Inheritance

     Object

     Constructors

     UriPath(none)
     The UriPathconstructor creates an empty uri path
     object.

     UriPath(String)
     The UriPathconstructor create a uri object by root
     path. The string argument is the uri root path.

     String)UriPath(String
     The UriPathconstructor create a uri object by root and
     index. The first string argument is the uri root path
     and the second string argument is the directory index
     path.

     StringUriPath(String
     The UriPathconstructor create a uri object by root,
     index and authority. The first string argument is the
     uri root path, the second string argument is the
     directory index path and the third argument is the
     authority.

     Methods

     Stringget‐root‐>
     The get‐rootmethod returns the root path.

     Stringget‐index‐>
     The get‐indexmethod returns the index path.

     Stringget‐authority‐>
     The get‐authoritymethod returns the uri authority.

     Stringmap‐request‐uri‐>
     The map‐request‐urimap a request uri into a system
     path. The string argument is the request uri. The
     request uri must be an absolute path. The result string
     is the system path build with the root path.

     Stringnormalize‐>
     The normalizemethod build a system from a request path.
     The request path is associated with the root path and
     then normalized to produce a complete system path.

     HttpProto
The HttpProtoclass is a base class that ease the deployment
of the http protocol. The base class is built with a
property list which is used to define the message header.
The class also defines the write methods which are used to









                            ‐11‐


write a message either on an output stream or into a buffer.

     Predicate

     http‐proto‐p

     Inheritance

     Object

     Methods

     nonereset‐>
     The resetmethod resets the http protocol object by
     clearing the protocol version and header.

     noneparse‐>
     The parsemethod parse the input stream bound to the
     http protocol. In order to operate, an input stream
     must be associated with the protocol object or an
     exception is raised. After a stream has been parsed,
     the protocol version and the header are set.

     nonewrite‐>
     The writemethod formats and writes the http protocol
     object to an output stream or a buffer. Without
     argument, the default output stream is used. With an
     argument, an output stream or a buffer object can be
     used.

     Integerheader‐length‐>
     The header‐lengthmethod returns the number of
     properties in the header.

     Booleanheader‐exists‐p‐>
     The header‐exists‐ppredicate returns true if the
     property exists in the header. The string argument is
     the property name.

     noneheader‐set‐>
     The header‐setmethod sets a new property to the http
     header. The first argument is the property name. The
     second argument is a literal object which is internally
     converted to a string.

     Propertyheader‐get‐>
     The header‐getmethod returns a property object by
     index.

     Stringheader‐map‐>
     The header‐mapmethod returns a property value by name.
     The string argument is the property name.

     Propertyheader‐find‐>









                            ‐12‐


     The header‐findmethod returns a property object by
     name. The string argument is the property name. If the
     property is not found, the nil object is returned.

     Propertyheader‐lookup‐>
     The header‐lookupmethod returns a property object by
     name. The string argument is the property name. If the
     property is not found, an exception is raised.

     Plistheader‐plist‐>
     The header‐plistmethod returns the header in the form
     of a property list.

     Booleancontent‐length‐p‐>
     The content‐length‐ppredicate returns true if the
     content length is defined in the protocol header.

     Integerget‐content‐length‐>
     The get‐content‐lengthmethod returns the content length
     defined in the protocol header. If the content length
     is not defined in the header, the null value is
     returned.

     Booleanmedia‐type‐p‐>
     The media‐type‐ppredicate returns true if the content
     type is defined in the protocol header.

     Stringget‐media‐type‐>
     The get‐media‐typemethod returns the media type defined
     in the protocol header. If the media type is not
     defined in the header, the default media type is
     returned.

     Booleanencoding‐mode‐p‐>
     The encoding‐mode‐ppredicate returns true if the
     encoding mode is defined in the protocol header.

     Stringget‐encoding‐mode‐>
     The get‐encoding‐modemethod returns the protocol
     encoding mode. If the encoding mode is not defined in
     the protocol header, the default encoding mode is
     returned.

     HttpRequest
The HttpRequestclass is a base class designed to handle a
http request. The class operates with the protocol version
1.1 as defined by RFC 2616. For a server request, the
request is built by reading an input stream and setting the
request command with its associated header. For a client
request, the request is formatted with a request command and
a eventually a uri. In both cases, the header is filled
automatically depending on the request side.











                            ‐13‐


     Predicate

     http‐request‐p

     Inheritance

     HttpProto

     Constructors

     HttpRequest(none)
     The HttpRequestconstructor creates a default http
     request. By default, the request object is built with
     the GETmethod and the request uri set to the root
     value.

     HttpRequest(String)
     The HttpRequestconstructor creates a http request
     object with a specific command. By default, the request
     uri is set to root, except for the OPTIONSmethod

     HttpRequest(Uri)
     The HttpRequestconstructor creates a http request
     object with a uri. The default request method is GET.

     HttpRequest(InputStream)
     The HttpRequestconstructor creates a http request
     object with a specific input stream. At construction,
     the request header is cleared and the input stream is
     bound to the object.

     String)HttpRequest(String
     The HttpRequestconstructor creates a http request
     object with a specific method and a uri name. The first
     string argument is the request method to use. The
     second string argument is the uri attached to the
     command. Note that the term urishould be understood as
     a request uri.

     Uri)HttpRequest(String
     The HttpRequestconstructor creates a http request
     object with a specific method and a uri. The first
     string argument is the request method to use. The
     second argument is the uri attached to the method.

     Methods

     noneset‐method‐>
     The set‐methodmethod sets the request method. This
     method does not check that the command is a valid HTTP
     method and thus leaves plenty of room for server
     development. As a matter of fact, RFC 2616 does not
     prohibit the existence of such extension.










                            ‐14‐


     Stringget‐method‐>
     The get‐methodmethod returns the request method string.

     noneset‐uri‐>
     The set‐urimethod sets the request uri. The argument
     string does not have to be a valid uri string since
     some commands might accept special string such like "*"
     to indicate all applicable uri.

     Stringget‐uri‐>
     The get‐urimethod returns the request uri string.

     HttpResponse
The HttpResponseclass is a base class designed to handle a
http response. The class operates with the protocol version
1.1 as defined by RFC 2616. For a client response, the
response is built by reading an input stream and setting the
response status code with its associated header. For a
server response, the response is formatted with a response
status and additional header information. In both cases, the
header is filled automatically depending on the response
side. On the other hand, trying to set some header with an
input stream bound to the response object might render the
response object unusable.

     Predicate

     http‐response‐p

     Inheritance

     HttpProto

     Constructors

     HttpResponse(none)
     The HttpResponseconstructor creates a default http
     response object. The response is marked valid with a
     default text/plainmedia type.

     HttpResponse(Integer)
     The HttpResponseconstructor creates a http response
     object with a status code. The response code is
     associated with the default text/plainmedia type.

     HttpResponse(InputStream)
     The HttpResponseconstructor creates a http response
     object with a specific input stream. At construction,
     the response header is cleared and the input stream is
     bound to the object.

     String)HttpResponse(Integer
     The HttpResponseconstructor creates a http response
     object with a status code and a media type. The first









                            ‐15‐


     argument is the status code. The second argument is the
     associated media type.

     Methods

     noneset‐status‐code‐>
     The set‐status‐codemethod sets the response status
     code.

     Integerget‐status‐code‐>
     The get‐status‐codemethod returns the response status
     code.

     Stringmap‐status‐code‐>
     The map‐status‐codemethod returns a string
     representation of the response status code.

     Booleanstatus‐ok‐p‐>
     The status‐ok‐ppredicate returns true if the response
     status code is valid (aka status 200).

     Booleanstatus‐error‐p‐>
     The status‐error‐ppredicate returns true if the
     response status code is an error code.

     Booleanlocation‐p‐>
     The location‐ppredicate returns true is the response
     status code indicates that a request should be made at
     another location. The location can be found with the
     get‐locationmethod.

     Stringget‐location‐>
     The get‐locationmethod returns the location uri found
     in the response header. This method is equivalent to a
     header query.

     noneset‐location‐>
     The set‐locationmethod set the redirect location in the
     response header. The string argument is the location
     uri.

     noneset‐cookie‐>
     The set‐cookiemethod sets a cookie object to the http
     header. The cookie version is properly handled by the
     method.

     Cookie
The Cookieclass is a special class designed to handle cookie
setting within a http transaction. A cookie is
name/valuepair that is set by the server and stored by the
http client. Further connection with the client will result
with the cookie value transmitted by the client to the
server. A cookie has various parameters that controls its
existence and behavior. The most important one is the cookie









                            ‐16‐


maximum agethat is defined in seconds. A null value tells
the client to discard the cookie. A cookie without maximum
age is valid only during the http client session. A cookie
can be added to the HttpReplyobject with the set‐
cookiemethod. A cookie can be constructed with a
name/valuepair. An optional third argument is the maximum
age. The default cookie version is 1 as specified by RFC
2965. With a version 1, the maximum age is interpreted as
the number of seconds before the cookie expires. With
version 0, the maximum age is the absolute time.

     Predicate

     cookie‐p

     Inheritance

     Object

     Constructors

     String)Cookie(String
     The Cookieconstructor creates a cookie with a name
     value pair. The first argument is the cookie name. The
     second argument is the cookie value.

     StringCookie(String
     The Cookieconstructor creates a cookie with a name
     value pair and a maximum age. The first argument is the
     cookie name. The second argument is the cookie value.
     The third argument is the cookie maximum age.

     Methods

     Integerget‐version‐>
     The get‐versionmethod returns the cookie version.

     noneset‐version‐>
     The set‐versionmethod sets the cookie version. The
     version number can only be 0 or 1.

     Stringget‐name‐>
     The get‐namemethod returns the cookie name. This is the
     name store on the http client.

     noneset‐name‐>
     The set‐namemethod sets the cookie name. This is the
     name store on the http client.

     Stringget‐value‐>
     The get‐valuemethod returns the cookie value. This is
     the value stored on the http client bounded by the
     cookie name.










                            ‐17‐


     noneset‐value‐>
     The set‐valuemethod sets the cookie value. This is the
     value store on the http client bounded by the cookie
     name.

     Integerget‐maximum‐age‐>
     The get‐maximum‐agemethod returns the cookie maximum
     age. The default value is ‐1, that is, no maximum age
     is set and the cookie is valid only for the http client
     session.

     noneset‐maximum‐age‐>
     The set‐maximum‐agemethod sets the cookie maximum age.
     A negative value is reset to ‐1. A 0 value tells the
     http client to discard the cookie. A positive value
     tells the http client to store the cookie for the
     remaining seconds.

     Stringget‐path‐>
     The get‐pathmethod returns the cookie path value. The
     path determines for which http request the cookie is
     valid.

     noneset‐path‐>
     The set‐pathmethod sets the cookie path value. The path
     determines for which http request the cookie is valid.

     Stringget‐domain‐>
     The get‐domainmethod returns the cookie domain value.

     noneset‐domain‐>
     The set‐domainmethod sets the cookie domain value. It
     is string recommended to use the originator domain name
     since many http client can reject cookie those domain
     name does not match the originator name.

     Integerget‐port‐>
     The get‐portmethod returns the cookie port number.

     noneset‐port‐>
     The set‐portmethod sets the cookie port number. This
     value is not used with a cookie version 0.

     Stringget‐comment‐>
     The get‐commentmethod returns the cookie comment value.

     noneset‐comment‐>
     The set‐commentmethod sets the cookie comment value.

     Stringget‐comment‐url‐>
     The get‐comment‐urlmethod returns the cookie comment
     url value.

     noneset‐comment‐url‐>









                            ‐18‐


     The set‐comment‐urlmethod sets the cookie comment url
     value. This value is not used with cookie version 0.

     Booleanget‐discard‐>
     The get‐discardmethod returns the cookie discard flag.

     noneset‐discard‐>
     The set‐discardmethod sets the cookie discard flag. The
     discard flag the tells the user agent to destroy the
     cookie when it terminates. This value is not used with
     cookie version 0.

     Booleanget‐secure‐>
     The get‐securemethod returns the cookie secure flag.

     noneset‐secure‐>
     The set‐securemethod sets the cookie secure flag. When
     a cookie is secured, it is only returned by the http
     client if a connection has been secured (i.e use
     https).

     Stringto‐string‐>
     The to‐stringmethod returns a string formatted for the
     http reply header. Normally this method should not be
     called since the set‐cookiemethod of the httpReplytakes
     care of such thing.

     Functions

     Booleanmime‐extension‐p‐>
     The mime‐extension‐ppredicates returns true if a media
     type extension ‐ mime extension ‐ is defined. Most of
     the time, media type extension can be seen as a file
     extension.

     Booleanmime‐value‐p‐>
     The mime‐value‐ppredicates returns true if a media type
     ‐ mime value ‐ is defined.

     Stringextension‐to‐mime‐>
     The extension‐to‐mimefunction converts a media type
     extension into a media type. In the first form, without
     a second argument, if the media type extension does not
     exist, an exception is raised. In the second form, with
     the second argument set to true, if the media type
     extension does not exist, the default media type is
     returned. If the flag is set to false, an exception is
     raised like the first form.

     Stringnormalize‐uri‐name‐>
     The normalize‐uri‐namefunction normalizes the string
     argument by adding a uri scheme if missing in the
     original string. If the function detects that the name
     starts with a host name, the "http" scheme is added. If









                            ‐19‐


     the function detects that the string starts with a
     path, the "file" scheme is added. otherwise, the name
     argument is left untouched.

     Stringsystem‐uri‐name‐>
     The system‐uri‐namefunction normalizes the string
     argument by prioritizing the system name. The function
     attempts to find a file that match the string argument
     and eventually build a uri file scheme. If the file is
     not fond, the normalization process occurs with the
     normalize‐uri‐namefunction.

     Stringpath‐uri‐name‐>
     The path‐uri‐namefunction normalizes the string
     argument by extracting a path associated with the uri
     string. If the string is a valid uri string, the path
     is the uri path component. If the uri path is empty, it
     is normalized to a /. If the string argument is not a
     uri string, the string is assumed to be a partial uri
     and both query and fragment parts are removed if
     present.