*** empty log message ***
authorMatthew Mondor <mmondor@pulsar-zone.net>
Thu, 7 Jul 2005 05:34:14 +0000 (05:34 +0000)
committerMatthew Mondor <mmondor@pulsar-zone.net>
Thu, 7 Jul 2005 05:34:14 +0000 (05:34 +0000)
tests/js-test/js/httpd/httpd.js
tests/js-test/js/httpd/options.js

index a01df38..0349fe2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: httpd.js,v 1.20 2005/07/07 00:59:05 mmondor Exp $ */
+/* $Id: httpd.js,v 1.21 2005/07/07 05:34:14 mmondor Exp $ */
 
 /*
  * Copyright (c) 2005, Matthew Mondor
@@ -83,7 +83,7 @@ eval(file_read('root.js'));           /* Root object for virtual chroot(2) */
  * Server identification
  */
 SERVER_VERSION                 = 'mmondor_js_httpd/0.0.1 (NetBSD)';
-SERVER_CVSID   = '$Id: httpd.js,v 1.20 2005/07/07 00:59:05 mmondor Exp $';
+SERVER_CVSID   = '$Id: httpd.js,v 1.21 2005/07/07 05:34:14 mmondor Exp $';
 
 
 
@@ -130,6 +130,9 @@ function VHost(o)
                throw (x);
        }
 
+       if (o.charset != undefined)
+               this.charset = o.charset;
+
        /*
         * Link object to vhosts table
         */
@@ -233,7 +236,8 @@ HTTPReply.prototype = {
  */
 function http_error(fd, code, desc, ldesc)
 {
-       var res = new HTTPReply(code, desc, 'text/html; charset=iso-8859-1');
+       var res = new HTTPReply(code, desc, 'text/html; charset=' +
+           options.default_charset);
        res.addNoCacheHeaders();
 
        var html = new MLTag('html', true);
@@ -572,7 +576,7 @@ FD.prototype.parseRequest = function()
                                this.http_content_length = words[1].valueOf();
                        else if (words[0] == 'If-Modified-Since:')
                                this.http_modified_since = Math.round(
-                                   Date.parse(lines[i].substr(19)) / 60000);
+                                   Date.parse(lines[i].substr(19)) / 1000);
                }
        }
 
@@ -760,13 +764,14 @@ FD.prototype.httpRespond = function()
         * Then return with close=false, to delegate operations to
         * process_transfer().
         */
-       mimetype = options.default_mimetype;
        if ((i = path.virtual.lastIndexOf('.')) != -1) {
                ext = (path.virtual.substr(i + 1)).toLowerCase();
                if (ext.lastIndexOf('/') == -1 &&
                    mimetypes_table[ext] != undefined)
                        mimetype = mimetypes_table[ext];
        }
+       mimetype += '; charset=' + (this.http_vhost.charset == undefined ?
+           options.default_charset : this.http_vhost.charset);
        res = new HTTPReply(200, 'OK', mimetype);
        res.flush(this, st.st_size);
 
index 6961410..4660a61 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: options.js,v 1.4 2005/07/06 23:52:23 mmondor Exp $ */
+/* $Id: options.js,v 1.5 2005/07/07 05:34:14 mmondor Exp $ */
 
 var options = {
        /* Maximum number of concurrent clients that we should serve */
@@ -12,7 +12,8 @@ var options = {
        /* Default virtual host site to use */
        default_vhost:          "hal.xisop",
        /* Default mimetype to use when none matching file extension */
-       default_mimetype:       "application/octet-stream"
+       default_mimetype:       "application/octet-stream",
+       default_charset:        "us-ascii"
 };
 
 /* Address:port combinations to listen to */
@@ -33,7 +34,8 @@ var vhosts = [
                name:           "hal.xisop",
                aliases:        [ "hal", "localhost" ],
                root:           "/home/mmondor/jswww/welcome",
-               scripts:        true
+               scripts:        true,
+               charset:        'iso-8859-1'
        },
 
        /* Dynamic application virtual host for ascpi.com */
@@ -41,29 +43,28 @@ var vhosts = [
                name:           "ascpi.com",
                aliases:        [ "www.ascpi.com", "ascpi.hal.xisop",
                                    "ascpi.hal" ],
-               root:           "/home/mmondor/jswww/ascpi.com",
-               scripts:        true
+               root:           "/home/mmondor/jswww/ascpi.com"
        },
 
        /* Static only test virtual host */
        {
                name:           "test.hal.xisop",
-               root:           "/home/mmondor/jswww/test/htdocs",
-               scripts:        false
+               root:           "/home/mmondor/jswww/test/htdocs"
        }
 ];
 
 var mimetypes  = {
-       'text/html; charset=iso-8859-1':        [ "html", "htm", "dhtml" ],
-       'text/plain; charset=iso-8859-1':       [ "txt" ],
+       'text/html':                            [ "html", "htm", "dhtml" ],
+       'text/plain':                           [ "txt" ],
        'text/css':                             [ "css" ],
        'application/pdf':                      [ "pdf" ],
        'application/postscript':               [ "ps" ],
-       'applicatoin/x-tar':                    [ "tar" ],
+       'application/x-tar':                    [ "tar" ],
        'application/x-gzip':                   [ "gz" ],
-       'applicatoin/x-bzip2':                  [ "bz2" ],
+       'application/x-bzip2':                  [ "bz2" ],
        'application/zip':                      [ "zip" ],
        'application/x-javascript':             [ "js" ],
+       'application/x-c':                      [ "c", "h", "cpp", "cc" ],
        'application/x-sh':                     [ "sh" ],
        'application/x-shockwave-flash':        [ "swf" ],
        'application/xml':                      [ "xml" ],