mirror of https://github.com/aria2/aria2
2006-07-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add the support for Metalink3.0 backward compatible links: * src/Request.h (SAFE_CHARS): Added '#'. (METALINK_MARK): New definition. * src/Request.cc (parseUrl): Added the support for Metalink3.0 backward compatible links. etc * src/PeerInteraction.cc (MsgPushBack): Removed. (sendMessages): Use STL copy and back_inserter. (rejectAllPieceMessageInQueue): Use STL copy and back_inserter. (rejectPieceMessageInQueue): Use STL copy and back_inserter. * src/TorrentMan.h (MAX_PEER_LIST_SIZE): Changed to 100 from 250.pull/1/head
parent
524d664850
commit
7db2b0596d
21
ChangeLog
21
ChangeLog
|
@ -1,3 +1,24 @@
|
|||
2006-07-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
To add the support for Metalink3.0 backward compatible links:
|
||||
|
||||
* src/Request.h
|
||||
(SAFE_CHARS): Added '#'.
|
||||
(METALINK_MARK): New definition.
|
||||
* src/Request.cc
|
||||
(parseUrl): Added the support for Metalink3.0 backward compatible
|
||||
links.
|
||||
|
||||
etc
|
||||
|
||||
* src/PeerInteraction.cc
|
||||
(MsgPushBack): Removed.
|
||||
(sendMessages): Use STL copy and back_inserter.
|
||||
(rejectAllPieceMessageInQueue): Use STL copy and back_inserter.
|
||||
(rejectPieceMessageInQueue): Use STL copy and back_inserter.
|
||||
* src/TorrentMan.h
|
||||
(MAX_PEER_LIST_SIZE): Changed to 100 from 250.
|
||||
|
||||
2006-07-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
* src/SharedHandle.h: New class.
|
||||
|
|
3
TODO
3
TODO
|
@ -11,4 +11,5 @@
|
|||
* Refacturing HttpConnection and FtpConnection
|
||||
* Query resource by location
|
||||
* Log version
|
||||
* List available os, version, etc for metalink
|
||||
* List available os, version, etc for metalink
|
||||
* Performance Profiling
|
|
@ -45,17 +45,6 @@ PeerInteraction::~PeerInteraction() {
|
|||
delete peerConnection;
|
||||
}
|
||||
|
||||
class MsgPushBack {
|
||||
private:
|
||||
MessageQueue* messageQueue;
|
||||
public:
|
||||
MsgPushBack(MessageQueue* messageQueue):messageQueue(messageQueue) {}
|
||||
|
||||
void operator()(const PeerMessageHandle& msg) {
|
||||
messageQueue->push_back(msg);
|
||||
}
|
||||
};
|
||||
|
||||
bool PeerInteraction::isSendingMessageInProgress() const {
|
||||
if(messageQueue.size() > 0) {
|
||||
const PeerMessageHandle& peerMessage = messageQueue.front();
|
||||
|
@ -84,7 +73,7 @@ void PeerInteraction::sendMessages(int uploadSpeed) {
|
|||
}
|
||||
}
|
||||
}
|
||||
for_each(tempQueue.begin(), tempQueue.end(), MsgPushBack(&messageQueue));
|
||||
copy(tempQueue.begin(), tempQueue.end(), back_inserter(messageQueue));
|
||||
}
|
||||
|
||||
void PeerInteraction::addMessage(const PeerMessageHandle& peerMessage) {
|
||||
|
@ -123,7 +112,7 @@ void PeerInteraction::rejectAllPieceMessageInQueue() {
|
|||
itr++;
|
||||
}
|
||||
}
|
||||
for_each(tempQueue.begin(), tempQueue.end(), MsgPushBack(&messageQueue));
|
||||
copy(tempQueue.begin(), tempQueue.end(), back_inserter(messageQueue));
|
||||
}
|
||||
|
||||
void PeerInteraction::rejectPieceMessageInQueue(int index, int begin, int length) {
|
||||
|
@ -149,7 +138,7 @@ void PeerInteraction::rejectPieceMessageInQueue(int index, int begin, int length
|
|||
itr++;
|
||||
}
|
||||
}
|
||||
for_each(tempQueue.begin(), tempQueue.end(), MsgPushBack(&messageQueue));
|
||||
copy(tempQueue.begin(), tempQueue.end(), back_inserter(messageQueue));
|
||||
}
|
||||
|
||||
void PeerInteraction::onChoked() {
|
||||
|
|
|
@ -56,14 +56,25 @@ bool Request::redirectUrl(const string& url) {
|
|||
}
|
||||
|
||||
bool Request::parseUrl(const string& url) {
|
||||
currentUrl = url;
|
||||
string tempUrl = url;
|
||||
string tempUrl;
|
||||
string::size_type sharpIndex = url.find("#");
|
||||
if(sharpIndex != string::npos) {
|
||||
if(url.find(METALINK_MARK) == sharpIndex) {
|
||||
tempUrl = url.substr(sharpIndex+strlen(METALINK_MARK));
|
||||
} else {
|
||||
tempUrl = url.substr(0, sharpIndex);
|
||||
}
|
||||
} else {
|
||||
tempUrl = url;
|
||||
}
|
||||
|
||||
currentUrl = tempUrl;
|
||||
string query;
|
||||
host = "";
|
||||
port = 0;
|
||||
dir = "";
|
||||
file = "";
|
||||
if(url.find_first_not_of(SAFE_CHARS) != string::npos) {
|
||||
if(tempUrl.find_first_not_of(SAFE_CHARS) != string::npos) {
|
||||
return false;
|
||||
}
|
||||
string::size_type startQueryIndex = tempUrl.find("?");
|
||||
|
|
|
@ -35,7 +35,10 @@ using namespace std;
|
|||
":/?[]@"\
|
||||
"!$&'()*+,;="\
|
||||
"-._~"\
|
||||
"%"
|
||||
"%"\
|
||||
"#"
|
||||
|
||||
#define METALINK_MARK "#!metalink3!"
|
||||
|
||||
class Request {
|
||||
private:
|
||||
|
|
|
@ -47,7 +47,7 @@ using namespace std;
|
|||
#define DEFAULT_ANNOUNCE_MIN_INTERVAL 1800
|
||||
#define MAX_PEERS 55
|
||||
#define MIN_PEERS 15
|
||||
#define MAX_PEER_LIST_SIZE 250
|
||||
#define MAX_PEER_LIST_SIZE 100
|
||||
#define END_GAME_PIECE_NUM 20
|
||||
#define MAX_PEER_ERROR 5
|
||||
|
||||
|
|
|
@ -23,6 +23,8 @@ class RequestTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testRedirectUrl2);
|
||||
CPPUNIT_TEST(testResetUrl);
|
||||
CPPUNIT_TEST(testSafeChar);
|
||||
CPPUNIT_TEST(testInnerLink);
|
||||
CPPUNIT_TEST(testMetalink);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
public:
|
||||
|
@ -44,6 +46,8 @@ public:
|
|||
void testRedirectUrl2();
|
||||
void testResetUrl();
|
||||
void testSafeChar();
|
||||
void testInnerLink();
|
||||
void testMetalink();
|
||||
};
|
||||
|
||||
|
||||
|
@ -270,3 +274,22 @@ void RequestTest::testSafeChar() {
|
|||
bool v = req.setUrl("http://aria.rednoah.com/|<>");
|
||||
CPPUNIT_ASSERT(!v);
|
||||
}
|
||||
|
||||
void RequestTest::testInnerLink() {
|
||||
Request req;
|
||||
bool v = req.setUrl("http://aria.rednoah.com/index.html#download");
|
||||
CPPUNIT_ASSERT(v);
|
||||
CPPUNIT_ASSERT_EQUAL(string("index.html"), req.getFile());
|
||||
}
|
||||
|
||||
void RequestTest::testMetalink() {
|
||||
Request req;
|
||||
bool v = req.setUrl("http://aria.rednoah.com/download/aria.tar.bz2#!metalink3!http://aria2.sourceforge.net/download/aria.metalink");
|
||||
CPPUNIT_ASSERT(v);
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria2.sourceforge.net"), req.getHost());
|
||||
CPPUNIT_ASSERT_EQUAL(string("/download"), req.getDir());
|
||||
CPPUNIT_ASSERT_EQUAL(string("aria.metalink"), req.getFile());
|
||||
|
||||
bool v2 = req.setUrl("http://aria.rednoah.com/download/aria.tar.bz2#!metalink3!");
|
||||
CPPUNIT_ASSERT(!v2);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue