min = {}, public_http_path, port, ssl, host, obj, args, ircuri, pass, target, modifiers, query,
secure = (typeof request.client.encrypted === 'object');
- //try {
+ try {
if (kiwi.config.handle_http) {
// Run through any plugins..
args = {request: request, response: response, ssl: secure};
}
}
- //} catch (e) {
- // console.log('ERROR app.httpHandler()');
- // console.log(e);
- //}
+ } catch (e) {
+ console.log('ERROR app.httpHandler()');
+ console.log(e);
+ }
};
exports.onhttp = function (ev, opts) {
var host, port = null, i;
- // TODO: request.socket.pair seems to only be set in a SSL req, is this
- // the best way to check for this?
- if (!opts.ssl) {
+ if (!ev.ssl) {
host = ev.request.headers.host;
// Remove the port if one is set
host = host.substring(0, host.search(/:/));
}
- for (i in kiwi.config.ports) {
- if (kiwi.config.ports[i].secure) {
- port = kiwi.config.ports[i].number;
+ for (i in kiwi.config.servers) {
+ if (kiwi.config.servers[i].secure) {
+ port = kiwi.config.servers[i].port;
break;
}
}
if (port !== 443) {
host += ':' + port.toString();
}
-
- console.log('https://' + host + ev.request.url);
+
ev.response.writeHead(302, {'Location': 'https://' + host + ev.request.url});
ev.response.end();