mirror of
https://github.com/aria2/aria2.git
synced 2025-02-18 21:27:34 +00:00

Implemented auto protocol detection. Now you can do: aria2c -Z http://host/file file1.torrent file2.metalink (Note: -Z option is required for auto protcol detection.) Then aria2c downloads 3 files simultaneously: 1. http://host/file 2. file1.torrent <-- read local torrent file 3. file2.metalink <-- read local Metalink file. Same thing goes with -i option. Assume your uris.txt contans: http://host/file file1.torrent file2.metalink Then you can do: aria2c -i uris.txt (Note: -Z option is not needed if -i option is given.) * src/main.cc * src/ProtocolDetector.{cc, h} * test/ProtocolDetectorTest.cc
54 lines
1.5 KiB
C++
54 lines
1.5 KiB
C++
#include "ProtocolDetector.h"
|
|
#include "Exception.h"
|
|
#include "Util.h"
|
|
#include <iostream>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
namespace aria2 {
|
|
|
|
class ProtocolDetectorTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(ProtocolDetectorTest);
|
|
CPPUNIT_TEST(testIsStreamProtocol);
|
|
CPPUNIT_TEST(testGuessTorrentFile);
|
|
CPPUNIT_TEST(testGuessMetalinkFile);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
public:
|
|
void setUp() {}
|
|
|
|
void tearDown() {}
|
|
|
|
void testIsStreamProtocol();
|
|
void testGuessTorrentFile();
|
|
void testGuessMetalinkFile();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION(ProtocolDetectorTest);
|
|
|
|
void ProtocolDetectorTest::testIsStreamProtocol()
|
|
{
|
|
ProtocolDetector detector;
|
|
CPPUNIT_ASSERT(detector.isStreamProtocol("http://localhost/index.html"));
|
|
CPPUNIT_ASSERT(detector.isStreamProtocol("ftp://localhost/index.html"));
|
|
CPPUNIT_ASSERT(!detector.isStreamProtocol("/home/web/localhost/index.html"));
|
|
}
|
|
|
|
void ProtocolDetectorTest::testGuessTorrentFile()
|
|
{
|
|
ProtocolDetector detector;
|
|
CPPUNIT_ASSERT(detector.guessTorrentFile("test.torrent"));
|
|
CPPUNIT_ASSERT(!detector.guessTorrentFile("http://localhost/test.torrent"));
|
|
CPPUNIT_ASSERT(!detector.guessTorrentFile("test.xml"));
|
|
}
|
|
|
|
void ProtocolDetectorTest::testGuessMetalinkFile()
|
|
{
|
|
ProtocolDetector detector;
|
|
CPPUNIT_ASSERT(detector.guessMetalinkFile("test.xml"));
|
|
CPPUNIT_ASSERT(!detector.guessMetalinkFile("http://localhost/test.xml"));
|
|
CPPUNIT_ASSERT(!detector.guessMetalinkFile("test.torrent"));
|
|
}
|
|
|
|
} // namespace aria2
|