Use the request modules and not the https module.

This commit is contained in:
Tim Schumacher 2013-08-11 17:14:43 +02:00
parent 1d13ea4462
commit f4c7c5b82a

View file

@ -12,7 +12,7 @@ var
,util = require('util') ,util = require('util')
,dgram = require('dgram') ,dgram = require('dgram')
,config = require('./config') ,config = require('./config')
,http = require('https') ,request = require('request')
,jsdom = require('jsdom') ,jsdom = require('jsdom')
,nodemailer = require("nodemailer") ,nodemailer = require("nodemailer")
,log = require('sys').log ,log = require('sys').log
@ -68,7 +68,6 @@ EventTool.prototype.publishMail = function() {
var view = self.processEventData(); var view = self.processEventData();
// load the template // load the template
var template = fs.readFileSync('templates/email/template.mustache','utf-8'); var template = fs.readFileSync('templates/email/template.mustache','utf-8');
console.log(view);
var output = mustache.render(template, view); var output = mustache.render(template, view);
var transport = null; var transport = null;
if (self.config.mail.mda == 'smtp') { if (self.config.mail.mda == 'smtp') {
@ -147,8 +146,8 @@ EventTool.prototype.processEvents = function() {
}); });
} }
EventTool.prototype.parseData = function() { EventTool.prototype.parseData = function(et) {
var self = this.req.EventTool; var self = et;
jsdom.env( jsdom.env(
self.RequestData, self.RequestData,
function (errors, window) { function (errors, window) {
@ -176,20 +175,17 @@ EventTool.prototype.parseData = function() {
); );
} }
EventTool.prototype.processResponse = function(res) { EventTool.prototype.processResponse = function(error, response, body) {
var self = this.EventTool; var self = this.EventTool;
if (res.statusCode == 200) { if (response.statusCode == 200) {
res.on('data', function(d) { self.RequestData = body;
self.RequestData = self.RequestData + d; self.parseData(self);
});
res.on('end',self.parseData);
} }
} }
EventTool.prototype.run = function() { EventTool.prototype.run = function() {
log('Suche nach Terminen'); log('Suche nach Terminen');
var req = http.request(this.config.url,this.processResponse); var req = request({'url':this.config.url,'strictSSL': false},this.processResponse);
req.EventTool = this; req.EventTool = this;
req.end(); req.end();