scripts/fahrplan_download: update, still does not work

This commit is contained in:
Astro 2011-09-08 22:16:42 +02:00
parent a4588f2dc8
commit eea19af277
1 changed files with 7 additions and 20 deletions

View File

@ -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);
});
}