pull/1/head
Tatsuhiro Tsujikawa 2006-02-21 15:01:05 +00:00
parent 32e8f2b011
commit 28fc3405dd
10 changed files with 87 additions and 33 deletions

View File

@ -1,23 +1,41 @@
2006-02-21 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* FtpInitiateConnectionCommand.{h,cc}:
* FtpNegotiationCommand.{h,cc}:
* FtpDownloadCommand.{h,cc}:
* FtpConnection.{h,cc}: Added FTP support
* SimpleLogger.cc: Log message now includes time information.
* main.cc: The value of --http-auth-scheme option is chagned from
'BASIC' to 'basic'
* main.cc: Added --timeout command-line option.
* prefs.h: option string constants are now defined in prefs.h
2006-02-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Fixed timeout bug in AbstractCommand
* Added totalSize entry to .aria2 file. No compatibility for
version 0.1.0's.
* AbstractCommand.cc: Fixed timeout bug in AbstractCommand
* SegmentMan.cc: Added totalSize entry to .aria2 file. No compatibility
with version 0.1.0's one.
2006-02-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Added --enable-ssl option to configure script.
* Make Request-URI an absolute path. Some servers cannot permit
absoluteURI as Request-URI.
* Added Referer support.
* Added referer command-line option.
* Added rety-wait command-line option.
* Fixed formating bug in Exception::setMsg()
* Added HTTPS support.
* Added SocketCore. Socket is now handle class for SocketCore.
* Fixed bug in ChunkedEncoding: expanding buffer size is wrong
* Fixed bug in DownloadCommand: In Chunked Encoding, it wrongly
adds to Segment.ds buff length from the socket.
* configure.in: Added --enable-ssl option to configure script.
* HttpConnection.cc: Make Request-URI an absolute path. Some servers
cannot permit absoluteURI as Request-URI.
* HttpConnection.cc: Added Referer support.
* main.cc: Added referer command-line option.
* main.cc: Added rety-wait command-line option.
* Exception.h: Fixed formating bug in Exception::setMsg()
* SocketCore.{h,cc}:
* Socket.{h, cc}:
* Request.cc:
* InitiateConnectionCommandFactory.cc:
* HttpRequestCommand.cc: Added HTTPS support.
* SocketCore.{h,cc}: Added SocketCore. Socket becomes a handle class
for SocketCore.
* ChunkedEncoding.cc: Fixed bug in ChunkedEncoding: expanding buffer
size is wrong
* DownloadCommand.cc: Fixed bug in DownloadCommand: In Chunked
Encoding, it wrongly adds to Segment.ds buff length from the socket.
2006-02-17 Tatsuhiro Tsujikawa <tsujikawa at rednoah dot com>

6
README
View File

@ -1,4 +1,4 @@
aria2 - a simple utility for downloading files faster.
aria2 - a simple utility for downloading files.
1. Disclaimer
-------------
@ -11,10 +11,12 @@ aria2 has segmented downloading engine in its core. By segmented downloading,
it can download files very much faster than ordinary browsers.
aria2 is in very early development stage. Currently it has following features:
* HTTP GET support
* HTTP/HTTPS GET support
* HTTP Proxy support
* HTTP BASIC authentication support
* HTTP Proxy authentication support
* FTP support(active, passive mode)
* FTP through HTTP proxy(GET command or tunneling)
* Segmented download
* Cookie support(currently aria2 ignores "expires")
* It can run as a daemon process.

1
TODO
View File

@ -1,6 +1,5 @@
* Add HTTP POST support
* Add expires handling for Cookie
* Add FTP support
* Add SSL server cert verification
* Add SSL client cert support
* Better HTTP status handling

View File

@ -32,13 +32,13 @@ FtpConnection::~FtpConnection() {}
void FtpConnection::sendUser() const {
string request = "USER "+option->get(PREF_FTP_USER)+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}
void FtpConnection::sendPass() const {
string request = "PASS "+option->get(PREF_FTP_PASSWD)+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, "PASS ********");
logger->info(MSG_SENDING_REQUEST, cuid, "PASS ********");
socket->writeData(request);
}
@ -50,25 +50,25 @@ void FtpConnection::sendType() const {
type = "I";
}
string request = "TYPE "+type+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}
void FtpConnection::sendCwd() const {
string request = "CWD "+req->getDir()+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}
void FtpConnection::sendSize() const {
string request = "SIZE "+req->getFile()+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}
void FtpConnection::sendPasv() const {
string request = "PASV\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}
@ -87,7 +87,7 @@ Socket* FtpConnection::sendPort() const {
Util::itos(ipaddr[0])+","+Util::itos(ipaddr[1])+","+
Util::itos(ipaddr[2])+","+Util::itos(ipaddr[3])+","+
Util::itos(addrinfo.second/256)+","+Util::itos(addrinfo.second%256)+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
} catch (Exception* ex) {
delete serverSocket;
@ -98,13 +98,13 @@ Socket* FtpConnection::sendPort() const {
void FtpConnection::sendRest(const Segment& segment) const {
string request = "REST "+Util::llitos(segment.sp+segment.ds)+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}
void FtpConnection::sendRetr() const {
string request = "RETR "+req->getFile()+"\r\n";
logger->info(MSG_SENDING_FTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request);
}

View File

@ -31,7 +31,7 @@ HttpConnection::HttpConnection(int cuid, const Socket* socket, const Request* re
void HttpConnection::sendRequest(const Segment& segment) const {
string request = createRequest(segment);
logger->info(MSG_SENDING_HTTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request.c_str(), request.size());
}
@ -46,7 +46,7 @@ void HttpConnection::sendProxyRequest() const {
option->get(PREF_HTTP_PROXY_PORT))+"\r\n";
}
request += "\r\n";
logger->info(MSG_SENDING_HTTP_REQUEST, cuid, request.c_str());
logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
socket->writeData(request.c_str(), request.size());
}

View File

@ -20,6 +20,8 @@
*/
/* copyright --> */
#include "SimpleLogger.h"
#include "Util.h"
#include <time.h>
#include <stdarg.h>
SimpleLogger::SimpleLogger(string filename) {
@ -50,9 +52,13 @@ void SimpleLogger::writeLog(int level, string msg, va_list ap, Exception* e) con
default:
levelStr = "INFO";
}
vfprintf(file, string(levelStr+" - "+msg+"\n").c_str(), ap);
time_t now = time(NULL);
char datestr[26];
ctime_r(&now, datestr);
datestr[strlen(datestr)-1] = '\0';
vfprintf(file, string(string(datestr)+" - "+levelStr+" - "+Util::replace(msg, "\r", "")+"\n").c_str(), ap);
if(e != NULL) {
fprintf(file, string(levelStr+" - exception: "+e->getMsg()+"\n").c_str());
fprintf(file, string(string(datestr)+" - "+levelStr+" - exception: "+Util::replace(e->getMsg(), "\r", "")+"\n").c_str());
}
fflush(stdout);
}

View File

@ -119,3 +119,21 @@ bool Util::endsWith(string target, string part) {
return false;
}
}
string Util::replace(string target, string oldstr, string newstr) {
if(target == "" || oldstr == "" ) {
return target;
}
string result;
string::size_type p = 0;
string::size_type np = target.find(oldstr);
while(np != string::npos) {
result += target.substr(p, np-p)+newstr;
p = np+oldstr.size();
np = target.find(oldstr, p);
}
result += target.substr(p);
return result;
}

View File

@ -51,6 +51,8 @@ public:
static string trim(string src);
static bool endsWith(string target, string part);
static string replace(string target, string oldstr, string newstr);
};
#endif // _D_UTIL_H_

View File

@ -27,8 +27,7 @@
#define MSG_CONNECTING_TO_SERVER "CUID#%d - Connecting to %s:%d"
#define MSG_SEGMENT_CHANGED "CUID#%d - The segment changed. We send the request again with new Range header."
#define MSG_REDIRECT "CUID#%d - Redirecting to %s"
#define MSG_SENDING_HTTP_REQUEST "CUID#%d - Sending the request:\n%s"
#define MSG_SENDING_FTP_REQUEST "CUID#%d - Sending the request: %s"
#define MSG_SENDING_REQUEST "CUID#%d - Requesting:\n%s"
#define MSG_RECEIVE_RESPONSE "CUID#%d - Response received:\n%s"
#define MSG_DOWNLOAD_ABORTED "CUID#%d - Download aborted."
#define MSG_RESTARTING_DOWNLOAD "CUID#%d - Restarting the download."

View File

@ -11,6 +11,7 @@ class UtilTest:public CppUnit::TestFixture {
CPPUNIT_TEST(testSplit);
CPPUNIT_TEST(testSlice);
CPPUNIT_TEST(testEndsWith);
CPPUNIT_TEST(testReplace);
CPPUNIT_TEST_SUITE_END();
private:
@ -22,6 +23,7 @@ public:
void testSplit();
void testSlice();
void testEndsWith();
void testReplace();
};
@ -111,3 +113,11 @@ void UtilTest::testEndsWith() {
part = "g";
CPPUNIT_ASSERT(!Util::endsWith(target, part));
}
void UtilTest::testReplace() {
CPPUNIT_ASSERT_EQUAL(string("abc\n"), Util::replace("abc\r\n", "\r", ""));
CPPUNIT_ASSERT_EQUAL(string("abc"), Util::replace("abc\r\n", "\r\n", ""));
CPPUNIT_ASSERT_EQUAL(string(""), Util::replace("", "\r\n", ""));
CPPUNIT_ASSERT_EQUAL(string("abc"), Util::replace("abc", "", "a"));
CPPUNIT_ASSERT_EQUAL(string("xbc"), Util::replace("abc", "a", "x"));
}