2006-02-21 12:28:42 +00:00
|
|
|
/* <!-- copyright */
|
|
|
|
/*
|
2006-09-21 15:31:24 +00:00
|
|
|
* aria2 - The high speed download utility
|
2006-02-21 12:28:42 +00:00
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2006-09-21 15:31:24 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*
|
|
|
|
* In addition, as a special exception, the copyright holders give
|
|
|
|
* permission to link the code of portions of this program with the
|
|
|
|
* OpenSSL library under certain conditions as described in each
|
|
|
|
* individual source file, and distribute linked combinations
|
|
|
|
* including the two.
|
|
|
|
* You must obey the GNU General Public License in all respects
|
|
|
|
* for all of the code used other than OpenSSL. If you modify
|
|
|
|
* file(s) with this exception, you may extend this exception to your
|
|
|
|
* version of the file(s), but you are not obligated to do so. If you
|
|
|
|
* do not wish to do so, delete this exception statement from your
|
|
|
|
* version. If you delete this exception statement from all source
|
|
|
|
* files in the program, then also delete it here.
|
2006-02-21 12:28:42 +00:00
|
|
|
*/
|
|
|
|
/* copyright --> */
|
|
|
|
#include "FtpNegotiationCommand.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "DownloadEngine.h"
|
|
|
|
#include "FtpConnection.h"
|
|
|
|
#include "RequestGroup.h"
|
|
|
|
#include "PieceStorage.h"
|
2006-02-21 12:28:42 +00:00
|
|
|
#include "FtpDownloadCommand.h"
|
|
|
|
#include "DlAbortEx.h"
|
|
|
|
#include "message.h"
|
2006-02-21 14:00:58 +00:00
|
|
|
#include "prefs.h"
|
2007-01-08 00:13:25 +00:00
|
|
|
#include "Util.h"
|
2007-10-11 16:58:24 +00:00
|
|
|
#include "SingleFileDownloadContext.h"
|
2007-11-05 15:50:49 +00:00
|
|
|
#include "DefaultBtProgressInfoFile.h"
|
2007-11-13 11:46:58 +00:00
|
|
|
#include "RequestGroupMan.h"
|
|
|
|
#include "DownloadFailureException.h"
|
2007-12-12 13:53:33 +00:00
|
|
|
#include "ServerHost.h"
|
2006-02-21 12:28:42 +00:00
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
FtpNegotiationCommand::FtpNegotiationCommand(int32_t cuid,
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
const RequestHandle& req,
|
2007-05-20 13:51:52 +00:00
|
|
|
RequestGroup* requestGroup,
|
2006-07-19 17:07:45 +00:00
|
|
|
DownloadEngine* e,
|
|
|
|
const SocketHandle& s):
|
2007-05-20 13:51:52 +00:00
|
|
|
AbstractCommand(cuid, req, requestGroup, e, s), sequence(SEQ_RECV_GREETING)
|
2006-02-21 12:28:42 +00:00
|
|
|
{
|
2006-04-17 16:17:20 +00:00
|
|
|
ftp = new FtpConnection(cuid, socket, req, e->option);
|
2006-07-19 17:07:45 +00:00
|
|
|
disableReadCheckSocket();
|
2006-02-21 12:28:42 +00:00
|
|
|
setWriteCheckSocket(socket);
|
|
|
|
}
|
|
|
|
|
|
|
|
FtpNegotiationCommand::~FtpNegotiationCommand() {
|
|
|
|
delete ftp;
|
|
|
|
}
|
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
bool FtpNegotiationCommand::executeInternal() {
|
2007-10-17 16:26:51 +00:00
|
|
|
while(processSequence(_segments.front()));
|
2006-02-21 12:28:42 +00:00
|
|
|
if(sequence == SEQ_RETRY) {
|
|
|
|
return prepareForRetry(0);
|
|
|
|
} else if(sequence == SEQ_NEGOTIATION_COMPLETED) {
|
2006-07-19 17:07:45 +00:00
|
|
|
FtpDownloadCommand* command =
|
2007-05-20 13:51:52 +00:00
|
|
|
new FtpDownloadCommand(cuid, req, _requestGroup, e, dataSocket, socket);
|
2007-01-23 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To add chunk checksum validation:
* src/MetalinkEntry.h
(MetalinkChunkChecksum.h): New include.
(chunkChecksum): New variable.
* src/Request.h
(method): New variable.
(setMethod): New function.
(getMethod): New function.
(METHOD_GET): New static constant.
(METHOD_HEAD): New static constant.
* src/Xml2MetalinkProcessor.h
(getPieceHash): New function.
* src/PieceStorage.h
(markAllPiecesDone): New function.
(checkIntegrity): New function.
* src/FileAllocator.h
(NullFileAllocationMonitor.h): New include.
(FileAllocator): Initialize fileAllocationMonitor with new
NullFileAllocationMonitor().
* src/MultiDiskAdaptor.h
(messageDigest.h): Remove include.
(ctx): Removed.
(hashUpdate): Added ctx.
(MultiDiskAdaptor): Removed ctx.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/UrlRequestInfo.h
(HeadResult): New class.
(digestAlgo): New variable.
(chunkChecksumLength): New variable.
(chunkChecksums): New variable.
(getHeadResult): New function.
(UrlRequestInfo): Added digestAlgo, chunkChecksumLength.
(setDigestAlgo): New function.
(setChunkChecksumLength): New function.
(setChunkChecksums): New function.
* src/DefaultPieceStorage.cc
(DiskAdaptorWriter.h): New include.
(ChunkChecksumValidator.h): New include.
(markAllPiecesDone): New function.
(checkIntegrity): New function.
* src/DefaultBtContext.h
(getPieceHashes): New function.
* src/TorrentRequestInfo.cc
(execute): Try to validate chunk checksum if file already exists
and
.aria2 file doesn't there and user allows aria2 to overwrite it.
* src/messageDigest.h
(~MessageDigestContext): Added digestFree().
* src/MetalinkRequestInfo.cc
(execute): Set digestAlgo, chunkChecksum, chunkChecksums to
reqInfo.
* src/DiskAdaptor.h
(messageDigest.h): New include.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/DownloadCommand.h
(PeerStat.h): New include.
(maxDownloadSpeedLimit): New variable.
(startupIdleTime): New variable.
(lowestDownloadSpeedLimit): New variable.
(peerStat): New variable.
(setMaxDownloadSpeedLimit): New function.
(setStartupIdleTime): New function.
(setLowestDownloadSPeedLimit): New function.
* src/BtContext.h
(getPieceHashes): New function.
* src/main.cc
(main): Set PREF_REALTIME_CHUNK_CHECKSUM and
PREF_CHECK_INTEGRITY
option to true for testing purpose.
* src/BtPieceMessage.cc
(checkPieceHash): Use messageDigest
* src/DownloadEngine.cc
(SetDescriptor): Removed.
(AccumulateActiveCommand): Removed.
(waitData): Rewritten.
(updateFdSet): Rewritten.
* src/MultiDiskAdaptor.cc
(hashUpdate): Added ctx.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/BitfieldMan.h
(isBitRangeSet): New function.
(unsetBitRange): New function.
* src/ByteArrayDiskWriter.h
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/ConsoleDownloadEngine.cc
(calculateStatistics): If nspeed < 0 then set nspeed to 0.
* src/DiskWriter.h
(messageDigest.h): New include.
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/ChunkChecksumValidator.h: New class.
* src/DiskAdaptorWriter.h: New class.
* src/prefs.h
(PREF_REALTIME_CHUNK_CHECKSUM): New definition.
(PREF_CHECK_INTEGRITY): New definition.
* src/HttpResponseCommand.cc
(handleDefaultEncoding): Added method "HEAD" handling.
Removed the call to
e->segmentMan->shouldCancelDownloadForSafety().
(handleOtherEncoding):
Added the call to
e->segmentMan->shouldCancelDownloadForSafety().
(createHttpDownloadCommand): Set maxDownloadSpeedLimit,
startupIdleTime, lowestDownloadSpeedLimit to command.
* src/SegmentMan.h
(getSegmentEntryByIndex): New function.
(getSegmentEntryByCuid): New function.
(getSegmentEntryIteratorByCuid): New function.
(diskWriter): DiskWriter -> DiskWriterHandle
(pieceHashes): New variable.
(chunkHashLength): New variable.
(digestAlgo): New variable.
(FindPeerStat): Removed.
(getPeerStat): Rewritten.
(markAllPiecesDone): New function.
(checkIntegrity): New function.
(tryChunkChecksumValidation): New function.
(isChunkChecksumValidationReady): New function.
* src/BitfieldMan.cc
(BitfieldMan): Initialized bitfieldLength, blocks to 0.
(BitfieldMan): Initialized blockLength, totalLength,
bitfieldLength,
blocks to 0.
(isBitRangeSet): New function.
(unsetBitRange): New function.
* src/FtpNegotiateCommand.cc
(executeInternal): Set maxDownloadSpeedLimit,
startupIdleTime, lowestDownloadSpeedLimit to command.
(recvSize): Added method "HEAD" handling.
Removed the call to
e->segmentMan->shouldCancelDownloadForSafety().
* src/AbstractSingleDiskAdaptor.cc
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/AbstractSingleDiskAdaptor.h
(sha1Sum): Renamed as messageDigest.
(messageDigest): New function.
* src/Util.h
(indexRange): New function.
* src/MetalinkEntry.cc
(MetalinkEntry): Initialized chunkChecksum to 0.
* src/ShaVisitor.cc
(~ShaVisitor): Removed the call to ctx.digestFree().
* src/SegmentMan.cc
(ChunkChecksumValidator.h): New include.
(SegmentMan): Initialized chunkHashLength to 0. Initialized
digestAlgo
to DIGEST_ALGO_SHA1.
(~SegmentMan): Removed diskWriter.
(FindSegmentEntryByIndex): Removed.
(FindSegmentEntryByCuid): Removed.
(checkoutSegment): Rewritten.
(findSlowerSegmentEntry): Rewritten.
(getSegment): Rewritten.
(updateSegment): Rewritten.
(completeSegment): Rewritten.
(markAllPiecesDone): New function.
(checkIntegrity): New function.
(isChunkChecksumValidationReady): New function.
(tryChunkChecksumValidation): New function.
* src/Xml2MetalinkProcessor.cc
(getEntry): Get size and set it to entry.
Get chunk checksum and set it to entry.
(getPieceHash): New function.
* src/Util.cc
(sha1Sum): Removed ctx.digestFree()
(fileChecksum): Removed ctx.digestFree()
(indexRange): New function.
* src/Request.cc
(METHOD_GET): New variable.
(METHOD_HEAD): New variable.
(Request): Added method.
* src/UrlRequestInfo.cc
(FatalException.h): New include.
(message.h): New include.
(operator<<): Added operator<< for class HeadResult.
(getHeadResult): New function.
(execute): Get filename and size in separate download engine.
* src/ChunkChecksumValidator.cc: New class.
* src/DownloadCommand.cc:
(DownloadCommand): Added peerStat.
(executeInternal): Use maxDownloadSpeedLimit member instead of
getting
the value from Option.
The buffer size is now 16KB.
Use peerStat member instead of getting it from SegmentMan.
Use startupIdleTime member instead of gettingit from Option.
Added chunk checksum validation.
* src/AbstractDiskWriter.cc
(AbstractDiskWriter): Removed ctx.
(~AbstractDiskWriter): Removed ctx.digestFree()
(writeDataInternal): Returns the return value of write.
(readDataInternal): Returns the return value of read.
(sha1Sum): Renamed as messageDigest
(messageDigest): New function.
* src/AbstractDiwkWriter.h
(messageDigest.h): Removed include.
(ctx): Removed.
(sha1Sum): Renamed as messageDigest
(messageDigest): New function.
* src/DefaultPieceStorage.h
(markAllPiecesDone): New function.
(checkIntegrity): New function.
* src/NullFileAllocationMonitor.h: New class.
2007-01-24 15:55:34 +00:00
|
|
|
command->setMaxDownloadSpeedLimit(e->option->getAsInt(PREF_MAX_DOWNLOAD_LIMIT));
|
|
|
|
command->setStartupIdleTime(e->option->getAsInt(PREF_STARTUP_IDLE_TIME));
|
|
|
|
command->setLowestDownloadSpeedLimit(e->option->getAsInt(PREF_LOWEST_SPEED_LIMIT));
|
2007-12-12 13:53:33 +00:00
|
|
|
if(!_requestGroup->isSingleHostMultiConnectionEnabled()) {
|
|
|
|
_requestGroup->removeURIWhoseHostnameIs(_requestGroup->searchServerHost(cuid)->getHostname());
|
|
|
|
}
|
2006-05-09 15:54:14 +00:00
|
|
|
e->commands.push_back(command);
|
2006-02-21 12:28:42 +00:00
|
|
|
return true;
|
2007-12-01 04:56:10 +00:00
|
|
|
} else if(sequence == SEQ_HEAD_OK || sequence == SEQ_DOWNLOAD_ALREADY_COMPLETED) {
|
2007-01-29 16:46:48 +00:00
|
|
|
return true;
|
2007-12-01 04:56:10 +00:00
|
|
|
} else if(sequence == SEQ_FILE_PREPARATION) {
|
|
|
|
if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
|
|
|
|
sequence = SEQ_SEND_PASV;
|
|
|
|
} else {
|
|
|
|
sequence = SEQ_SEND_PORT;
|
|
|
|
}
|
|
|
|
return false;
|
2006-02-21 12:28:42 +00:00
|
|
|
} else {
|
2006-05-09 15:54:14 +00:00
|
|
|
e->commands.push_back(this);
|
2006-02-21 12:28:42 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvGreeting() {
|
|
|
|
socket->setBlockingMode();
|
2006-08-07 16:05:00 +00:00
|
|
|
disableWriteCheckSocket();
|
|
|
|
setReadCheckSocket(socket);
|
|
|
|
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 220) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_CONNECTION_FAILED);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
sequence = SEQ_SEND_USER;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendUser() {
|
|
|
|
ftp->sendUser();
|
|
|
|
sequence = SEQ_RECV_USER;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvUser() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
switch(status) {
|
|
|
|
case 0:
|
|
|
|
return false;
|
|
|
|
case 230:
|
|
|
|
sequence = SEQ_SEND_TYPE;
|
|
|
|
break;
|
|
|
|
case 331:
|
|
|
|
sequence = SEQ_SEND_PASS;
|
|
|
|
break;
|
|
|
|
default:
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendPass() {
|
|
|
|
ftp->sendPass();
|
|
|
|
sequence = SEQ_RECV_PASS;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvPass() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 230) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
sequence = SEQ_SEND_TYPE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendType() {
|
|
|
|
ftp->sendType();
|
|
|
|
sequence = SEQ_RECV_TYPE;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvType() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 200) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
sequence = SEQ_SEND_CWD;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendCwd() {
|
|
|
|
ftp->sendCwd();
|
|
|
|
sequence = SEQ_RECV_CWD;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvCwd() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 250) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
sequence = SEQ_SEND_SIZE;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendSize() {
|
|
|
|
ftp->sendSize();
|
|
|
|
sequence = SEQ_RECV_SIZE;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvSize() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int64_t size = 0;
|
|
|
|
int32_t status = ftp->receiveSizeResponse(size);
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 213) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 14:00:58 +00:00
|
|
|
}
|
2007-01-28 14:18:35 +00:00
|
|
|
if(size == INT64_MAX || size < 0) {
|
2007-07-23 13:04:48 +00:00
|
|
|
throw new DlAbortEx(EX_TOO_LARGE_FILE, Util::llitos(size, true).c_str());
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
2007-10-11 16:58:24 +00:00
|
|
|
if(_requestGroup->getPieceStorage().isNull()) {
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
SingleFileDownloadContextHandle dctx = _requestGroup->getDownloadContext();
|
|
|
|
dctx->setTotalLength(size);
|
|
|
|
dctx->setFilename(Util::urldecode(req->getFile()));
|
2007-11-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten to add content-type support.
* src/DownloadHandler.{h, cc}
* src/BtPostDownloadHandler.{h, cc}
* test/BtPostDownloadHandlerTest.cc
* src/MetalinkPostDownloadHandler.{h, cc}
* test/MetalinkPostDownloadHandlerTest.cc
* src/PostDownloadHandler.{h, cc}
* src/DownloadHandlerConstants.{h, cc}
* src/RequestGroup.cc
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
* src/SingleFileDownloadContext.{h, cc}
* src/RequestGroup.h
* src/RequestGroupCriteria.h
* src/ContentTypeRequestGroupCriteria.h
Added 'mem' option value for --follow-metalink,
--follow-torrent.
If it is give, metalink/torrent file is not written to the disk,
but
just is kept in memory. Parsing is occurred on memory.
* src/MetalinkHelper.{h, cc}
* src/MetalinkProcessor.h
* src/Xml2MetalinkProcessor.{h, cc}
* test/Xml2MetalinkProcessorTest.cc
* src/DownloadHandlerFactory.{h, cc}
* test/DownloadHandlerFactoryTest.cc
* src/PreDownloadHandler.{h, cc}
* src/OptionHandlerFactory.cc
* src/DefaultBtContext.{h, cc}
* test/DefaultBtContextTest.cc
* src/version_usage.cc
* src/Metalink2RequestGroup.{h, cc}
* src/RequestGroup.{h, cc}
* src/a2functional.h
* test/a2functionalTest.cc
* src/MemoryBufferPreDownloadHandler.{h, cc}
* src/OptionHandlerImpl.h
* src/prefs.h
* src/Util.{h, cc}
* test/UtilTest.cc
Keep DownloadResult rather than RequestGroup after downloads to
reduce
memory usage.
* src/RequestGroupMan.{h, cc}
* src/DownloadEngine.cc
* src/BtDependency.{h, cc}: Changed the type of dependee from
WeakHandle to SharedHandle because WeakHandle could be null.
* src/RequestGroup.{h, cc}
* src/DownloadEngineFactory.cc
* src/DownloadResult.h
Set totalLength after download finished
* src/UnknownLengthPieceStorage.{h, cc}
Keep torrent file specified in metalink in memory.
* src/Metalink2RequestGroup.cc
* src/BtDependency.cc
* src/TrueRequestGroupCriteria.h
Fixed the bug: seekg is used where seekp should be used.
* src/ByteArrayDiskWriter.cc
* test/ByteArraydiskWriterTest.cc
2007-11-27 12:27:10 +00:00
|
|
|
_requestGroup->preDownloadProcessing();
|
2007-11-13 11:46:58 +00:00
|
|
|
if(e->_requestGroupMan->isSameFileBeingDownloaded(_requestGroup)) {
|
|
|
|
throw new DownloadFailureException(EX_DUPLICATE_FILE_DOWNLOAD,
|
|
|
|
_requestGroup->getFilePath().c_str());
|
|
|
|
}
|
|
|
|
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
_requestGroup->initPieceStorage();
|
2007-05-20 13:51:52 +00:00
|
|
|
|
2007-11-07 12:36:33 +00:00
|
|
|
// TODO Is this really necessary?
|
2007-01-29 16:46:48 +00:00
|
|
|
if(req->getMethod() == Request::METHOD_HEAD) {
|
|
|
|
sequence = SEQ_HEAD_OK;
|
|
|
|
return false;
|
|
|
|
}
|
2007-05-20 13:51:52 +00:00
|
|
|
|
2007-11-05 15:50:49 +00:00
|
|
|
BtProgressInfoFileHandle infoFile = new DefaultBtProgressInfoFile(_requestGroup->getDownloadContext(), _requestGroup->getPieceStorage(), e->option);
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
if(!infoFile->exists() && _requestGroup->downloadFinishedByFileLength()) {
|
|
|
|
sequence = SEQ_DOWNLOAD_ALREADY_COMPLETED;
|
|
|
|
return false;
|
2007-05-20 13:51:52 +00:00
|
|
|
}
|
2007-11-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Don't connect server before checking file integrity at startup,
if
filesize and output file path are known.
* src/AbstractCommand.cc
* src/StreamFileAllocationEntry.cc
* src/Metalink2RequestGroup.cc
* src/RequestGroup.{h, cc}
* src/HttpResponseCommand.cc
* src/FtpNegotiationCommand.cc
Added DownloadFailureException. If it is thrown, RequestGroup
should
halt.
* src/AbstractCommand.cc
* src/DownloadFailureException.h
* src/RequestGroup.cc
Catch RecoverableException, instead of DlAbortEx.
* src/RequestGroupMan.cc
* src/FillRequestGroupCommand.cc
* src/MetaFileUtil.cc
* src/IteratableChunkChecksumValidator.cc
Now first parameter of MSG_DOWNLOAD_ABORTED is
gid(RequestGroup::
getGID())
* src/CheckIntegrityCommand.cc
* src/message.h
Print gid instead of idx.
* src/RequestGroupMan.cc
Removed exception throwers declaration.
* src/DirectDiskAdaptor.{h, cc}
* src/SocketCore.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpConnection.{h, cc}
* src/HttpResponse.{h, cc}
* src/DiskAdaptor.{h, cc}
* src/CopyDiskAdaptor.{h, cc}
* src/MultiDiskAdaptor.{h, cc}
* src/HttpHeaderProcessor.{h, cc}
* src/AbstractSingleDiskAdaptor.{h, cc}
* src/Util.{h, cc}
* test/UtilTest.cc
* src/DefaultDiskWriter.{h, cc}
* src/FtpConnection.{h, cc}
* src/AbstractDiskWriter.{h, cc}
Removed duplicate code.
* src/StreamCheckIntegrityEntry.cc
Removed unnecessary include.
* src/DiskWriter.h
Included Exception.h
* src/option_processing.cc
Included 2 files and added doc
* src/TrackerWatcherCommand.cc
* src/SocketCore.cc (writeData): Fixed send error with GnuTLS.
2007-11-09 18:01:12 +00:00
|
|
|
_requestGroup->loadAndOpenFile(infoFile);
|
2007-12-01 04:56:10 +00:00
|
|
|
|
|
|
|
prepareForNextAction(this);
|
2007-05-20 13:51:52 +00:00
|
|
|
|
|
|
|
sequence = SEQ_FILE_PREPARATION;
|
2007-12-01 04:56:10 +00:00
|
|
|
disableReadCheckSocket();
|
|
|
|
setWriteCheckSocket(dataSocket);
|
|
|
|
|
|
|
|
//e->noWait = true;
|
2007-05-20 13:51:52 +00:00
|
|
|
return false;
|
|
|
|
} else {
|
|
|
|
_requestGroup->validateTotalLength(size);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
if(e->option->get(PREF_FTP_PASV) == V_TRUE) {
|
2006-02-21 12:28:42 +00:00
|
|
|
sequence = SEQ_SEND_PASV;
|
|
|
|
} else {
|
|
|
|
sequence = SEQ_SEND_PORT;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendPort() {
|
|
|
|
serverSocket = ftp->sendPort();
|
|
|
|
sequence = SEQ_RECV_PORT;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvPort() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 200) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
sequence = SEQ_SEND_REST;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendPasv() {
|
|
|
|
ftp->sendPasv();
|
|
|
|
sequence = SEQ_RECV_PASV;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvPasv() {
|
2007-07-21 08:56:16 +00:00
|
|
|
pair<string, int32_t> dest;
|
|
|
|
int32_t status = ftp->receivePasvResponse(dest);
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if(status != 227) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
// make a data connection to the server.
|
2006-04-17 16:17:20 +00:00
|
|
|
logger->info(MSG_CONNECTING_TO_SERVER, cuid,
|
|
|
|
dest.first.c_str(),
|
|
|
|
dest.second);
|
2006-02-21 12:28:42 +00:00
|
|
|
dataSocket->establishConnection(dest.first, dest.second);
|
|
|
|
|
2006-07-19 17:07:45 +00:00
|
|
|
disableReadCheckSocket();
|
2006-02-21 12:28:42 +00:00
|
|
|
setWriteCheckSocket(dataSocket);
|
|
|
|
|
|
|
|
sequence = SEQ_SEND_REST_PASV;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
bool FtpNegotiationCommand::sendRestPasv(const SegmentHandle& segment) {
|
2006-02-21 12:28:42 +00:00
|
|
|
dataSocket->setBlockingMode();
|
|
|
|
setReadCheckSocket(socket);
|
2006-07-19 17:07:45 +00:00
|
|
|
disableWriteCheckSocket();
|
2006-02-21 12:28:42 +00:00
|
|
|
return sendRest(segment);
|
|
|
|
}
|
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
bool FtpNegotiationCommand::sendRest(const SegmentHandle& segment) {
|
2006-02-21 12:28:42 +00:00
|
|
|
ftp->sendRest(segment);
|
|
|
|
sequence = SEQ_RECV_REST;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvRest() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2007-05-20 13:51:52 +00:00
|
|
|
// TODO if we recieve negative response, then we set _requestGroup->getSegmentMan()->splittable = false, and continue.
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status != 350) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
|
|
|
sequence = SEQ_SEND_RETR;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::sendRetr() {
|
|
|
|
ftp->sendRetr();
|
|
|
|
sequence = SEQ_RECV_RETR;
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool FtpNegotiationCommand::recvRetr() {
|
2007-07-21 08:56:16 +00:00
|
|
|
int32_t status = ftp->receiveResponse();
|
2006-02-21 12:28:42 +00:00
|
|
|
if(status == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2006-08-07 17:21:09 +00:00
|
|
|
if(status != 150 && status != 125) {
|
2007-12-04 11:38:06 +00:00
|
|
|
throw new DlAbortEx(EX_BAD_STATUS, status);
|
2006-02-21 12:28:42 +00:00
|
|
|
}
|
2007-03-26 12:16:57 +00:00
|
|
|
if(e->option->get(PREF_FTP_PASV) != V_TRUE) {
|
2006-07-19 17:07:45 +00:00
|
|
|
assert(serverSocket->getSockfd() != -1);
|
2006-02-21 12:28:42 +00:00
|
|
|
dataSocket = serverSocket->acceptConnection();
|
|
|
|
}
|
|
|
|
sequence = SEQ_NEGOTIATION_COMPLETED;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-15 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
To handle Segment as SegmentHandle:
* src/AbstractCommand.cc (execute): Rewritten.
* src/SegmentMan.h: Segment -> SegmentHandle
Introducded HttpResponse class, HttpRequest class to improve
code
extensiveness and make it clear:
* src/HttpDownloadCommand.cc: transfer encoders are now managed
by
HttpResponse class.
* src/HttpRequest.h, src/HttpRequest.cc: New class.
* src/HttpResponse.h, src/HttpResponse.cc: New class.
* src/HttpConnection.cc: Contruction of http request were moved
to
HttpRequest class.
* src/HttpResponseCommand.h, src/HttpResponseCommand.cc:
Refactored.
* src/HttpRequestCommand.cc (executeInternal): Rewritten.
* src/HttpAuthConfig.h: New class.
* src/Range.h: New class.
To make FtpTunnel{Request, Response}Command and
HttpProxy{Request, Response}Command derived from
AbstractProxy{Request, Response}Command:
* src/FtpTunnelResponseCommand.h,
src/FtpTunnelResponseCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/FtpTunnelRequestCommand.h, src/FtpTunnelRequestCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/HttpProxyRequestCommand.h, src/HttpProxyRequestCommand.cc:
Derived from AbstractProxyRequestCommand class.
* src/HttpProxyResponseCommand.h,
src/HttpProxyResponseCommand.cc:
Derived from AbstractProxyResponseCommand class.
* src/AbstractProxyRequestCommand.h,
src/AbstractProxyRequestCommand.cc
: New class.
* src/AbstractProxyResponseCommand.h,
src/AbstractProxyResponseCommand.cc: New class.
To add netrc support:
* src/Netrc.h, src/Netrc.cc: New class.
* src/Util.h, src/Util.cc (split): New function.
* src/HttpHeader.cc (getRange): Fixed so that it inspects
"Content-Range" header instead of "Range" header.
* src/HttpHeader.h
(getStatus): Removed.
(setStatus): Removed.
* src/Segment.h
(getPositionToWrite): New function.
2007-03-15 15:07:18 +00:00
|
|
|
bool FtpNegotiationCommand::processSequence(const SegmentHandle& segment) {
|
2006-02-21 12:28:42 +00:00
|
|
|
bool doNextSequence = true;
|
|
|
|
switch(sequence) {
|
|
|
|
case SEQ_RECV_GREETING:
|
|
|
|
return recvGreeting();
|
|
|
|
case SEQ_SEND_USER:
|
|
|
|
return sendUser();
|
|
|
|
case SEQ_RECV_USER:
|
|
|
|
return recvUser();
|
|
|
|
case SEQ_SEND_PASS:
|
|
|
|
return sendPass();
|
|
|
|
case SEQ_RECV_PASS:
|
|
|
|
return recvPass();
|
|
|
|
case SEQ_SEND_TYPE:
|
|
|
|
return sendType();
|
|
|
|
case SEQ_RECV_TYPE:
|
|
|
|
return recvType();
|
|
|
|
case SEQ_SEND_CWD:
|
|
|
|
return sendCwd();
|
|
|
|
case SEQ_RECV_CWD:
|
|
|
|
return recvCwd();
|
|
|
|
case SEQ_SEND_SIZE:
|
|
|
|
return sendSize();
|
|
|
|
case SEQ_RECV_SIZE:
|
|
|
|
return recvSize();
|
|
|
|
case SEQ_SEND_PORT:
|
|
|
|
return sendPort();
|
|
|
|
case SEQ_RECV_PORT:
|
|
|
|
return recvPort();
|
|
|
|
case SEQ_SEND_PASV:
|
|
|
|
return sendPasv();
|
|
|
|
case SEQ_RECV_PASV:
|
|
|
|
return recvPasv();
|
|
|
|
case SEQ_SEND_REST_PASV:
|
|
|
|
return sendRestPasv(segment);
|
|
|
|
case SEQ_SEND_REST:
|
|
|
|
return sendRest(segment);
|
|
|
|
case SEQ_RECV_REST:
|
|
|
|
return recvRest();
|
|
|
|
case SEQ_SEND_RETR:
|
|
|
|
return sendRetr();
|
|
|
|
case SEQ_RECV_RETR:
|
|
|
|
return recvRetr();
|
|
|
|
default:
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
return doNextSequence;
|
|
|
|
}
|