mirror of
https://github.com/aria2/aria2.git
synced 2025-01-24 02:31:29 +00:00
d5bb035642
* src/AbstractCommand.cc (execute): Changed log level of MSG_RESTARTING_DOWNLOAD and MSG_MAX_TRY from error to info. Added MSG_DOWNLOAD_ABORTED after MSG_MAX_TRY. * src/message.h (MSG_TORRENT_DOWNLOAD_ABORTED): New definition. (MSG_DOWNLOAD_ABORTED): Added %s. (MSG_RESTARTING_DOWNLOAD): Added %s. (MSG_DOWNLOAD_ALREADY_COMPLETED): Updated. * src/PeerAbstractCommand.cc (execute): MSG_DOWNLOAD_ABORTED -> MSG_TORRENT_DOWNLOAD_ABORTED * src/Request.h (cookieBox): Made ShardHandle. * src/RequestGroup.h, src/RequestGroup.cc (createNextCommandWithAdj): New function. * src/FileAllocationCommand.cc (executeInternal): Use createNextCommandWithAdj(). * src/CheckIntegrityCommand.cc (executeInternal): Use createNextCommandWithAdj(). Added --load-cookies command-option. * src/OptionHandlerFactory.cc (createOptionHandlers): Added PREF_LOAD_COOKIES. * src/CookieBox.h, src/CookieBox.cc: Rwritten using CookieParser. Now aria2 can handle cookie's expiration date. * src/Cookie.h (expires): Changed its type to time_t. * src/main.cc: Added --load-cookies command-line option. * src/prefs.h (PREF_LOAD_COOKIES): New definition. * src/Util.h, src/Util.cc (httpGMT): New function. * src/Request.cc (Request): Initialize cookieBox using CookieBoxFactory. * src/CookieBoxFactory.h, src/CookieBoxFactory.cc: New class. * src/CookieParser.h, src/CookieParser.cc: New class. * src/main.cc: Chagned the default value of --metalink-servers to 5. * src/HttpResponseCommand.cc (handleOtherEncoding): Call RequestGroup::shouldCancelDownloadForSafety
65 lines
1.9 KiB
C++
65 lines
1.9 KiB
C++
#include "CookieBox.h"
|
|
#include <string>
|
|
#include <cppunit/extensions/HelperMacros.h>
|
|
|
|
using namespace std;
|
|
|
|
class CookieBoxTest:public CppUnit::TestFixture {
|
|
|
|
CPPUNIT_TEST_SUITE(CookieBoxTest);
|
|
CPPUNIT_TEST(testCriteriaFind);
|
|
CPPUNIT_TEST_SUITE_END();
|
|
private:
|
|
|
|
public:
|
|
void setUp() {
|
|
}
|
|
|
|
void testCriteriaFind();
|
|
};
|
|
|
|
|
|
CPPUNIT_TEST_SUITE_REGISTRATION( CookieBoxTest );
|
|
|
|
void CookieBoxTest::testCriteriaFind() {
|
|
// 1181473200 = Sun Jun 10 11:00:00 2007 GMT
|
|
Cookie c1("SESSIONID1", "1", 1181473200, "/downloads", "rednoah.com", false);
|
|
Cookie c2("SESSIONID2", "2", 1181473200, "/downloads", "rednoah.com", false);
|
|
Cookie c3("USER", "user", "/home", "aria.rednoah.com", false);
|
|
Cookie c4("PASS", "pass", "/downloads", "rednoah.com", true);
|
|
|
|
CookieBox box;
|
|
box.add(c1);
|
|
box.add(c2);
|
|
box.add(c3);
|
|
box.add(c4);
|
|
|
|
Cookies result1 = box.criteriaFind("rednoah.com", "/downloads", 1181473100, false);
|
|
CPPUNIT_ASSERT_EQUAL(2, (int)result1.size());
|
|
Cookies::iterator itr = result1.begin();
|
|
CPPUNIT_ASSERT_EQUAL(string("SESSIONID1=1"), (*itr).toString());
|
|
itr++;
|
|
CPPUNIT_ASSERT_EQUAL(string("SESSIONID2=2"), (*itr).toString());
|
|
|
|
result1 = box.criteriaFind("rednoah.com", "/downloads", 1181473100, true);
|
|
CPPUNIT_ASSERT_EQUAL(3, (int)result1.size());
|
|
itr = result1.begin();
|
|
CPPUNIT_ASSERT_EQUAL(string("SESSIONID1=1"), (*itr).toString());
|
|
itr++;
|
|
CPPUNIT_ASSERT_EQUAL(string("SESSIONID2=2"), (*itr).toString());
|
|
itr++;
|
|
CPPUNIT_ASSERT_EQUAL(string("PASS=pass"), (*itr).toString());
|
|
|
|
result1 = box.criteriaFind("aria.rednoah.com", "/", 1181473100, false);
|
|
CPPUNIT_ASSERT_EQUAL(0, (int)result1.size());
|
|
|
|
result1 = box.criteriaFind("aria.rednoah.com", "/home", 1181473100, false);
|
|
CPPUNIT_ASSERT_EQUAL(1, (int)result1.size());
|
|
itr = result1.begin();
|
|
CPPUNIT_ASSERT_EQUAL(string("USER=user"), (*itr).toString());
|
|
|
|
result1 = box.criteriaFind("rednoah.com", "/downloads", 1181473200, false);
|
|
CPPUNIT_ASSERT_EQUAL(0, (int)result1.size());
|
|
}
|
|
|