mirror of
https://github.com/aria2/aria2.git
synced 2025-04-07 06:27:37 +03:00
2006-07-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add Metalink support(http/ftp only): * src/AbstractCommand.h (tryReserved): New function. * src/AbstractCommand.cc (execute): Call tryReserved(). (tryReserved): New function. * src/Request.h (Requests): New type definition. * src/SegmentMan.h (reserved): New variable. * src/Util.h (fileChecksum): New function. (toUpper): New function. (toLower): New function. * src/Util.cc (messageDigest.h): Included. (trim): Trim \r\n\t. (fileChecksum): New function. (toUpper): New function. (toLower): New function. * src/main.cc (normalDownload): New function. (main): Added 2 command-line options: metalink-file, metalink-connection. Their usage has not been written yet. * src/MetalinkProcessor.h: New class. * src/Xml2MetalinkProcessor.h: New class. * src/Xml2MetalinkProcessor.cc: New class. * src/MetalinkEntry.h: New class. * src/MetalinkEntry.cc: New class. * src/MetalinkResource.h: New class. * src/MetalinkResource.cc: New class. To add md5 message digest checking: * src/messageDigest.h: Rewritten. * src/MultiDiskWriter.cc: Updated according to the changes in messageDigest.h. * src/ShaVisitor.cc: Updated according to the changes in messageDigest.h. * src/Util.cc: Updated according to the changes in messageDigest.h. * src/AbstractDiskWriter.cc: Updated according to the changes in messageDigest.h. To fix a bug that causes segfault when the payload length in peer message is less than 0: * src/PeerConnection.cc: (receiveMessage): Fixed the bug. * src/PeerMessageUtil.cc (checkLength): Throw an exception if length is less than or equals to 0. To add new interfaces to Base64 encoding/decoding: * src/Base64.h (part_encode): Changed the method signature. (encode): New function(overload). (decode): New function(overload). * src/Base64.cc (part_encode): Rewritten. (encode): Rewritten. (encode): New function(overload). To prevent a peer to download same piece if there is an error in checksum: * src/PieceMessage.cc (receivedAction): Call peerInteraction->abortPiece().
This commit is contained in:
parent
003a474357
commit
78eff23254
39 changed files with 1724 additions and 156 deletions
|
@ -17,6 +17,9 @@ class UtilTest:public CppUnit::TestFixture {
|
|||
CPPUNIT_TEST(testGetContentDispositionFilename);
|
||||
CPPUNIT_TEST(testComputeFastSet);
|
||||
CPPUNIT_TEST(testRandomAlpha);
|
||||
CPPUNIT_TEST(testFileChecksum);
|
||||
CPPUNIT_TEST(testToUpper);
|
||||
CPPUNIT_TEST(testToLower);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
private:
|
||||
|
||||
|
@ -34,6 +37,9 @@ public:
|
|||
// may be moved to other helper class in the future.
|
||||
void testGetContentDispositionFilename();
|
||||
void testRandomAlpha();
|
||||
void testFileChecksum();
|
||||
void testToUpper();
|
||||
void testToLower();
|
||||
};
|
||||
|
||||
|
||||
|
@ -214,3 +220,31 @@ void UtilTest::testComputeFastSet() {
|
|||
void UtilTest::testRandomAlpha() {
|
||||
CPPUNIT_ASSERT_EQUAL(string("rUopvKRn"), Util::randomAlpha(8));
|
||||
}
|
||||
|
||||
void UtilTest::testFileChecksum() {
|
||||
unsigned char buf[20];
|
||||
string filename = "4096chunk.txt";
|
||||
Util::fileChecksum(filename, buf, MessageDigestContext::ALGO_SHA1);
|
||||
string sha1 = Util::toHex(buf, 20);
|
||||
CPPUNIT_ASSERT_EQUAL(string("608cabc0f2fa18c260cafd974516865c772363d5"),
|
||||
sha1);
|
||||
|
||||
Util::fileChecksum(filename, buf, MessageDigestContext::ALGO_MD5);
|
||||
string md5 = Util::toHex(buf, 16);
|
||||
CPPUNIT_ASSERT_EQUAL(string("82a7348c2e03731109d0cf45a7325b88"),
|
||||
md5);
|
||||
}
|
||||
|
||||
void UtilTest::testToUpper() {
|
||||
string src = "608cabc0f2fa18c260cafd974516865c772363d5";
|
||||
string upp = "608CABC0F2FA18C260CAFD974516865C772363D5";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(upp, Util::toUpper(src));
|
||||
}
|
||||
|
||||
void UtilTest::testToLower() {
|
||||
string src = "608CABC0F2FA18C260CAFD974516865C772363D5";
|
||||
string upp = "608cabc0f2fa18c260cafd974516865c772363d5";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(upp, Util::toLower(src));
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue