Commit Graph

44 Commits (2ca98cc428e03dc30ab9f4a89b7e39aaa45ef57e)

Author SHA1 Message Date
Tatsuhiro Tsujikawa 79876af88f Removed util::endsWith(a, b). Added util::iendsWith() 2011-11-05 00:25:24 +09:00
Tatsuhiro Tsujikawa ea1b4b3ee5 Eliminated SocketCore::peekData() form HTTP/FTP downloads.
We introduced SocketRecvBuffer which buffers received bytes. Since
HTTP response header and response body are divided with \r\n, we have
to buffer up several bytes to find this delimiter. We use
SocketRecvBuffer to hold these bytes and only consumes header and
passes SocketRecvBuffer, which may contain head of response body, to
next Command.  Since FTPConnection doesn't use SocketCore::peekData(),
we left it as is.
2011-01-16 16:55:41 +09:00
Tatsuhiro Tsujikawa 1372ac51ad 2010-11-14 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added .cc file for classes/structs that only provided by header
	file. Defined non-POD classes' ctor, dtor in .cc file.  Moved
	implementation code in header file to .cc file for major
	classes/strucsts.
2010-11-14 07:17:55 +00:00
Tatsuhiro Tsujikawa efbfe4c006 2010-09-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Data from remote server in HTTP/FTP download are now written to
	the disk(or memory) through StreamFilter. Decoding chunked and
	gziped streams are done cascading StreamFilter.
	Removed inefficient 1byte read code.
	* src/ChunkedDecodingStreamFilter.cc
	* src/ChunkedDecodingStreamFilter.h
	* src/DownloadCommand.cc
	* src/DownloadCommand.h
	* src/GZipDecodingStreamFilter.cc
	* src/GZipDecodingStreamFilter.h
	* src/HttpConnection.cc
	* src/HttpDownloadCommand.cc
	* src/HttpResponse.cc
	* src/HttpResponse.h
	* src/HttpResponseCommand.cc
	* src/HttpResponseCommand.h
	* src/HttpSkipResponseCommand.cc
	* src/HttpSkipResponseCommand.h
	* src/Makefile.am
	* src/NullSinkStreamFilter.cc
	* src/NullSinkStreamFilter.h
	* src/RequestGroup.cc
	* src/SinkStreamFilter.cc
	* src/SinkStreamFilter.h
	* src/StreamFilter.cc
	* src/StreamFilter.h
	* test/ChunkedDecodingStreamFilterTest.cc
	* test/GZipDecodingStreamFilterTest.cc
	* test/HttpResponseTest.cc
	* test/Makefile.am
	* test/MockSegment.h
2010-09-06 14:29:36 +00:00
Tatsuhiro Tsujikawa 332a5bd4a1 2010-07-16 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Reverted previous change and fixed it in a right way.
	* src/HttpDownloadCommand.cc
2010-07-16 16:19:45 +00:00
Tatsuhiro Tsujikawa 3886919101 2010-07-16 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Make sure that all decoders are finished to pool socket
	* src/HttpDownloadCommand.cc
2010-07-16 15:19:46 +00:00
Tatsuhiro Tsujikawa 8274432f14 2010-07-12 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Set end byte in Range header if start byte > 0 to get more chance
	to pool socket.
	* src/DefaultPieceStorage.cc
	* src/DefaultPieceStorage.h
	* src/DownloadCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/PieceStorage.h
	* src/UnknownLengthPieceStorage.h
	* test/DefaultPieceStorageTest.cc
	* test/HttpRequestTest.cc
	* test/MockPieceStorage.h
2010-07-12 11:55:23 +00:00
Tatsuhiro Tsujikawa f3b097b5af 2010-07-11 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that segments are not filled to
	Request::getMaxPipelinedRequest().
	Make sure that trailing data of transfer encoding is read propery,
	after file data is received.
	* src/AbstractCommand.cc
	* src/DownloadCommand.cc
	* src/DownloadCommand.h
	* src/FtpDownloadCommand.cc
	* src/FtpDownloadCommand.h
	* src/HttpDownloadCommand.cc
	* src/HttpDownloadCommand.h
2010-07-11 14:21:17 +00:00
Tatsuhiro Tsujikawa ca4940622c 2010-06-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Changed naming standards for class member variable: now it looks
	like var_ instead of _var.
2010-06-21 13:51:56 +00:00
Tatsuhiro Tsujikawa 970e7f95a6 2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variable private. Added accessor funcs.
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/AbstractProxyRequestCommand.cc
	* src/AbstractProxyRequestCommand.h
	* src/AbstractProxyResponseCommand.cc
	* src/AbstractProxyResponseCommand.h
	* src/CreateRequestCommand.cc
	* src/DownloadCommand.cc
	* src/DownloadCommand.h
	* src/FtpDownloadCommand.cc
	* src/FtpDownloadCommand.h
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/FtpNegotiationCommand.h
	* src/FtpTunnelRequestCommand.cc
	* src/FtpTunnelResponseCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpProxyRequestCommand.cc
	* src/HttpProxyResponseCommand.cc
	* src/HttpRequestCommand.cc
	* src/HttpResponseCommand.cc
	* src/HttpResponseCommand.h
	* src/HttpSkipResponseCommand.cc
	* src/InitiateConnectionCommand.cc
2010-06-09 12:43:44 +00:00
Tatsuhiro Tsujikawa 9afc36152a 2010-06-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made protected member variables of Command private. Added accessor
	funcs.
2010-06-08 15:02:20 +00:00
Tatsuhiro Tsujikawa 7cd9b21937 2010-06-08 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Made public member variables of DownloadEngine private. Added
	accessor funcs.
2010-06-08 14:11:36 +00:00
Tatsuhiro Tsujikawa 92f84f71f5 2010-05-21 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that connection pooling does not take into account
	proxy.  This means that when connection A via proxy X is pooled,
	it will be wrongly reused in the download using proxy Y.
	* src/DownloadEngine.cc
	* src/DownloadEngine.h
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpResponseCommand.cc
	* src/HttpSkipResponseCommand.cc
2010-05-21 13:54:50 +00:00
Tatsuhiro Tsujikawa bf5f559c5c 2010-03-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use cuid_t type for cuid.
2010-03-20 14:30:36 +00:00
Tatsuhiro Tsujikawa c342bde962 2010-02-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Use vector instead of deque for containers which is used for
	mostly read-only purpose.
2010-02-28 12:30:11 +00:00
Tatsuhiro Tsujikawa e237a6ebda 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Pool connection if _contentEncodingDecoder is used and server
	supports persistent connection.
	* src/HttpDownloadCommand.cc
2010-01-06 13:02:10 +00:00
Tatsuhiro Tsujikawa 4db349c1f3 2010-01-06 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Untabify. Fixed one line in copyright which is longer than 80
	columns.
	* src
	* test
2010-01-05 16:01:46 +00:00
Tatsuhiro Tsujikawa 2a2c8c5da0 2009-07-04 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
If pipelining is enabled, we can always pool socket.
	* src/HttpDownloadCommand.cc
2009-07-04 10:22:44 +00:00
Tatsuhiro Tsujikawa cf19dce855 2009-07-01 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
HTTP pipelining is now working. Fixed Segmention fault in
	BitfieldMan's copy ctor.	
	* src/AbstractCommand.cc
	* src/BitfieldMan.cc
	* src/BitfieldMan.h
	* src/DownloadCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpRequest.cc
	* src/SegmentMan.cc
	* src/SegmentMan.h
	* test/BitfieldManTest.cc
	* test/SegmentManTest.cc
2009-06-30 17:03:57 +00:00
Tatsuhiro Tsujikawa 5699b67526 2009-06-28 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Rewritten DownloadContext and removed SingleFileDownloadContext
	and BtContext and its derived classes. BitTorrent specific
	attributes are now set by DownloadContext::setAttribute() with key
	bittorrent::BITTORRENT.
	* src/AbstractBtMessage.cc
	* src/AbstractBtMessage.h
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/AbstractProxyRequestCommand.cc
	* src/AbstractProxyResponseCommand.cc
	* src/ActivePeerConnectionCommand.cc
	* src/ActivePeerConnectionCommand.h
	* src/AnnounceList.cc
	* src/BtCheckIntegrityEntry.cc
	* src/BtConstants.h
	* src/BtContext.h: Removed
	* src/BtDependency.cc
	* src/BtExtendedMessage.cc
	* src/BtPieceMessage.cc
	* src/BtPieceMessage.h
	* src/BtPostDownloadHandler.cc
	* src/BtRegistry.cc
	* src/BtRegistry.h
	* src/BtSetup.cc
	* src/CheckIntegrityCommand.cc
	* src/CheckIntegrityEntry.cc
	* src/ChecksumCheckIntegrityEntry.cc
	* src/ConsoleStatCalc.cc
	* src/ContentTypeRequestGroupCriteria.cc
	* src/DHTGetPeersCommand.cc
	* src/DHTGetPeersCommand.h
	* src/DHTPeerLookupTask.cc
	* src/DHTPeerLookupTask.h
	* src/DHTTaskFactory.h
	* src/DHTTaskFactoryImpl.cc
	* src/DHTTaskFactoryImpl.h
	* src/DefaultBtAnnounce.cc
	* src/DefaultBtAnnounce.h
	* src/DefaultBtContext.cc: Removed
	* src/DefaultBtContext.h: Removed
	* src/DefaultBtInteractive.cc
	* src/DefaultBtInteractive.h
	* src/DefaultBtMessageDispatcher.cc
	* src/DefaultBtMessageDispatcher.h
	* src/DefaultBtMessageFactory.cc
	* src/DefaultBtMessageFactory.h
	* src/DefaultBtMessageReceiver.cc
	* src/DefaultBtMessageReceiver.h
	* src/DefaultBtProgressInfoFile.cc
	* src/DefaultBtRequestFactory.cc
	* src/DefaultBtRequestFactory.h
	* src/DefaultExtensionMessageFactory.cc
	* src/DefaultExtensionMessageFactory.h
	* src/DefaultPeerStorage.cc
	* src/DefaultPeerStorage.h
	* src/DefaultPieceStorage.cc
	* src/DefaultSegmentManFactory.cc
	* src/DiskAdaptor.cc
	* src/DiskAdaptor.h
	* src/DownloadContext.cc
	* src/DownloadContext.h
	* src/DownloadEngine.cc
	* src/DownloadEngineFactory.cc
	* src/DownloadHandler.cc
	* src/DownloadResult.h
	* src/FileAllocationCommand.cc
	* src/FileAllocationDispatcherCommand.cc
	* src/FileAllocationEntry.cc
	* src/FileEntry.h
	* src/FillRequestGroupCommand.cc
	* src/FtpDownloadCommand.cc
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/FtpTunnelRequestCommand.cc
	* src/FtpTunnelResponseCommand.cc
	* src/HandshakeExtensionMessage.cc
	* src/HandshakeExtensionMessage.h
	* src/HaveEraseCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpProxyRequestCommand.cc
	* src/HttpProxyResponseCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/HttpResponseCommand.cc
	* src/HttpServerBodyCommand.cc
	* src/HttpServerCommand.cc
	* src/HttpSkipResponseCommand.cc
	* src/InitiateConnectionCommandFactory.cc
	* src/InitiatorMSEHandshakeCommand.cc
	* src/InitiatorMSEHandshakeCommand.h
	* src/IteratableChecksumValidator.cc
	* src/IteratableChecksumValidator.h
	* src/IteratableChunkChecksumValidator.cc
	* src/MSEHandshake.cc
	* src/MSEHandshake.h
	* src/Makefile.am
	* src/Makefile.in
	* src/Metalink2RequestGroup.cc
	* src/MetalinkPostDownloadHandler.cc
	* src/MultiDiskAdaptor.cc
	* src/MultiDiskAdaptor.h
	* src/MultiFileAllocationIterator.cc
	* src/MultiUrlRequestInfo.cc
	* src/PeerChokeCommand.cc
	* src/PeerChokeCommand.h
	* src/PeerInitiateConnectionCommand.cc
	* src/PeerInitiateConnectionCommand.h
	* src/PeerInteractionCommand.cc
	* src/PeerInteractionCommand.h
	* src/PeerReceiveHandshakeCommand.cc
	* src/PieceHashCheckIntegrityEntry.cc
	* src/RealtimeCommand.cc
	* src/ReceiverMSEHandshakeCommand.cc
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupEntry.cc
	* src/RequestGroupMan.cc
	* src/SeedCheckCommand.cc
	* src/SeedCheckCommand.h
	* src/SegmentMan.cc
	* src/ShareRatioSeedCriteria.h
	* src/SingleFileDownloadContext.cc: Removed
	* src/SingleFileDownloadContext.h: Removed
	* src/SleepCommand.cc
	* src/StreamCheckIntegrityEntry.cc
	* src/TrackerWatcherCommand.cc
	* src/TrackerWatcherCommand.h
	* src/UnknownLengthPieceStorage.cc
	* src/Util.cc
	* src/Util.h
	* src/XmlRpcMethodImpl.cc
	* src/bittorrent_helper.cc
	* src/bittorrent_helper.h
	* src/download_helper.cc
	* src/main.cc
	* src/option_processing.cc
	* test/BitfieldManTest.cc
	* test/BittorrentHelperTest.cc
	* test/BtCancelMessageTest.cc
	* test/BtChokeMessageTest.cc
	* test/BtDependencyTest.cc
	* test/BtPieceMessageTest.cc
	* test/BtPostDownloadHandlerTest.cc
	* test/BtRegistryTest.cc
	* test/BtRejectMessageTest.cc
	* test/BtRequestMessageTest.cc
	* test/DHTPeerAnnounceStorageTest.cc
	* test/DefaultBtAnnounceTest.cc
	* test/DefaultBtContextTest.cc: Removed
	* test/DefaultBtMessageDispatcherTest.cc
	* test/DefaultBtMessageFactoryTest.cc
	* test/DefaultBtProgressInfoFileTest.cc
	* test/DefaultBtRequestFactoryTest.cc
	* test/DefaultExtensionMessageFactoryTest.cc
	* test/DefaultPeerStorageTest.cc
	* test/DefaultPieceStorageTest.cc
	* test/DirectDiskAdaptorTest.cc
	* test/DownloadContextTest.cc
	* test/DownloadHandlerFactoryTest.cc
	* test/DownloadHelperTest.cc
	* test/HandshakeExtensionMessageTest.cc
	* test/HttpRequestTest.cc
	* test/HttpResponseTest.cc
	* test/IteratableChecksumValidatorTest.cc
	* test/IteratableChunkChecksumValidatorTest.cc
	* test/MSEHandshakeTest.cc
	* test/Makefile.am
	* test/Makefile.in
	* test/Metalink2RequestGroupTest.cc
	* test/MetalinkPostDownloadHandlerTest.cc
	* test/MockBtContext.h: Removed
	* test/MockDHTTaskFactory.h
	* test/MockDownloadContext.h: Removed
	* test/MockPieceStorage.h
	* test/MultiDiskAdaptorTest.cc
	* test/MultiFileAllocationIteratorTest.cc
	* test/RequestGroupManTest.cc
	* test/RequestGroupTest.cc
	* test/SegmentManTest.cc
	* test/ShareRatioSeedCriteriaTest.cc
	* test/SingleFileDownloadContextTest.cc: Removed
	* test/UtilTest.cc
	* test/XmlRpcMethodTest.cc
2009-06-28 10:37:15 +00:00
Tatsuhiro Tsujikawa 90471d6805 2009-06-24 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added experimental support of WEB-Seeding for multi-file torrent.
	Due to fundamental changes in file handling in HTTP/FTP code, many
	functions are not working: PeerStat, ServerHost, proxy..etc
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/BitfieldMan.cc
	* src/BitfieldMan.h
	* src/CreateRequestCommand.cc
	* src/CreateRequestCommand.h
	* src/DefaultPieceStorage.cc
	* src/DefaultPieceStorage.h
	* src/DownloadCommand.cc
	* src/DownloadCommand.h
	* src/DownloadContext.cc
	* src/DownloadContext.h
	* src/FileEntry.cc
	* src/FileEntry.h
	* src/FtpDownloadCommand.cc
	* src/FtpDownloadCommand.h
	* src/FtpFinishDownloadCommand.cc
	* src/FtpFinishDownloadCommand.h
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpInitiateConnectionCommand.h
	* src/FtpNegotiationCommand.cc
	* src/FtpNegotiationCommand.h
	* src/FtpTunnelResponseCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpDownloadCommand.h
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpInitiateConnectionCommand.h
	* src/HttpProxyResponseCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/HttpRequestCommand.h
	* src/HttpResponseCommand.cc
	* src/HttpResponseCommand.h
	* src/HttpSkipResponseCommand.cc
	* src/HttpSkipResponseCommand.h
	* src/InitiateConnectionCommand.cc
	* src/InitiateConnectionCommand.h
	* src/InitiateConnectionCommandFactory.cc
	* src/InitiateConnectionCommandFactory.h
	* src/Makefile.am
	* src/PieceStorage.h
	* src/RequestGroup.cc
	* src/RequestGroup.h
	* src/RequestGroupMan.cc
	* src/SegmentMan.cc
	* src/SegmentMan.h
	* src/SingleFileDownloadContext.h
	* src/StreamFileAllocationEntry.cc
	* src/TrackerWatcherCommand.cc
	* src/UnknownLengthPieceStorage.cc
	* src/UnknownLengthPieceStorage.h
	* src/array_fun.h
	* src/bitfield.h
	* src/download_helper.cc
	* test/DownloadContextTest.cc
	* test/Makefile.am
	* test/MockDownloadContext.h
2009-06-23 15:35:45 +00:00
Tatsuhiro Tsujikawa 997a0c29d1 2009-02-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Changed the default value of --proxy-method option from 'tunnel'
	to 'get'. Use 'tunnel' for HTTPS regardless of --proxy-method
	option.
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/FtpInitiateConnectionCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpInitiateConnectionCommand.h
	* src/OptionHandlerFactory.cc
2009-02-07 13:46:08 +00:00
Tatsuhiro Tsujikawa c34ac25683 2009-01-16 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed compile warning/error.
	* src/DownloadResult.h
	* src/HttpDownloadCommand.cc
	* src/ServerStat.cc
	* test/RequestGroupTest.cc
2009-01-15 15:39:05 +00:00
Tatsuhiro Tsujikawa 5a639a3d1e 2008-12-16 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that causes corrupted downloads if HTTP pipelining
	is enabled and the server doesn't support keep-alive.
	* src/AbstractCommand.cc
	* src/DownloadCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpDownloadCommand.h
	* src/HttpResponseCommand.cc
	* src/Request.cc
	* src/Request.h
	* test/RequestTest.cc
2008-12-15 15:38:07 +00:00
Tatsuhiro Tsujikawa 93a49e4840 2008-11-05 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added the ability to pool proxy connection.
	The conneciton in FTP with proxy-method=GET is not pooled.
	Proxy-Connection header will not be sent when sending CONNECT
	method.
	* src/DownloadEngine.cc
	* src/DownloadEngine.h
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpNegotiationCommand.cc
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpResponse.cc
	* src/HttpSkipResponseCommand.cc
	* test/HttpRequestTest.cc
	* test/HttpResponseTest.cc
2008-11-05 12:30:22 +00:00
Tatsuhiro Tsujikawa c7fb678e6e 2008-11-04 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Deprecated --http-proxy-user and --http-proxy-passwd options.
	Added --https-proxy, --ftp-proxy and --all-proxy options.
	Above 3 options and --http-proxy option can handle proxy in URL
	format like: http://user:passwd@host:port.
	If a proxy requires user/password, they must be specified in a
	URL.
	Deprecated --ftp-via-http-proxy option. Use --http-proxy-method
	option instead.
	* src/AbstractCommand.cc
	* src/AbstractCommand.h
	* src/AbstractProxyRequestCommand.cc
	* src/AbstractProxyRequestCommand.h
	* src/AuthConfigFactory.cc
	* src/AuthConfigFactory.h
	* src/FtpFinishDownloadCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/FtpInitiateConnectionCommand.h
	* src/FtpNegotiationCommand.cc
	* src/FtpTunnelRequestCommand.cc
	* src/FtpTunnelRequestCommand.h
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpInitiateConnectionCommand.h
	* src/HttpProxyRequestCommand.cc
	* src/HttpProxyRequestCommand.h
	* src/HttpRequest.cc
	* src/HttpRequest.h
	* src/HttpRequestCommand.cc
	* src/HttpRequestCommand.h
	* src/HttpSkipResponseCommand.cc
	* src/InitiateConnectionCommand.cc
	* src/InitiateConnectionCommand.h
	* src/OptionHandlerFactory.cc
	* src/OptionHandlerImpl.h
	* src/Request.cc
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
	* test/AuthConfigFactoryTest.cc
	* test/HttpRequestTest.cc
	* test/OptionHandlerTest.cc
2008-11-04 14:08:26 +00:00
Tatsuhiro Tsujikawa 92c66d24ac 2008-07-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten ChunkedEncoding class as ChunkedDecoder class.
	* src/A2STR.cc
	* src/A2STR.h
	* src/ChunkedDecoder.cc
	* src/ChunkedDecoder.h
	* src/ChunkedEncoding.cc: Removed
	* src/ChunkedEncoding.h: Removed
	* src/DownloadCommand.cc
	* src/DownloadCommand.h
	* src/HttpDownloadCommand.cc
	* src/HttpResponse.cc
	* src/HttpResponse.h
	* src/HttpResponseCommand.cc
	* src/HttpSkipResponseCommand.cc
	* src/HttpSkipResponseCommand.h
	* src/Makefile.am
	* src/TransferEncoding.h: Removed
	* test/ChunkedDecoderTest.cc
	* test/ChunkedEncodingTest.cc: Removed
	* test/HttpResponseTest.cc
	* test/Makefile.am
2008-07-01 11:38:25 +00:00
Tatsuhiro Tsujikawa 53464fd0fc 2008-05-07 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
const SharedHandle<Request> -> const SharedHandle<Request>&
	* src/FtpDowndloadCommand.cc
	* src/FtpDowndloadCommand.h
	* src/HttpDownloadCommand.cc
	* src/HttpDownloadCommand.h
2008-05-06 15:14:14 +00:00
Tatsuhiro Tsujikawa 5f55bc197f 2008-04-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Reuse socket if the origin server supports HTTP keep-alive and
	--enable-http-keep-alive or --enable-http-pipelining is given.
	The current implementation doesn't reuse the connections 
established
	against proxy server.

	* src/AbstractCommand.cc
	* src/DownloadEngine.cc
	* src/DownloadEngine.h
	* src/HttpDownloadCommand.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/HttpResponseCommand.cc
2008-04-22 08:52:47 +00:00
Tatsuhiro Tsujikawa 1c7c6f9898 2008-04-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Rewritten HTTP keep-alive and pipelining routine.
	* src/AbstractCommand.cc
	* src/HttpConnection.cc
	* src/HttpDownloadCommand.cc
	* src/HttpRequest.cc
	* src/HttpRequestCommand.cc
	* src/HttpResponseCommand.cc
	* src/Request.cc
	* src/Request.h
	* src/RequestGroup.cc
	* test/HttpRequestTest.cc
	* test/HttpResponseTest.cc
	* test/RequestTest.cc
2008-04-22 07:15:35 +00:00
Tatsuhiro Tsujikawa 1b7c198289 2008-02-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Removed "using namespace std;" from all sources. Appended std:: 
prefix to c++
	standard classes.
	Included string.h where mem* function are used.
2008-02-08 15:53:45 +00:00
Tatsuhiro Tsujikawa 884a139e72 2007-10-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Added HTTP/1.1 keep alive and pipelining support.
	See --enable-http-keep-alive and --enable-http-pipelining 
option.
	* src/AbstractCommand.{h, cc}: Now it has one-to-many relation 
to
	Segment.
	* src/HttpDownloadCommand.{h, cc}
	* src/OptionHandlerFactory.cc
	* src/HttpConnection.{h, cc}
	* src/version_usage.cc
	* src/HttpInitiateConnectionCommand.cc
	* src/FtpInitiateConnectionCommand.cc
	* src/Segment.h
	* src/HttpRequestCommand.{h, cc}
	* src/option_processing.cc
	* src/prefs.h
	* src/HttpResponseCommand.cc
	* src/SegmentMan.{h, cc}
	* src/FtpNegotiateCommand.cc
	* src/HttpProxyResponseCommand.cc
	* src/Request.cc
	* src/HttpRequest.cc
	* src/DownloadCommand.cc
	* test/HttpRequestTest.cc
	* test/RequestTest.cc
2007-10-17 16:26:51 +00:00
Tatsuhiro Tsujikawa 048a2cf597 2007-10-12 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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.
2007-10-11 16:58:24 +00:00
Tatsuhiro Tsujikawa ccdd5b31a3 2007-06-01 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/FileAllocationCommand.cc: Derived from RealtimeCommand.
	* src/CheckIntegrityCommand.cc: Derived from RealtimeCommand.
	
	* src/MetalinkEntry.h
	(checksum): Changed to ChecksumHandle
	* src/MetalinkRequestInfo.cc
	(checksum): Changed to ChecksumHandle

	* src/File.cc
	(mkdirs): OPEN_MODE -> DIR_OPEN_MODE
	* src/common.h
	(DIR_OPEN_MODE): New definition

	* src/RequestGroup.cc
	(prepareForNextAction): Added an argument.

	* src/message.h
	(MSG_GOOD_CHECKSUM): New definition
	(MSG_BAD_CHECKSUM): New definition

	* src/HttpResponseCommand.cc
	(handleDefaultEncoding): Continue download sequence in new
	non-segmented download.

	* src/FileAllocationEntry.h
	(_nextDownloadCommand): New variable.

	* src/DownloadCommand.cc
	(prepareForNextSegment): Create ChecksumCommand if checksum is
	available.	

	* src/RealtimeCommand.h, src/RealtimeCommand.cc: New class.

	* src/IteratableChecksumValidator.h,
	src/IteratableChecksumValidator.cc: New class.

	* src/ChecksumCommand.h, src/ChecksumCommand.cc: New class.
2007-05-31 15:56:20 +00:00
Tatsuhiro Tsujikawa eaf2d53a91 2007-05-20 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* Added the simultaneous download feature.
2007-05-20 13:51:52 +00:00
Tatsuhiro Tsujikawa 11907c175d 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
Tatsuhiro Tsujikawa c0fd1fff2a 2006-10-18 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Request -> RequestHandle:
	
	* src/HttpResponseCommand.h: Request->RequestHandle
	* src/AbstractCommand.cc: Request->RequestHandle
	* src/HttpDownloadCommand.cc: Request->RequestHandle
	* src/HttpRequestCommand.cc: Request->RequestHandle
	* src/FtpInitiateConnectionCommand.h: Request->RequestHandle
	* src/AbstractCommand.h: Request->RequestHandle
	* src/HttpProxyRequestCommand.h: Request->RequestHandle
	* src/HttpResponseCommand.cc: Request->RequestHandle
	* src/HttpInitiateConnectionCommand.h: Request->RequestHandle
	* src/FtpNegotiateCommand.cc: Request->RequestHandle
	* src/FtpTunnelResponseCommand.h: Request->RequestHandle
	* src/HttpConnection.h: Request->RequestHandle
	* src/HttpProxyResponseCommand.cc: Request->RequestHandle
	* src/InitiateConnectionCommandFactory.h: Request->RequestHandle
	* src/FtpTunnelResponseCommand.cc: Request->RequestHandle
	* src/DownloadCommand.h: Request->RequestHandle
	* src/FtpDowndloadCommand.cc: Request->RequestHandle
	* src/HttpInitiateConnectionCommand.cc: Request->RequestHandle
	* src/HttpRequestCommand.h: Request->RequestHandle
	* src/FtpNegotiateCommand.h: Request->RequestHandle
	* src/FtpTunnelResponseCommand.cc: Request->RequestHandle
	* src/FtpInitiateConnectionCommand.cc: Request->RequestHandle
	* src/HttpDownloadCommand.h: Request->RequestHandle
	* src/FtpConnection.cc: Request->RequestHandle
	* src/InitiateConnectionCommandFactory.cc: 
Request->RequestHandle
	* src/UrlRequestInfo.cc: Request->RequestHandle
	* src/HttpProxyResponseCommand.h: Request->RequestHandle
	* src/HttpConnection.h: Request->RequestHandle
	* src/DownloadCommand.cc: Request->RequestHandle
	* src/FtpConnection.h: Request->RequestHandle
	* src/FtpDowndloadCommand.h: Request->RequestHandle
	* src/HttpProxyRequestCommand.cc: Request->RequestHandle
	* src/FtpTunnelRequestCommand.h: Request->RequestHandle
	* src/Request.h
	(SharedHandle.h): New include.
	(RequestHandle): New type definition.
	(Requests): Redefined.
	
	To add MULTITRACKER support:

	* src/TrackerWatcherCommand.h
	(createRequestCommand): New function.
	* src/DownloadEngineFactory.cc
	(newTorrentConsoleEngine): Removed req.
	* src/prefs.h
	(PREF_TRACKER_MAX_TRIES): New definition.
	* src/TorrentMan.cc
	(TorrentMan): Removed req. Added trackerNumTry.
	(~TorrentMan): Removed req.
	(setupInternal1): Added announceList.
	* src/TorrentRequestInfo.cc
	(execute): Set PREF_MAX_TIRES to 1. The max number of tries for
	announces is now specified by PREF_TRACKER_MAX_TRIES.
	* src/main.cc
	(main): Added PREF_TRACKER_MAX_TRIES.
	* src/TorrentMan.h
	(Request.h): Removed.
	(AnnounceList.h): New include.
	(trackerNumTry): New variable.
	(req): Removed.
	(announceList): New variable.
	* src/TrackerWatcherCommand.cc
	(execute): Rewritten.
	(createRequestCommand): New function.
	* src/TrackerUpdateCommand.cc
	(execute): Updated with the use of AnnounceList.
	* src/AnnounceList.cc: New class.
	* src/AnnounceList.h: New class.
	
	To fix typo:

	* src/prefs.h
	(PREF_MAX_TRIES): max_try->max_tries

	To not to decode "+" as space in URL decode:

	* src/Util.cc
	(urldecode): Removed "+"->space decoding rule. Test case was 
updated.
2006-10-18 14:57:00 +00:00
Tatsuhiro Tsujikawa 1b5af8e829 2006-09-22 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* src/*.{h,cc}:
	Added an exception to the license which allows linking with 
OpenSSL.
2006-09-21 15:31:24 +00:00
Tatsuhiro Tsujikawa 2fb9b5be97 2006-09-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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().
2006-09-19 14:52:59 +00:00
Tatsuhiro Tsujikawa 524d664850 2006-07-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* 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.
2006-07-19 17:07:45 +00:00
Tatsuhiro Tsujikawa b1d46227d4 make string type argument const string& where possible 2006-04-19 17:49:03 +00:00
Tatsuhiro Tsujikawa 133f759a0d make socket parameter in *Command contructor const 2006-03-31 14:46:48 +00:00
Tatsuhiro Tsujikawa 40cb1ca9ce 2006-03-27 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
* configure.in: Added gnutls support. Added several CPP macros.
	* m4/openssl.m4: Added.
	* src/SocketCore.{h,cc}: Drop const quarifier from writeData(),
	readData(), peekData(). Added gnutls support.
	* src/HttpDownloadCommand.cc: Removed SleepCommand.h
	* src/TrackerWatcherCommand.{h,cc}: Added. This command creates
	TrackerInitCommand periodicaly(TorrentMan::minInterval).
	* src/TorrentMan.cc: Remove downloadedSize == 0 check from 
save().
	Instead, added a check for whether setup method has executed
	successfully.
	* src/TorrentMan.h: Added member vaiable setupComplete. Updated
	DEFAULT_ANNOUNCE_INTERVAL and DEFAULT_ANNOUNCE_MIN_INTERVAL to 
300.
	* src/Makefile.am: Updated.
	* src/messageDigest.h: Added. This is a macro calculating SHA1 
digest
	using whether OpenSSL or gcrypt, depending on the result of 
configure
	script.
	* src/ShaVisitor.{h,cc}: Removed direct	dependency on OpenSSL by 
using
	messageDigest.h. 
	* src/TorrentAutoSaveCommand.h: Removed unused variable cuid.
	* src/PeerListenCommand.cc: Added log about port binded 
successfully.
	Fixed memory leak.
	* src/main.cc: Added gnutls support. Replaced LIB_SSL with
	ENABLE_BITTORRENT where they are not related to OpenSSL but 
BitTorrent.
	Removed instantiation of TrackerInitCommand. Instead,
	TrackerWatcherCommand is instantiated and pushed to the command 
queue.
	* src/InitiateConnectionCommandFactory.cc: Replaced HAVE_LIBSSL 
with
	ENABLE_SSL.
	* src/Request.cc: Replaced HAVE_LIBSSL with ENABLE_SSL.
	* src/RequestSlotMan.cc:
	(deleteCompletedRequestSlot)
	If a piece is already acquired by another command, delete the 
request
	slots for the piece.
	* src/TrackerUpdateCommand.cc:
	(execute)
	Changed log level of MSG_TRACKER_WARNING_MESSAGE from info to 
warn.
	Added a check whether peer list is null.
	Fixed the bug that causes sending completed event to the tracker
	several times.
	* src/TrackerInitCommand.cc:
	(execute)
	Fixed the bug that causes sending completed event to the tracker
	several times.
	* src/AbstractDiskWriter.{h,cc}: Removed direct dependency on 
OpenSSL
	by using messageDigest.h.
	
	
2006-03-26  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	* PeerConnection.cc: Replaced log message "keep-alive" with
	"keep alive".
	* PeerInteractionCommand.{h,cc}: Close connection if peer is 
choking
	localhost long time.
	* TorrentMan.cc: When adding new peer with duplicate = true, if 
the
	number of peer list is equal to or grater than MAX_PEER_LIST, 
delete
	at most 100 failure entry from the list. If with duplicate = 
false,
	MAX_PEER_LIST is not checked.
	* PeerListenCommand.cc: Fixed the argument order of log message.

2006-03-25  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>

	* Logger.h: Moved enum LEVEL from SimpleLogger.h to here.
	Added warn().
	* SimpleLogger.h: Moved enum LEVEL to Logger.h.
	Implemented warn().
	Defined 2 macros(WRITE_LOG, WRITE_LOG_EX) to avoid duplicated 
code.
2006-03-27 14:47:26 +00:00
Tatsuhiro Tsujikawa 52634627bc Initial import 2006-02-17 13:35:04 +00:00