diff --git a/scripts/fahrplan_download.js b/scripts/fahrplan_download.js index dce899354..973f4b649 100755 --- a/scripts/fahrplan_download.js +++ b/scripts/fahrplan_download.js @@ -1,7 +1,7 @@ #!/usr/bin/env node var URL = require('url'); -var HTTP = require('http'); +var HTTPS = require('http'); var FS = require('fs'); var EXPAT = require('node-expat'); var El = require('node-xmpp').Element; @@ -17,31 +17,18 @@ var conference_id = process.argv[4]; var outputDir = '.'; var baseDir = '/fahrplan'; -var clients = []; -for(var i = 0; i < 4; i++) - clients.push(HTTP.createClient(443, 'cccv.pentabarf.org', true)); - function get(path, cb) { - var client = clients[Math.floor(Math.random() * clients.length)]; - console.log("GET " + path); - var req = client.request('GET', path, - { 'Host': 'cccv.pentabarf.org', - 'Authorization': 'Basic ' + base64(user + ':' + pass) }); - req.end(); - - req.on('response', function(res) { + HTTPS.get({ host: 'cccv.pentabarf.org', + path: path, + headers: { + 'Authorization': 'Basic ' + base64(user + ':' + pass) + } }, function(res) { if (res.statusCode === 200) cb(res); else console.warn(res.statusCode + ': ' + path); - }); - req.on('error', function(e) { - console.error(e.message); - // Retry: - process.nextTick(function() { - get(path, cb); - }); + console.log(res.headers); }); }