mirror of https://github.com/aria2/aria2
2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use digits to find first byte of file size, which makes the intention of the code clearer. * src/FtpConnection.cc Don't call validateTotalLength() when size is 0. * src/FtpNegotiationCommand.ccpull/1/head
parent
23b6a43585
commit
c42c8b7f9c
|
@ -1,3 +1,12 @@
|
||||||
|
2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
|
Use digits to find first byte of file size, which makes the intention
|
||||||
|
of the code clearer.
|
||||||
|
* src/FtpConnection.cc
|
||||||
|
|
||||||
|
Don't call validateTotalLength() when size is 0.
|
||||||
|
* src/FtpNegotiationCommand.cc
|
||||||
|
|
||||||
2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
2008-06-26 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||||
|
|
||||||
Updated po files.
|
Updated po files.
|
||||||
|
|
|
@ -285,6 +285,7 @@ unsigned int FtpConnection::receivePasvResponse(std::pair<std::string, uint16_t>
|
||||||
|
|
||||||
unsigned int FtpConnection::receiveRetrResponse(uint64_t& size)
|
unsigned int FtpConnection::receiveRetrResponse(uint64_t& size)
|
||||||
{
|
{
|
||||||
|
static const char* DIGITS = "0123456789";
|
||||||
std::pair<unsigned int, std::string> response;
|
std::pair<unsigned int, std::string> response;
|
||||||
if(bulkReceiveResponse(response)) {
|
if(bulkReceiveResponse(response)) {
|
||||||
if(response.first == 150 || response.first == 125) {
|
if(response.first == 150 || response.first == 125) {
|
||||||
|
@ -295,11 +296,11 @@ unsigned int FtpConnection::receiveRetrResponse(uint64_t& size)
|
||||||
std::string& res = response.second;
|
std::string& res = response.second;
|
||||||
std::string::size_type start;
|
std::string::size_type start;
|
||||||
if((start = res.find_first_of("(")) != std::string::npos &&
|
if((start = res.find_first_of("(")) != std::string::npos &&
|
||||||
(start = res.find_first_not_of("( ", start)) != std::string::npos) {
|
(start = res.find_first_of(DIGITS, start)) != std::string::npos) {
|
||||||
|
|
||||||
// now start points to the first byte of the size string.
|
// now start points to the first digit of the size string.
|
||||||
std::string::size_type end =
|
std::string::size_type end =
|
||||||
res.find_first_not_of("0123456789", start);
|
res.find_first_not_of(DIGITS, start);
|
||||||
|
|
||||||
if(end != std::string::npos) {
|
if(end != std::string::npos) {
|
||||||
size = Util::parseULLInt(res.substr(start, end-start));
|
size = Util::parseULLInt(res.substr(start, end-start));
|
||||||
|
|
|
@ -421,8 +421,12 @@ bool FtpNegotiationCommand::recvRetr() {
|
||||||
return onFileSizeDetermined(size);
|
return onFileSizeDetermined(size);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
// size == 0 means file size could not be retrieved from the response of
|
||||||
|
// RETR raw command.
|
||||||
|
if(size > 0) {
|
||||||
_requestGroup->validateTotalLength(size);
|
_requestGroup->validateTotalLength(size);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(e->option->getAsBool(PREF_FTP_PASV)) {
|
if(e->option->getAsBool(PREF_FTP_PASV)) {
|
||||||
sequence = SEQ_NEGOTIATION_COMPLETED;
|
sequence = SEQ_NEGOTIATION_COMPLETED;
|
||||||
|
|
Loading…
Reference in New Issue