Don't set Request::supportsPersistentConnection() in
HttpConnection
since this code is also used in AbstractProxyResponseCommand.
Moved those code to HttpResponse.
* src/HttpResponse.cc
* src/HttpResponse.h
* src/HttpConnection.cc
* src/HttpConnection.h
* src/HttpResponseCommand.cc
* test/HttpResponseTest.cc
* src/HttpHeaderProcessor.cc: Rewritten using std::string as a
buffer.
* src/HttpHeaderProcessor.h: Rewritten using std::string as a
buffer.
* src/HttpConnection.cc: Included missing sstream.
Rewritten Exception class. Throw exception object, not its pointer and
catch by reference, so that remove problematic delete operator for
catched exception.
* src/Exception.cc
* src/Exception.h
* test/ExceptionTest.cc
* src/*: All files throwing/catching exception.
* test/*: All files throwing/catching exception.
Now HTTP status and version are a member variable of HttpHeader.
HTTP status is processed as a string, not integer.
* src/AbstractProxyResponseCommand.cc
* src/HttpConnection.cc
* src/HttpHeader.cc
* src/HttpHeader.h
* src/HttpHeaderProcessor.cc
* src/HttpHeaderProcessor.h
* src/HttpResponse.cc
* src/HttpResponse.h
* test/HttpHeaderProcessorTest.cc
* test/HttpResponseTest.cc
Rewritten SharedHandle. Now copy constructor taking raw pointer
has
keyword explicit and SharedHandle's default constructor
initializes
its internal obj to null, old implementation initializes it
using
obj's default constructor.
To assign null, write SharedHandle<T> x(...); x.reset();
TODO: test/SharedHandleTest.cc needs more tests.
* src/SharedHandle.h
Implemented BitTorrent/http/ftp integrated download.
I've rewritten lots of files and now some headers have forward
class declarations to reduce compile time.
The implementation is extremely alpha stage, I recommend to use this
for testing purpose only.
Fixed the bug that prevents cookies from being sent to the
server
if the domain of cookie is FQDN and starts with ".".
* src/Cookie.cc (match)
To add the ability to change peer id.
* src/DefaultBtContext.h
(_peerIdPrefix): New variable
(setPeerIdPrefix): New function.
* src/torrentRequestInfo.cc
(execute): Set the option value of PREF_PEER_ID_PREFIX to
DefaultBtContext.
* src/main.cc (main): Added peer-id-prefix command-line option.
The usage message is not added yet.
* src/DefaultBtContext.cc
(generatePeerId): Use _peerIdPrefix.
* src/prefs.h (PREF_PEER_ID_PREFIX): New definition.
Made -S option work with metalink file and provided selective
download
to metalink.
* src/MetalinkEntry.h, src/MetalinkEntry.cc
(filename): Removed.
(file): New variable.
(size): Removed.
(operator=): Updated.
(getPath): New function.
(getLength): New function.
(toFileEntry): New function.
* src/TorrentRequestInfo.h, src/TorrentRequestInfo.cc
(execute): Use toStream.
(showFileEntry): Removed.
* src/MetalinkRequestInfo.h
(targetFiles): New variable.
(setTargetFiles): New variable.
* src/MetalinkRequestInfo.cc
(execute): Added the ability to print file information included
in
a metalink file.
Added selective download mode to metalink.
* src/main.cc
(showUsage): Updated to denote that -S and --select-file options
are
applicable to metalink.
* src/FileEntry.h
(operator=): New function.
(getBasename): New function.
(getDirname): New function.
* src/Util.h, src/Util.cc
(toStream): New function.
* src/Xml2MetalinkProcessor.cc: Updated.
Made aria2 work with metalink with directory structure.
* src/File.h, src/File.cc
(getBasename): New function.
(getDirname): New function.
* src/RequestGroup.h, src/RequestGroup.cc
(_topDir): New variable.
(setTopDir): New function.
(initSegmentMan): A directory structure is added to
_segmentMan->dir.
Rewrote HTTP header parsing with stringstream.
* src/HttpConnection.h, src/HttpConnection.cc
(HttpRequestEntry): New class.
(headerBuf): Removed.
(headerBufLength): Removed.
(outstandingHttpRequests): Now its element type is
HttpRequestEntryHandle.
(findEndOfHeader): Removed.
(receiveResponse): Rewritten.
Updated doc for -j option to notice that it should be used with
-i
option.
* src/main.cc (showUsage)
Removed unused classes.
* src/RequestInfo.h
(FileInfo): Removed.
(checksum): Removed.
(fileInfo): Removed.
(setChecksum): Removed.
(getChecksum): Removed.
(getFileInfo): Removed.
Use ISO units.
* src/ConsoleDownloadEngine.cc
* src/TorrentConsoleDownloadEngine.cc
* src/Util.cc (abbrevSize)
To the ability to read options from a config file:
* src/main.cc: Command-line parameter validation is delegated to
OptionHandler class.
* src/OptionHandlerFactory.h, src/OptionHandlerFactory.cc: New
class.
* src/Option.h, src/Option.cc (clear): New function.
* src/OptionParser.h, src/OptionParser.cc: New class.
* src/OptionHandler.h: New class.
* src/NameMatchOptionHandler.h: New class.
* src/OptionHandlerImpl.h: New classes.
* src/prefs.h: '_' -> '-'
(FTP_PASV_ENABLED): Renamed to FTP_PASV.
(FTP_PASV): New definition.
* src/Util.h, src/Util.cc (getRealSize): New function.
To disable netrc support if .netrc file does not have correct
permissions:
* src/File.h, src/File.cc (mode): New function.
To prevent confidential information to be logged:
* src/HttpConnection.h, src/HttpConnection.cc
(eraseConfidentialInfo): New function.
(sendRequest): Call eraseConfidentialInfo().
(sendProxyRequest): Call eraseConfidentialInfo().
* src/main.cc: Validate permissions of .netrc file.
To add --user-agent command-line option:
* src/main.cc: Added new command line option: --user-agent
* src/prefs.h (PREF_USER_AGENT): New definition.
* src/HttpRequestCommand.cc (executeInternal): Set user-agent
option
parameter to HttpRequest object.
Marged the patches from Dan Fandrich.
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.
* src/HttpHeader.h
(Range.h): New include.
(status): New variable.
(HttpHeader): Initialized status with 0.
(getStatus): New function.
(setStatus): New function.
(getRange): New function.
(HttpHeaderHandle): New function.
* src/HttpHeader.cc
(getRange): New function.
* src/Request.h
(RequestWeakHandle): New definition.
* src/HttpConnection.h
(HttpConnectionHandle): New type definition.
* src/HttpConnection.cc
(receiveResponse): Set HTTP status to headers.
* src/main.cc
(showUsage): Fixed typo.
* src/Segment.h
(SegmentHandle): New type definition.
* src/BitfieldMan.h
(getMissingUnusedLength): New function.
* src/BitfieldMan.cc
(getMissingUnusedLength): New function.
To rewrite segment download mechanism for HTTP/FTP download.
Use BitfieldMan to manage segment download.
* src/HttpResponseCommand.h
(executeInternal): Pass the reference of segment.
* src/AbstractCommand.cc
(prepareForRetry): Call segmentMan->cancelSegment here.
(onAbort): Call segmentMan->cancelSegment here.
* src/HttpDownloadCommand.cc
(prepareForNextSegment): New function.
* src/DownloadEngineFactory.cc
(newConsoleEngine): Removed splitter.
(newTorrentConsoleEngine): Removed splitter.
* src/Request.h
(segment): Renamed from seg.
* src/FtpInitiateConnectionCommand.h
(executeInternal): Pass the reference of segment.
* src/AbstractCommand.h
(executeInternal): Pass the reference of segment.
* src/pref.h
(PREF_SEGMENT_SIZE): New definition.
* src/HttpProxyRequestCommand.h
(executeInternal): Pass the reference of segment.
* src/HttpResponseCommand.cc
(checkResponse): Allowed status 206 when a request range starts
0.
(handleDefaultEncoding): Rewritten the code related to Segment.
(handleOtherEncoding): Rewritten the code related to Segment.
* src/SegmentMan.h
(SegmentEntry): New class.
(SegmentEntries): New type definition.
(bitfield): New variable.
(usedSegmentEntries): New variable.
(onNullBitfield): New function.
(checkoutSegment): New function.
(segments): Removed.
(splitter): Removed.
(unregisterId): Removed.
(getSegment): New function(overload)
(getDownloadedSize): Removed.
(cancelSegment): New function.
(completeSegment): New function.
(initBitfield): New function.
(hasSegment): New function.
(getDownloadLength): New function.
* src/BitfieldMan.h
(getStartIndex): New function.
(getEndIndex): New function.
(getMissingUnusedIndex): New function(overload).
(getSparseMissingUnusedIndex): New function.
* src/BitfieldMan.cc
(getMissingIndexRandomly): Handle the last byte of bitfield
properly.
(getMissingUnusedIndex): New function(overload).
(Range): New class.
(getStartIndex): New function.
(getEndIndex): New function.
(getSparseMissingUnusedIndex): New function.
(isBitSetInternal): Return false if the given index is less than
0.
* src/HttpInitiateConnectionCommand.h
(executeInternal): Pass the reference of segment.
* src/FtpNegotiateCommand.h
(executeInternal): Pass the reference of segment.
* src/FtpNegotiateCommand.cc
(recvSize): Initialize bitfield here.
* src/FtpTunnelResponseCommand.h
(executeInternal): Pass the reference of segment.
* src/HttpConnection.cc
(createRequest): Rewritten range header processing.
* src/DownloadCommand.h
(executeInternal): Pass the reference of segment.
(prepareForRetry): Removed.
(prepareForNextSegment): Added an argument segment. Made it a
virtual
function.
* src/main.cc
(main): Set the initial value of PREF_SEGMENT_SIZE to 1MB.
* src/SegmentMan.cc
(SegmentMan): Added bitfield. Removed splitter.
(~SegmentMan): Added bitfield. Removed splitter.
(unregisterId): Removed.
(getSegment): Rewritten.
(updateSegment): Rewritten.
(save): Rewritten.
(read): Rewritten.
(finished): Rewritten.
(getDownloadedSize): Removed.
(initBitfield): New function.
(FindSegmentEntryByIndex): New function object.
(FindSegmentEntryByCuid): New function object.
(checkoutSegment): New function.
(onNullBitfield): New function.
(getSegment): New function(overload).
(CancelSegment): New function object.
(cancelSegment): New function.
(completeSegment): New function.
(hasSegment): New function.
(getDownloadLength): New function.
* src/FtpInitiateConnectionCommand.cc
(executeInternal): Load .aria2 file after hostname resolution
finishes.
* src/Segment.h: Rewritten.
* src/Segment.cc (operator<<): New function.
* src/HttpDownloadCommand.h
(prepareForNextSegment): New function.
* src/Request.cc
(resetUrl): Made segment null.
* src/DownloadEngine.cc
(~DownloadEngine): Call cleanQueue before deleting segmentMan.
* src/HttpProxyRequestCommand.h
(executeInternal): Pass the reference of segment.
* src/DownloadCommand.cc
(executeInternal): Rewritten the code related to Segment.
(prepareForRetry): Removed.
(prepareForNextSegment): Rewritten.
* src/FtpTunnelResponseCommand.h
(executeInternal): Pass the reference of segment.
To add HTTP 1.1 persistent connection support(experimental)
* src/HttpRequestCommand.cc
(executeInternal): Disable keep alive if it is disabled by
configuration.
* src/Request.h
(keepAlive): New variable.
(isKeepAlive): New function.
(setKeepAlive): New function.
* src/pref.h
(PREF_HTTP_KEEP_ALIVE): New definition.
* src/HttpResponseCommand.cc
(executeInternal): Check the remote server supports keep alive.
* src/HttpConnection.cc
(createRequest): Send "Connection: close" only if keep alive is
disabled.
* src/main.cc
(main):
Set the initial value(false) of PREF_KEEP_ALIVE to false.
To add max download speed limit:
* src/pref.h
(PREF_MAX_SPEED_LIMIT): New definition.
* src/PeerInteractionCommand.cc
(executeInternal): Added max download speed limit. Not tested
yet.
* src/SegmentMan.h
(PeerStats): New type definition.
(peerStats): New variable.
(registerPeerStat): New function.
(FindPeerStat): New function object.
(getPeerStat): New function.
(calculateDownloadSpeed): New function.
* src/SpeedCalc.h: New class.
* src/SpeedCalc.cc: New class.
* src/main.cc
(main):
Set the initial value of PREF_MAX_SPEED_LIMIT to 0(which means
the
download speed is not restricted).
* src/PeerStat.h: New class.
* src/SegmentMan.cc
(registerPeerStat): New function.
(calculateDownloadSpeed): New function.
* src/DownloadCommand.cc
(STARTUP_IDLE_TIME): New definition.
(DownloadCommand): Register peerStat to segmentMan. Call
peerStat->
downloadStart.
(~DownloadCommand): Call peerStat->downloadStop.
(executeInternal): Added download speed limitter. Rewritten
lowest
speed limitter.
* src/HttpConnection.cc
(receiveResponse): Fixed: eohIndex[headerBuf] ->
headerBuf[eohIndex].
* src/AbstractCommand.cc
(resolveHostname): Throw DlAbortEx if a name resolution failes.
Added hostname to the error message.
* src/ConsoleDownloadEngine.cc
(calculateStatistics): Initialize psize with dlSize.
* src/PieceMessage.cc
(receivedAction): Do not call peerInteraction->abortPiece here.
(onGotWrongPiece): Call peerInteraction->abortPiece here.
* src/BitfieldMan.h
(clearAllUseBit): New function.
(setAllUseBit): New function.
* src/BitfieldMan.cc
(clearAllBit): Do not clear useBitfield here.
(clearAllUseBit): New function.
(setAllUseBit): New function.
* src/Piece.cc
(clearAllBlock): Call bitfield->clearAllUseBit().
* src/SharedHandle.h: New class.
To wrap Socket, Command, PeerMessage and Peer with SharedHandle:
* src/HttpResponseCommand.h
(HttpResponseCommand): Wrapped Socket.
* src/SocketCore.h
(operator==): New function.
(operator!=): New function.
(operator<): New function.
(getSockfd): New function.
(isOpen): New function.
(writeData): New function.
* src/SocketCore.cc
(operator==): New function.
(operator!=): New function.
(operator<): New function.
* src/AbstractCommand.h
(socket): Changed its type to SocketHandle.
(setReadCheckSocket): Replaced Socket with SocketHandle.
(setWriteCheckSocket): Replaced Socket with SocketHandle.
(disableReadCheckSocket): New function.
(disableWriteCheckSocket): New function.
(readCheckTarget): Changed its type to SocketHandle.
(writeCheckTarget): Changed its type to SocketHandle.
(AbstractCommand): Replaced Socket with SocketHandle.
* src/AbstractCommand.cc
(AbstractCommand): Replaced Socket with SocketHandle.
(~AbstractCommand): Removed the deallocation for Socket object.
(disableReadCheckSocket): New function.
(setReadCheckSocket): Replaced Socket with SocketHandle.
(disableWriteCheckSocket): New function.
(setWriteCheckSocket): Replaced Socket with SocketHandle.
* src/HttpDownloadCommand.cc
(DownloadCommand): Replaced Socket with SocketHandle.
* src/PeerAbstractCommand.h
(socket): Changed its type to SocketHandle.
(peer): Changed its type to PeerHandle.
(setReadCheckSocket): Replaced Socket with SocketHandle.
(setWriteCheckSocket): Replaced Socket with SocketHandle.
(disableReadCheckSocket): New function.
(disableWriteCheckSocket): New function.
(readCheckTarget): Changed its type to SocketHandle.
(writeCheckTarget): Changed its type to SocketHandle.
(PeerAbstractCommand): Replaced Socket with SocketHandle.
Replaced Peer with PeerHandle.
* src/HttpRequestCommand.cc
(HttpRequestCommand): Replaced Socket with SocketHandle.
Use disableReadCheckSocket.
* src/PeerInitiateConnectionCommand.h
(PeerInitiateConnectionCommand): Replaced Peer with PeerHandle.
* src/PeerChokeCommand.cc
(UploadFaster::operator()): Replaced Peer with PeerHandle.
(DownloadFaster::operator()): Replaced Peer with PeerHandle.
(execute): Use PeerHandle.
* src/PeerConnection.h
(HandshakeMessage.h): Removed include of HandshakeMessage.h.
(socket): Changed its type to SocketHandle.
(PeerConnection): Replaced Socket with SocketHandle.
* src/PeerConnection.cc
(PeerConnection): Replaced Socket with SocketHandle.
* src/PeerInteractionCommand.h
(PeerInteractionCommand): Replaced socket with SocketHandle.
Replaced Peer with PeerHandle.
* src/PeerInteractionCommand.cc
(PeerInteractionCommand): Replaced Socket with SocketHandle.
Replaced Peer with PeerHandle.
(executeInternal): Use disableWriteCheckSocket.
Use HandshakeMessageHandle.
(receiveMessages): Use PeerMessageHandle.
(prepareForNextPeer): Use PeerHandle.
* src/HttpProxyRequestCommand.h
(HttpProxyRequestCommand): Replaced Socket with SocketHandle.
* src/HttpResponseCommand.cc
(HttpResponseCommand): Replaced Socket with SocketHandle.
* src/TorrentMan.cc
(nullPeer): Added external reference.
(~TorrentMan): Removed the deallocation of the elements of
peers.
(addPeer): Rewritten.
(isPeerAvailable): Use nullPeer.
(deleteOldpeers): Replaced with deleteErrorPeer.
(deleteErrorPeer): New function.
(getPeer): Use PeerHandle and nullPeer.
(hasMissingPiece): Replaced Peer with PeerHandle.
(getMissingPieceIndex): Replaced Peer with PeerHandle.
(getMissingFastPieceIndex): Replaced Peer with PeerHandle.
(getMissingFastPiece): Replaced Peer with PeerHandle.
(getMissingPiece): Replaced Peer with PeerHandle.
* src/FtpNegotiateCommand.cc
(FtpNegotiationCommand): Replaced Peer with PeerHandle.
(~FtpNegotiationCommand): Removed the deallocation of Sockets.
(recvGreeting): Use disableWriteCheckSocket.
(recvPasv): Removed the allocation of Socket.
Use disableReadCheckSocket.
(sendRestPasv): Use disableWriteCheckSocket.
(recvRetr): Changed assertion.
* src/PeerInteraction.h
(SharedHandle.h): Included SharedHandle.h.
(PeerMessageHandle): New type definition.
(HandshakeMessageHandle): New type definition.
(MessageQueue): Changed. Now its element is of type
PeerMessageHandle.
(peer): Changed its type to PeerHandle.
(createHandshakeMessage): Replaced HandshakeMessage with
HandshakeMessageHandle.
(createPeerMessage): Replaced PeerMessageHandle with
PeerMessage.
(PeerInteraction): Replaced Peer with PeerHandle.
Replaced Socket with SocketHandle.
(addMessage): Replaced PeerMessage with PeerMessageHandle.
(receiveMessage): Replaced PeerMessage with PeerMessageHandle.
(receiveHandshake): Replaced HandshakeMessage with
HandshakeMessageHandle.
* src/PeerInteraction.cc
(PeerInteraction): Replaced Peer with PeerHandle.
Replaced Socket with SocketHandle.
(~PeerInteraction): Removed the deallocation of the elements of
messageQueue.
(MsgPushBack::operator()): Replaced PeerMessage with
PeerMessageHandle.
(isSendingMessageInProgress): Replaced PeerMessage with
PeerMessageHandle.
(sendMessages): Use PeerMessageHandle. Removed try-catch block.
(addMessage): Replaced PeerMessage with PeerMessageHandle.
(rejectAllPieceMessageInQueue): Use PeerMessageHandle.
(rejectPieceMessageInQueue): Use PeerMessageHandle.
(abortPiece): Use PeerMessageHandle.
(receiveHandshake): Replaced HandshakeMessage with
HandshakeMessageHandle. Removed try-catch block.
(createHandshakeMessage): Replaced HandshakeMessage with
HandshakeMessageHandle.
(receiveMessage): Replaced PeerMessage with PeerMessageHandle.
Removed try-catch block.
(createPeerMessage): Replaced PeerMessage with
PeerMessageHandle.
* src/HttpProxyResponseCommand.cc
(HttpProxyRequestCommand): Replaced Socket with SocketHandle.
* src/FtpTunnelResponseCommand.h
(FtpTunnelResponseCommand): Replaced Socket with SocketHandle.
* src/HttpConnection.cc
(HttpConnection): Replaced Socket with SocketHandle.
* src/PeerAbstractCommand.cc
(PeerAbstractCommand): Replaced Socket with SocketHandle.
(~PeerAbstractCommand): Removed the deallocation of socket.
Use disableReadCheckSocket, disableWriteCheckSocket.
(disableReadCheckSocket): New function.
(setReadCheckSocket): Replaced Socket with SocketHandle.
(disableWriteCheckSocket): New function.
(setWriteCheckSocket): Replaced Socket with SocketHandle.
* src/InitiateConnectionCommandFactory.h: Corrected indentation.
* src/FtpTunnelRequestCommand.cc
(FtpTunnelRequestCommand): Replaced Socket with SocketHandle.
(~FtpTunnelRequestCommand): Corrected indentation.
* src/DownloadCommand.h
(DownloadCommand): Replaced Socket with SocketHandle.
* src/PeerListenCommand.cc
(PeerListenCommand): Removed the initialization of socket.
(~PeerListenCommand): Removed the deallocation of socket.
(bindPort): Use SocketHandle.
(execute): Use SocketHandle and PeerHandle.
* src/FtpDowndloadCommand.cc
(FtpDownloadCommand): Replaced Socket with SocketHandle.
(~FtpDownloadCommand): Removed the deallocation of ctrlSocket.
* src/main.cc
(main): Corrected indentation.
* src/HttpInitiateConnectionCommand.cc
(HttpInitiateConnectionCommand): Replaced Socket with
SocketHandle.
(executeInternal): Removed the allocation of socket.
* src/HttpRequestCommand.h
(HttpRequestCommand): Replaced Socket with SocketHandle.
* src/FtpNegotiationCommand.h
(dataSocket): Changed its type to SocketHandle.
(serverSocket): Changed its type to SocketHandle.
(FtpNegotiationCommand): Replaced Socket with SocketHandle.
* src/TorrentMan.h
(MAX_PEER_UPDATE): Removed.
(MAX_PEERS): New definition.
(Peers): The element is now of type PeerHandle.
(addPeer): Replaced Peer with PeerHandle. Removed 'duplicate'
argument.
(getPeer): Replaced Peer with PeerHandle.
(deleteOldErrorPeers): Removed.
(deleteErrorPeer): New function.
(hasMissingPiece): Replaced Peer with PeerHandle.
(getMissingPieceIndex): Replaced Peer with PeerHandle.
(getMissingPiece): Replaced Peer with PeerHandle.
(getMissingFastPieceIndex): Replaced Peer with PeerHandle.
(getMissingFastPiece): Replaced Peer with PeerHandle.
(addActivePeer): Replaced Peer with PeerHandle.
(deleteActivePeer): Replaced Peer with PeerHandle.
Added a check for the return value of find.
* src/FtpTunnelResponseCommand.cc
(FtpTunnelResponseCommand): Replaced Socket with SocketHandle.
* src/FtpInitiateConnectionCommand.cc
(executeInternal): Removed the allocation of socket.
* src/DownloadEngine.h
(Sockets): An element is now of type SocketHandle.
(SockCmdMap): A key is of type SocketHandle, a value is of type
int.
(CommandUuids): New type definition.
(rsockets): Changed its type to SockCmdMap.
(wsockets): Changed its type to SockCmdMap.
(addSocket): Rewritten.
(deleteSocket): Rewritten.
(addSocketForReadCheck): Rewritten.
(deleteSocketForReadCheck): Rewritten.
(addSocketForWriteCheck): Rewritten.
(deleteSocketForWriteCheck): Rewritten.
(PairFind): New template class.
* src/HttpDownloadCommand.h
(HttpDownloadCommand): Replaced Socket with SocketHandle.
* src/FtpConnection.cc
(FtpConnection): Replaced Socket with SocketHandle.
(sendPort): Removed the allocation of serverSocket. Removed
try-catch
block.
* src/InitiateConnectionCommandFactory.cc
(DlAbortEx.h): Included DlAbortEx.h.
(createInitiateConnectionCommand): Throw exception if the
protocol of
requested URI is not supported.
* src/Peer.cc
(nullPeer): Changed its type to PeerHandle.
(operator==): New function.
(operator!=): New function.
* src/Peer.h
(SharedHandle.h): Included SharedHandle.h.
(operator==): New function.
(operator!=): New function.
(Peer): Added the default constructor.
Use resetStatus() to initialize member variables.
(nullPeer): Removed.
* src/TrackerUpdateCommand.cc
(execute): Brushed up using SharedHandle. Replaced
MAX_PEER_UPDATE
with MIN_PEERS.
* src/PeerListenCommand.h
(socket): Changed its type to SocketHandle.
* src/Command.h
(CommandUuid): New type definition.
(uuid): New variable.
(uuidGen): New variable.
(Command): Added the initialization of uuid.
(getUuid): New function.
* src/Socket.h
(Socket): Removed.
(SocketHandle): New type definition.
* src/DownloadEngine.h
(FindCommand): New function object.
(run): The portion of socket check was rewritten.
(SetDescriptor): New function object.
(AccumulateActiveCommandUuid): New function object.
(waitData): Rewritten.
(addSocket): Rewritten.
(deleteSocket): Rewritten.
(addSocketForReadCheck): Rewritten.
(addSocketForWriteCheck): Rewritten.
(deleteSocketForReadCheck): Rewritten.
(deleteSocketForWriteCheck): Rewritten.
* src/HttpProxyResponseCommand.h
(HttpProxyResponseCommand): Replaced Socket with SocketHandle.
* src/HttpConnection.h
(socket): Changed its type to SocketHandle.
(HttpConnection): Replaced Socket with SocketHandle.
* src/PeerInitiateConnectionCommand.cc
(PeerInitiateConnectionCommand): Replaced Peer with PeerHandle.
(executeInternal): Removed the allocation of socket.
(prepareForNextPeer): Use PeerHandle.
* src/PeerMessage.h
(peer): Changed its type to PeerHandle.
(getPeer): Replaced Peer with PeerHandle.
(setPeer): Replaced Peer with PeerHandle.
* src/DownloadCommand.cc
(DownloadCommand): Replaced Socket with SocketHandle.
* src/FtpConnection.h
(socket): Changed its type to SocketHandle.
(FtpConnection): Replaced Socket with SocketHandle.
(sendPort); Replaced Socket with SocketHandle.
* src/FtpDowndloadCommand.h
(ctrlSocket): Changed its type to SocketHandle.
(FtpDownloadCommand): Replaced Socket with SocketHandle.
* src/HttpProxyRequestCommand.cc
(HttpProxyRequestCommand): Replaced Socket with SocketHandle.
* src/FtpTunnelRequestCommand.h
(FtpTunnelRequestCommand): Replaced Socket with SocketHandle.
etc
* src/PeerChokeCommand.h
(setAllPeerChoked): Removed.
(setAllPeerResetDelta): Removed.
* src/PeerChokeCommand.cc
(setAllPeerChoked): Removed.
(ChokePeer): New function object.
(setAllPeerResetDelta): Removed.
(ResetDelta): New function object.
(orderByDownloadRate): Fixed a bug: use DowloadFaster, not
UploadFaster
(execute): Show download speed when the local node is a seeder.
setAllPeerChoked and setAllPeerResetDelta were rewritten
using STL.
* src/TrackerWatcherCommand.h
(MIN_PEERS): Removed.
* src/TorrentMan.cc
(getPeer): Replaced MAX_PEER_UPDATE with MIN_PEERS.
* src/SocketCore.cc
(isReadable): Added secure to the condition.
* src/HttpConnection.cc
(receiveResponse): Fixed a bug that causes no response header
exception.
* src/Peer.h
(getFastSet): Fixed the return value type.
Each peer message has its own class.
* src/PendingMessages.h: Removed.
* src/PendingMessages.cc: Removed. The sending process was moved
to
each message class.
* src/RequestSlotMan.h: Removed.
* src/RequestSlotMan.cc: Removed. All functionarities were moved
to
SendMessageQueue.
* src/RequestMessage.h: New class.
* src/RequestMessage.cc: New class.
* src/CancelMessage.h: New class.
* src/CancelMessage.cc: New class.
* src/BitfieldMessage.h: New class.
* src/BitfieldMessage.cc: New class.
* src/ChokeMessage.h: New class.
* src/ChokeMessage.cc: New class.
* src/KeepAliveMessage.h: New class.
* src/KeepAliveMessage.cc: New class.
* src/PortMessage.h: New class.
* src/UnchokeMessage.h: New class.
* src/UnchokeMessage.cc: New class.
* src/PieceMessage.h: New class.
* src/PieceMessage.cc: New class.
* src/HaveMessage.h: New class.
* src/HaveMessage.cc: New class.
* src/BitfieldMessage.h: New class.
* src/BitfieldMessage.cc: New class.
* src/NotInterestedMessage.h: New class.
* src/NotInterestedMessage.cc: New class.
* src/InterestedMessage.h: New class.
* src/InterestedMessage.cc: New class.
* src/HandshakeMessage.h (sendMessageQueue): New variable.
(getSendMessageQueue): New function.
(setSendMessageQueue): New function.
* src/HandshakeMessage.cc: New class.
* src/PeerConnection.h (receiveMessage): Changed return value
and
arguments.
(receiveHandshake): Changed return value and arguments.
* src/PeerConnection.cc (receiveMessage): Do not create message
class
here.
(receiveHandshake): Do not create handshake class here.
* src/PeerInteractionCommand.h (peerConnection): Removed.
(piece): Removed.
(syncPiece): Removed.
(sendInterest): Removed.
(sendMessages): Removed.
(createRequestPendingMessage): Removed.
(checkPieceHash): Removed.
(erasePieceOnDisk): Removed.
(getNewPieceAndSendInterest): Removed.
(onGotNewPice): Removed.
(onGotWrongPiece): Removed.
* src/PeerInteractionCommand.cc (PeerInteractionCommand):
Removed peerConnection, piece.
(~PeerInteractionCommand): Removed peerConnection.
(executeInternal): Use sendMessageQueue instead of
peerConnection.
(syncPiece): Moved to SendMessageQueue.
(decideChoking): Removed PendingMessage.
(receiveMessage): Use sendMessageQueue instead of
peerConnection.
The action after receiving peer message was moved to each
message
class.
(onGotNewPice): Moved to SendMessageQueue.
(onGotWrongPiece): Moved to SendMessageQueue.
(getNewPieceAndSendInterest): Moved to SendMessageQueue.
(sendInterest): Moved to SendMessageQueue.
(createRequestPendingMessage): Removed.
(sendMessages): Moved to SendMessageQueue.
(onAbort): Use SendMessageQueue::abortPiece()
(keepAlive): Use sendMessageQueue instead of peerConnection.
(beforeSocketCheck): Use sendMessageQueue instead of
peerConnection.
(checkPieceHash): Moved to SendMessageQueue.
(erasePieceOnDisk): Moved to SendMessageQueue.
* src/PeerMessageUtil.h
(createBitfieldMessage): Removed.
(createHaveMessage): Changed return value and arguments.
(createBitfieldMessage): Changed return value and arguments.
(createRequestCancelMessage): Removed.
(createPieceMessage): Changed return value and arguments.
(getShortIntParam): New function.
(checkIndex): Changed arguments.
(checkBegin): Changed arguments.
(checkLength): Changed arguments.
(checkPieceOffset): Removed.
(checkRange): New function.
(checkBitfield): Changed arguments.
(createPeerMessage): Removed.
(checkIntegrity): Removed.
(createHandshakeMessage): Changed arguments.
(createChokeMessage): New function.
(createUnchokeMessage): New function.
(createInterestedMessage): New function.
(createNotInterestedMessage): New function.
(createRequestMessage): New function.
(createCancelMessage): New function.
(createPortMessage): New function.
* src/PeerMessageUtil.cc
(createBitfieldMessage): Removed.
(createHaveMessage): Changed return value and arguments.
(createBitfieldMessage): Changed return value and arguments.
(createRequestCancelMessage): Removed.
(createPieceMessage): Changed return value and arguments.
(getShortIntParam): New function.
(checkIndex): Changed arguments.
(checkBegin): Changed arguments.
(checkLength): Changed arguments.
(checkPieceOffset): Removed.
(checkRange): New function.
(checkBitfield): Changed arguments.
(createPeerMessage): Removed.
(checkIntegrity): Removed.
(createHandshakeMessage): Changed arguments.
(createChokeMessage): New function.
(createUnchokeMessage): New function.
(createInterestedMessage): New function.
(createNotInterestedMessage): New function.
(createRequestMessage): New function.
(createCancelMessage): New function.
(createPortMessage): New function.
* src/PeerMessage.h
(id): Removed.
(index): Removed.
(begin): Removed.
(length): Removed.
(bitfield): Removed.
(bitfieldLength): Removed.
(block): Removed.
(blockLength): Removed.
(inProgress): New variable.
(cuid): New variable.
(peer): New variable.
(sendMessageQueue): New variable.
(logger): New variable.
(setBitfield): Removed.
(getBitfield): Removed.
(setBlock): Removed.
(getBlock): Removed.
(getBitfieldLength): Removed.
(getBlockLength): Removed.
(isInProgress): New function.
(toString): Made pure virtual.
(check): New function.
(send): New function.
(receivedAction): New function.
(getId): Made pure virtual.
(setId): Removed.
(getIndex): Removed.
(setIndex): Removed.
(getBegin): Removed.
(setBegin): Removed.
(getLength): Removed.
(setLength): Removed.
(getCuid): New function.
(setCuid): New function.
(getPeer): New function.
(setPeer): New function.
(getSendMessageQueue): New function.
(setSendMessageQueue): New function.
(ID): Removed.
* src/PeerMessage.cc
(setBitfield): Removed.
(setBlock): Removed.
(toString): Removed.
* src/TorrentMan.h
(getPieceLength): New function.
(getPieceLength): New function.
* src/SendMessageQueue.h
(REQUEST_TIME_OUT): New definition.
(RequestSlots): New definition.
(MessageQueue): New definition.
(requestSlotMan): Removed.
(pendingMessages): Removed.
(requestSlots): New variable.
(messageQueue): New variable.
(torrentMan): New variable.
(peerConnection): New variable.
(peer): New variable.
(piece): New variable.
(getNewPieceAndSendInterest): New function.
(createPeerMessage): New function.
(createHandshakeMessage): New function.
(send): Made private.
(setPeerMessageCommonProperty): New function.
(deleteAllRequestSlot): New function.
(deleteRequestMessageInQueue): New function.
(cancelAllRequest): Made private.
(cancelAllRequest): Made private.
(countRequestSlot): Made private.
(addPendingMessage): Removed.
(deletePendingPieceMessage): Removed.
(deletePendingRequestMessage): Removed.
(addMessage): New function.
(deletePieceMessageInQueue): New function.
(deleteTimeoutRequestSlot): Changed argument.
(deleteCompletedRequestSlot): Changed argument.
(getCorrespoindingRequestSlot): Renamed to
getCorrespondingRequestSlot.
(getCorrespondingRequestSlot): New function.
(countPendingMessage): Removed.
(countMessageInQueue): New function.
(getTorrentMan): New function.
(getPeerConnection): New function.
(hasDownloadPiece): New function.
(getDownloadPiece): New function.
(setDownloadPiece): New function.
(syncPiece): New function.
(sendMessages): New function.
(sendNow): New function.
(trySendNow): New function.
(abortPiece): New function.
(sendHandshake): New function.
(receiveMessage): New function.
(receiveHandshake): New function.
(createRequestMessage): New function.
(createCancelMessage): New function.
(createPieceMessage): New function.
(createHaveMessage): New function.
(createChokeMessage): New function.
(createUnchokeMessage): New function.
(createInterestedMessage): New function.
(createNotInterestedMessage): New function.
(createBitfieldMessage): New function.
(createKeepAliveMessage): New function.
* src/SendMessageQueue.cc
(SendMessageQueue): Removed requestSlotMan.
Instantiated peerConnection here.
(~SendMessageQueue): Removed requestSlotMan.
Added deletion of peerConnection and the contents of
messageQueue.
(send): Updated according to the change of messageQueue.
(addPendingMessage): Renamed to addMessage.
(addMessage): New function.
(deletePendingPieceMessage): Renamed to
deletePieceMessageInQueue.
(deletePieceMessageInQueue): New function.
(deletePendingRequestMessage): Renamed to
deleteRequestMessageInQueue.
(deleteRequestMessageInQueue): New function.
(deleteRequestSlot): RequestSlotMan::deleteRequestSlot(...) was
moved
here.
(deleteTimeoutRequestSlot):
RequestSlotMan::deleteTimeoutRequestSlot
(...) was moved here.
(deleteAllRequestSlot):
RequestSlotMan::deleteAllRequestSlot(...) was
moved here.
(deleteCompletedRequestSlot):
RequestSlotMan::deleteCompletedRequestSlot(...) was moved here.
(getCorrespondingRequestSlot):
RequestSlotMan::getCorrespoindingRequestSlot(...) was moved
here.
And renamed to getCorrespondingRequestSlot, correcting a typo.
(countPendingMessage): Renamed to countMessageInQueue.
(countMessageInQueue): New function.
(countRequestSlot): RequestSlotMan::countRequestSlot() was moved
here.
(receiveHandshake): New function.
(createHandshakeMessage): New function.
(receiveMessage): New function.
(createPeerMessage): New function.
(syncPiece): New function.
(getNewPieceAndSendInterest): New function.
(sendMessages): New function.
(sendNow): New function.
(trySendNow): New function.
(sendHandshake): New function.
(abortPiece): New function.
(getDownloadPiece): New function.
(getPeerMessageCommonProperty): New function.
(createRequestMessage): New function.
(createCancelMessage): New function.
(createPieceMessage): New function.
(createHaveMessage): New function.
(createChokeMessage): New function.
(createUnchokeMessage): New function.
(createInterestedMessage): New function.
(createNotInterestedMessage): New function.
(createBitfieldMessage): New function.
(createKeepAliveMessage): New function.
To add simple Content-Disposition support:
* src/HttpResponseCommand.h (determinFilename): New function.
* src/HttpResponseCommand.cc (executeInternal):
Use determinFilename(headers) instead of req->getFile() when
comparing
filename.
(determinFilename): New function.
(handleDefaultEncoding): Use determinFilename(headers) instead
of
req->getFile().
(handleOtherEncoding): Use determinFilename(headers) instead of
req->getFile().
* src/Util.h (getContentDispositionFilename): New function.
* src/Util.cc (getContentDispositionFilename): New function.
* src/LogFactory.h (release): New function.
* src/LogFactory.cc (release): New function.
To fix a bug that causes out-of-bound exception when HTTP status
line is wrong:
* src/HttpConnection.cc (receiveResponse): Added a check for
header
size.
* src/common.h (Deleter): New class.
* src/SegmentMan.cc
(~SegmentMan): Added deletion of splitter and diskWriter.
* src/DownloadEngine.h
(Commands): Use deque.
(clearQueue): New function.
* src/DownloadEngine.cc
(~DownloadEngine): Added deletion of segmentMan.
(cleanQueue): New function.
* src/TorrentDownloadEngine.h
(TorrentDownloadEngine): The implementation was moved to
TorrentDownloadEngine.cc.
(~TorrentDownloadEngine): The implementation was moved to
TorrentDownloadEngine.cc.
* src/TorrentDownloadEngine.cc
(~TorrentDownloadEngine): Added deletion of torrentMan.
* src/main.cc
(clearRequest): Removed.
(handler): Added deletion of e.
(torrentHandler): Added deletion of te.
(main): Do not share splitter.
Use Deleter instead of clearRequest.
Deletion of classes were updated.
CompactTrackerResponseProcessor:
* src/TrackerWatcherCommand.h (req): Removed.
* src/TrackerWatcherCommand.cc (execute): Send a request to
tracker
if the number of peer connections are less than 30.
* src/ByteArrayDiskWriter.h (readData): Implemented.
* src/SegmentMan.h (diskWriter): New function.
* src/SegmentMan.cc (init): Added a call to
diskWriter->closeFile()
* src/main.cc : Removed #include
"CompactTrackerResponseProcessor.h"
(main): Use TrackerUpdateCommand.
* src/TorrentMan.h (CompactTrackerResponseProcessor): Removed.
(req): New variable.
(setTrackerResponseProcessor): Removed.
(getTrackerResponseProcessor): Removed.
(processTrackerResponse): Removed.
* src/DownloadEngine.h (diskWriter): Removed.
* src/TorrentDownloadEngine.cc (afterEachIteration): Removed a
call
to torrentMan->processTrackerResponse().
To add Util::expandBuffer:
* src/ByteArrayDiskWriter.h (expandBuffer): Removed.
* src/ByteArrayDiskWriter.cc (writeData): Use
Util::expandBuffer().
* src/Util.h (expandBuffer): New function.
To fix the bug that causes segmentation fault when "-l ." is
specified
in command-line option:
* src/SimpleLogger.h (SimpleLogger): Removed "filename"
argument.
(openFile): New function.
(closeFile): New function.
* src/SimpleLogger.cc (SimpleLogger): Removed fopen.
(~SimpleLogger): Call closeFile();
* src/LogFactory.cc (getInstance): Added a call to
slogger->openFile().
* src/main.cc (main): Added a check to see logger is configured
properly.
To enable HTTP authentication without specifying
"--http-auth-scheme"
* src/prefs.h (PREF_HTTP_AUTH_ENABLED): New definition.
* src/HttpConnection.cc (createRequest): Send Authorization
header
if PREF_HTTP_AUTH_ENABLED == V_TRUE.
* src/main.cc (main): Preset PREF_HTTP_AUTH_SCHEME to V_TRUE
If "--http-user" is specified, set PREF_HTTP_AUTH_ENABLED to
V_TRUE
* src/Peer.cc (shouldChoke): Updated algorithm.
* src/message.h (EX_AUTH_FAILED): New definition.
(EX_FILE_OPEN): New definition.
* src/HttpResponseCommand.cc (checkResponse): Throw DlAbortEx
if status == 401.
(handleDefaultEncoding): Added a call to
diskWriter->initAndOpenFile()
if req->isTorrent == true.
* src/main.cc (handler): Removed the check to see e->diskWriter
!= NULL
(torrentHandler): Removed the check to see diskAdaptor != NULL.
* src/AbstractDiskWriter.cc (openExistingFile): Updated
messsage.
(createFile): Updated message.
* 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.