-/* $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
* 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 $';
throw (x);
}
+ if (o.charset != undefined)
+ this.charset = o.charset;
+
/*
* Link object to vhosts table
*/
*/
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);
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);
}
}
* 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);
-/* $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 */
/* 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 */
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 */
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" ],