Code: Select all
#!/usr/bin/perl -w
my @files = (
# add mirrors here
'http://wza.digitalbrains.com/DC/PublicHubList.config',
'http://wza.digitalbrains.com/DC/PublicHubList2.config',
'http://wza.digitalbrains.com/DC/PublicHubList3.config',
# 'http://dcplusplus.sourceforge.net/PublicHubList.config',
);
my $file = $files[ rand @files ];
print "Status: 302 Moved Temporarily\r\n" .
"Location: $file\r\n" .
"\r\n";
what I tried was:
Code: Select all
--- HttpConnection.cpp.orig 2002-12-28 02:31:50.000000000 +0100
+++ HttpConnection.cpp 2003-01-18 23:32:30.000000000 +0100
@@ -56,17 +56,31 @@
socket->write("GET " + file + " HTTP/1.1\r\n");
socket->write("User-Agent: DC++ v" VERSIONSTRING "\r\n");
socket->write("Host: " + server + "\r\n");
+ socket->write("Connection: close\r\n");
socket->write("Cache-Control: no-cache\r\n\r\n");
}
void HttpConnection::onLine(const string& aLine) {
if(!ok) {
- if(aLine.find("200") == string::npos) {
+ if(aLine.find("302") != string::npos) {
+ moved302 = true;
+ } else if(aLine.find("200") == string::npos) {
socket->removeListener(this);
socket->disconnect();
fire(HttpConnectionListener::FAILED, this, aLine);
}
ok = true;
+ } else if(moved302 && aLine.find("Location") != string::npos) {
+ socket->removeListener(this);
+ socket->disconnect();
+ location302 = aLine.substr(10, aLine.length() - 11);
+ // reset all settings (as in constructor)
+ moved302 = false;
+ ok = false;
+ //port = 80;
+ size = -1;
+ //socket = NULL;
+ downloadFile(location302);
} else if(aLine == "\x0d") {
socket->setDataMode(size);
} else if(aLine.find("Content-Length") != string::npos) {
this is obviously wrong..
I can't seem to clear the socket buffer, and the socket.disconnect() fires a FAILURE. and also I don't know if this is the correct way to do this (maybe a MOVED event has to be fired at somone?)
I'm hoping some of you know how to do this correctly :)
/sed