From ec2ce4ffe5ca6af1a509dcd5a4d8bf0d5644401d Mon Sep 17 00:00:00 2001 From: klemens Date: Mon, 20 Mar 2017 22:44:41 +0100 Subject: [PATCH 1/2] spelling fixes --- ChangeLog.old | 84 +++++------ Makefile.am | 2 +- import-po | 2 +- src/FeatureConfig.cc | 2 +- src/GZipDecodingStreamFilter.cc | 2 +- src/HttpConnection.h | 2 +- src/InitiateConnectionCommand.h | 2 +- src/PieceStorage.h | 2 +- src/SSHSession.h | 2 +- src/SegmentMan.h | 2 +- src/SocketCore.h | 4 +- src/TimeBasedCommand.h | 8 +- src/UnknownLengthPieceStorage.h | 2 +- src/crypto_endian.h | 2 +- test/GZipDecoder.cc | 2 +- test/HttpResponseTest.cc | 2 +- test/HttpResponseTest.cc.8905 | 246 ++++++++++++++++++++++++++++++++ 17 files changed, 307 insertions(+), 61 deletions(-) create mode 100644 test/HttpResponseTest.cc.8905 diff --git a/ChangeLog.old b/ChangeLog.old index dc72dbef..ef4d9440 100644 --- a/ChangeLog.old +++ b/ChangeLog.old @@ -2300,7 +2300,7 @@ Fixed the bug that segments are not filled to Request::getMaxPipelinedRequest(). - Make sure that trailing data of transfer encoding is read propery, + Make sure that trailing data of transfer encoding is read property, after file data is received. * src/AbstractCommand.cc * src/DownloadCommand.cc @@ -6119,7 +6119,7 @@ 2010-01-10 Tatsuhiro Tsujikawa - Added following sentance to the help message of --out option: + Added following sentence to the help message of --out option: --out option is ignored when -Z is used. * doc/aria2c.1.txt * src/usage_text.h @@ -8458,7 +8458,7 @@ 2009-07-15 Tatsuhiro Tsujikawa - Added 'errorCode' to the reponse of tellStatus xml-rpc method. + Added 'errorCode' to the response of tellStatus xml-rpc method. This key is only available for stopped/completed downloads and its value is the error code defined in EXIT STATUS in man page. * src/XmlRpcMethodImpl.cc @@ -10020,7 +10020,7 @@ 2009-05-22 Tatsuhiro Tsujikawa - Removed tellAll XML-RPC command because its reponse tends to be + Removed tellAll XML-RPC command because its response tends to be big if stopped/waiting downloads pile up. * src/XmlRpcMethodFactory.cc * src/XmlRpcMethodImpl.cc @@ -10455,7 +10455,7 @@ DefaultBtContext::setFileFileter(). PieceStorage::setFileFilter(), DiskAdaptor::addDownloadEntry() functions are removed because they are no longer used. Creating - filter in BitfieldMan is done in new funtion + filter in BitfieldMan is done in new function PieceStorage::setupFileFilter() * src/BtContext.cc * src/BtContext.h @@ -10513,7 +10513,7 @@ 2009-05-10 Tatsuhiro Tsujikawa The information for files, URIs, peers are removed from the - reponse of TellaActive, TellStatus command because they tend to be + response of TellaActive, TellStatus command because they tend to be large. Instead they can be retrieved by the dedicated commands: getFiles, getUris and getPeers respectively. * src/XmlRpcMethodFactory.cc @@ -10737,7 +10737,7 @@ 2009-05-08 Tatsuhiro Tsujikawa - Added xml-rpc functionality. Currently only addURI commad is + Added xml-rpc functionality. Currently only addURI command is supported. To enable xml-rpc, run aria2 with --enable-http-server. This option name is temporal and will be changed. The feature that reports download progress in html format @@ -13042,7 +13042,7 @@ Fixed the bug that BitTorrent download doesn't finish when REJECT message is received before CHOKE message. The old implementation - doen't clear the use-bit of the piece when recieved REJECT + doen't clear the use-bit of the piece when received REJECT message. * src/DefaultBtMessageDispatcher.cc * test/DefaultBtMessageDispatcherTest.cc @@ -13876,7 +13876,7 @@ 2008-11-11 Tatsuhiro Tsujikawa Fixed the bug that metalink file is not processed if Content-Type - field has a paramter. + field has a parameter. * src/HttpResponse.cc * src/HttpResponse.h * test/HttpResponseTest.cc @@ -13906,7 +13906,7 @@ 2008-11-09 Tatsuhiro Tsujikawa - Added usege for proxy. + Added usage for proxy. * doc/aria2c.1.txt 2008-11-09 Tatsuhiro Tsujikawa @@ -14004,7 +14004,7 @@ 2008-11-05 Tatsuhiro Tsujikawa Added the ability to pool proxy connection. - The conneciton in FTP with proxy-method=GET is not pooled. + The connection 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 @@ -14147,7 +14147,7 @@ 2008-11-03 Tatsuhiro Tsujikawa - Corrected catched exception type. + Corrected caught exception type. * src/ServerStatMan.cc 2008-11-03 Tatsuhiro Tsujikawa @@ -14403,7 +14403,7 @@ 2008-10-19 Tatsuhiro Tsujikawa Fixed the bug that aria2 aborts when a request larger than 16KiB is - recieved. + received. In this fix, if a request larger than 16KiB length is received, aria2 disconnects the peer. * src/BtConstants.h @@ -14674,7 +14674,7 @@ Fixed the bug that aria2 downloads faster than max-download-limit when downloading file using both HTTP(or FTP) and BitTorrent, because aria2 - evaluates speed separatly(HTTP and BiTorrent) against max-download-limit + evaluates speed separately(HTTP and BiTorrent) against max-download-limit , instead of sum of them. * src/ActivePeerConnectionCommand.cc * src/DefaultBtInteractive.cc @@ -14934,7 +14934,7 @@ 2008-09-14 Tatsuhiro Tsujikawa - If establishing conneciton to a server is failed, then mark error on + If establishing connection to a server is failed, then mark error on its ServerStat. Added the cause of error to log when error event occurred. Moved message string to message.h for translation. @@ -15163,7 +15163,7 @@ 2008-09-07 Tatsuhiro Tsujikawa - Added a constuctor that receives struct timeval. + Added a constructor that receives struct timeval. Added operator<. * src/TimeA2.cc * src/TimeA2.h @@ -15178,7 +15178,7 @@ 2008-09-07 Tatsuhiro Tsujikawa - Implmented the functions to parse date. + Implemented the functions to parse date. * src/TimeA2.cc * src/TimeA2.h * test/TimeTest.cc @@ -15410,7 +15410,7 @@ 2008-08-24 Tatsuhiro Tsujikawa - Added sqlite3 depenency and Firefox3 cookie support. + Added sqlite3 dependency and Firefox3 cookie support. * README 2008-08-24 Tatsuhiro Tsujikawa @@ -17791,7 +17791,7 @@ 2008-05-10 Tatsuhiro Tsujikawa - Print usage when no URL is specifed or bad command-line option is + Print usage when no URL is specified or bad command-line option is specified. * src/HelpItemFactory.cc * src/help_tags.h @@ -18050,7 +18050,7 @@ Rewritten Exception class. Throw exception object, not its pointer and catch by reference, so that remove problematic delete operator for - catched exception. + caught exception. * src/Exception.cc * src/Exception.h * test/ExceptionTest.cc @@ -18181,7 +18181,7 @@ 2008-04-22 Tatsuhiro Tsujikawa Use the default value pulled from Option object in HelpItemFactory. - except options whose defualt value is embedded in a usage text. + except options whose default value is embedded in a usage text. * src/HelpItemFactory.cc * src/HelpItemFactory.h * src/option_processing.cc @@ -18275,7 +18275,7 @@ Added --header option. You can specify any number of additional HTTP headers like: aria2 --header="X-A: 300" --header="X-B: 900" http://host/file - Unlike other commad-line option, you can use --header option multiple times. + Unlike other command-line option, you can use --header option multiple times. * src/HelpItemFactory.cc * src/HttpRequest.{cc, h} * src/HttpRequestCommand.cc @@ -18339,13 +18339,13 @@ Implemented auto protocol detection. Now you can do: aria2c -Z http://host/file file1.torrent file2.metalink - (Note: -Z option is required for auto protcol detection.) + (Note: -Z option is required for auto protocol detection.) Then aria2c downloads 3 files simultaneously: 1. http://host/file 2. file1.torrent <-- read local torrent file 3. file2.metalink <-- read local Metalink file. - Same thing goes with -i option. Assume your uris.txt contans: + Same thing goes with -i option. Assume your uris.txt contains: http://host/file file1.torrent file2.metalink @@ -19471,7 +19471,7 @@ Fixed the bug that EX_TOO_LONG_PAYLOAD exception is thrown if just payload length(4bytes) are received. This happens because lenbufLength is not updated in this particular case and successive call of - receiveMessage() overwrites payload length with bytes recieved which + receiveMessage() overwrites payload length with bytes received which are payload body. * src/PeerConnection.{h, cc} * src/message.h @@ -20637,12 +20637,12 @@ * src/PeerListenCommand.{h, cc} Now an exception thrown while parsing tracker response is now logged. - If DlAbortEx is catched, then btAnnounce->resetAnnounce() immediately + If DlAbortEx is caught, then btAnnounce->resetAnnounce() immediately called, which means no retry is made in this case, assuming a tracker has a problem. * src/TrackerWatcherCommand.cc - Fixed: downloading a file whose length is unkown fails. + Fixed: downloading a file whose length is unknown fails. * src/DownloadCommand.cc Simplified prepareForNextSegment() @@ -21629,7 +21629,7 @@ * src/common.h (OPEN_MODE): New definition. * src/File.cc * src/Util.cc - * src/Directry.cc + * src/Directory.cc * src/AbstractDiskWriter.cc Change the level of log message "download aborted" to debug: @@ -21715,7 +21715,7 @@ is 80 or 443: * src/HttpRequest.cc (getHostText): Suppress port number in http request header if port is 80 or 443. - (createProxyRequest): Allways send port number. + (createProxyRequest): Always send port number. 2007-03-28 Tatsuhiro Tsujikawa @@ -21923,7 +21923,7 @@ 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 + * src/HttpConnection.cc: Construction of http request were moved to HttpRequest class. * src/HttpResponseCommand.h, src/HttpResponseCommand.cc: Refactored. * src/HttpRequestCommand.cc (executeInternal): Rewritten. @@ -23385,7 +23385,7 @@ (sendStatistics): Use pieceStorage, btRuntime. (afterEachIteration): New function. * src/AnnounceList: AnnounceTier->AnnounceTierHandle. - * src/Directry.h + * src/Directory.h (Directory): New function. (DirectoryHandle): New type definition. * src/BtProgressInfoFile.h: New file. @@ -23464,7 +23464,7 @@ (peerStorage): New variable. (pieceStorage): New variable. (setBtContext): New function. - * src/Directry.cc + * src/Directory.cc (Directory): New function. (createDir): Do nothing if name.size() == 0. * src/AnnounceList.h @@ -23748,7 +23748,7 @@ * src/SegmentMan.h (SegmentEntryHandle): New type definition. (SegmentEntries): Now holds SegmentEntryHandle. - (findSlowerSegmentEntry): New funtion. + (findSlowerSegmentEntry): New function. * src/SegmentMan.cc (save): Updated according to the changes in SegmentEntries. (read): Updated according to the changes in SegmentEntries. @@ -25644,7 +25644,7 @@ list as "peers": * src/TrackerUpdateCommand.cc - (execute): Added a check to see wether the type of peers is Data*. + (execute): Added a check to see whether the type of peers is Data*. 2006-05-27 Tatsuhiro Tsujikawa @@ -25724,7 +25724,7 @@ (getMissingIndex): Don't call getMissingIndexRandomly() if max is 0. (getMissingUnusedIndex): Don't call getMissingIndexRandomly() if max is 0. - (getMissingIndex): Dont't call getMissingIndexRandomly() if max is 0. + (getMissingIndex): Don't't call getMissingIndexRandomly() if max is 0. * src/TorrentMan.h (UsedPieces): Removed. (Pieces): New type definition. @@ -26803,7 +26803,7 @@ (getActivePeers): New function. (deleteActivePeer): New function. * src/TorrentMan.cc - (addPeer): deleteOldErrorPeers is moved to the begining of the function + (addPeer): deleteOldErrorPeers is moved to the beginning of the function * src/PeerAbstractCommand.cc (onAbort): Use peer->resetStatus(). * src/main.cc @@ -26954,7 +26954,7 @@ * 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. + * src/AbstractDiskWriter.cc (openExistingFile): Updated message. (createFile): Updated message. 2006-04-19 Tatsuhiro Tsujikawa @@ -27272,7 +27272,7 @@ (getCompletedLength): New function. * src/TorrentMan.h [FileEntry](Constructor): Updated signature. - Initalized newly added variables. + Initialized newly added variables. [FileEntry](offset): New variable. [FileEntry](extracted): New variable. [FileEntry](requested): New variable. @@ -27329,7 +27329,7 @@ (getName): New function. * src/TorrentMan.h (getMultiFileEntries): New function. (getName): New function. - * src/main.cc (main): Use above 2 funtion. + * src/main.cc (main): Use above 2 function. * Release 0.3.2 @@ -27454,7 +27454,7 @@ * 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 + * src/TorrentMan.h: Added member variable 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 @@ -27575,7 +27575,7 @@ * BitfieldMan.cc: fixed memory leak. * TorrentMan.cc: initialized storeDir to ".". * TorrentMan.cc: fixed memory leak. - * TorrentMan.cc: corrected file paths of splitted files. + * TorrentMan.cc: corrected file paths of split files. * PeerAbstractCommand.cc: casted timeout to long long int. * main.cc: added delete(req) and delete(te->diskWriter). * RequestSlot.cc: casted timeout value to long long int. @@ -27726,7 +27726,7 @@ * HttpConnection.cc: Added Referer support. * main.cc: Added referer command-line option. * main.cc: Added rety-wait command-line option. - * Exception.h: Fixed formating bug in Exception::setMsg() + * Exception.h: Fixed formatting bug in Exception::setMsg() * SocketCore.{h,cc}: * Socket.{h, cc}: * Request.cc: diff --git a/Makefile.am b/Makefile.am index 0804f14c..fbbaa212 100644 --- a/Makefile.am +++ b/Makefile.am @@ -30,7 +30,7 @@ endif # !HAVE_RST2HTML dist_noinst_DATA = LICENSE.OpenSSL # Format source files using clang-format. Don't format source files -# under deps directory since we are not responsible for thier coding +# under deps directory since we are not responsible for their coding # style. clang-format: CLANGFORMAT=`git config --get clangformat.binary`; \ diff --git a/import-po b/import-po index 49cb8c83..dea98de2 100755 --- a/import-po +++ b/import-po @@ -39,7 +39,7 @@ for file in "$WORK_DIR"/*.po; do # copy file to po directory echo "Moving \`$file' to \`$dst'..." mv "$file" "$dst" - # Upate LINGUAS here too. + # Update LINGUAS here too. echo -n " ${bn%.po}" >> "$PO_DIR"/LINGUAS done diff --git a/src/FeatureConfig.cc b/src/FeatureConfig.cc index 3cebd846..029d4809 100644 --- a/src/FeatureConfig.cc +++ b/src/FeatureConfig.cc @@ -293,7 +293,7 @@ std::string usedCompilerAndPlatform() rv << "\n built by " << BUILD; if (strcmp(BUILD, TARGET)) { - rv << "\n targetting " << TARGET; + rv << "\n targeting " << TARGET; } rv << "\n on " << __DATE__ << " " << __TIME__; diff --git a/src/GZipDecodingStreamFilter.cc b/src/GZipDecodingStreamFilter.cc index 2895403e..d24acc3e 100644 --- a/src/GZipDecodingStreamFilter.cc +++ b/src/GZipDecodingStreamFilter.cc @@ -65,7 +65,7 @@ void GZipDecodingStreamFilter::init() strm_->avail_in = 0; strm_->next_in = Z_NULL; - // initalize z_stream with gzip/zlib format auto detection enabled. + // initialize z_stream with gzip/zlib format auto detection enabled. if (Z_OK != inflateInit2(strm_, 47)) { throw DL_ABORT_EX("Initializing z_stream failed."); } diff --git a/src/HttpConnection.h b/src/HttpConnection.h index 54da32d1..fe254866 100644 --- a/src/HttpConnection.h +++ b/src/HttpConnection.h @@ -101,7 +101,7 @@ public: * If segment.sp+segment.ds > 0 then Range header is added. * This method is used in HTTP/HTTP downloading and FTP downloading via * HTTP proxy(GET method). - * @param segment indicates starting postion of the file for downloading + * @param segment indicates starting position of the file for downloading */ void sendRequest(std::unique_ptr httpRequest); diff --git a/src/InitiateConnectionCommand.h b/src/InitiateConnectionCommand.h index e40bd1f3..12bf5d12 100644 --- a/src/InitiateConnectionCommand.h +++ b/src/InitiateConnectionCommand.h @@ -47,7 +47,7 @@ protected: /** * Connect to the server. * This method just send connection request to the server. - * Using nonblocking mode of socket, this funtion returns immediately + * Using nonblocking mode of socket, this function returns immediately * after send connection packet to the server. */ virtual bool executeInternal() CXX11_OVERRIDE; diff --git a/src/PieceStorage.h b/src/PieceStorage.h index 981c8547..c6ea6750 100644 --- a/src/PieceStorage.h +++ b/src/PieceStorage.h @@ -157,7 +157,7 @@ public: virtual void markPieceMissing(size_t index) = 0; /** - * Tells that the download of the specfied piece completes. + * Tells that the download of the specified piece completes. */ virtual void completePiece(const std::shared_ptr& piece) = 0; diff --git a/src/SSHSession.h b/src/SSHSession.h index fc1e9d1a..4034add7 100644 --- a/src/SSHSession.h +++ b/src/SSHSession.h @@ -123,7 +123,7 @@ public: // blocks, or SSH_ERR_ERROR. int sftpStat(int64_t& totalLength, time_t& mtime); - // Moves file postion to |pos|. + // Moves file position to |pos|. void sftpSeek(int64_t pos); // Returns last error string diff --git a/src/SegmentMan.h b/src/SegmentMan.h index 2d1edadc..dfb586ea 100644 --- a/src/SegmentMan.h +++ b/src/SegmentMan.h @@ -117,7 +117,7 @@ public: int64_t getTotalLength() const; /** - * Returs true when the download has finished. + * Returns true when the download has finished. * If downloadStarted is false or the number of the segments of this object * holds is 0, then returns false. */ diff --git a/src/SocketCore.h b/src/SocketCore.h index 7fdcf6e3..60f33279 100644 --- a/src/SocketCore.h +++ b/src/SocketCore.h @@ -154,8 +154,8 @@ public: /** * Creates a socket and bind it with locahost's address and port. * flags is set to struct addrinfo's ai_flags. - * @param port port to listen. If 0 is specified, os automaticaly - * choose avaiable port. + * @param port port to listen. If 0 is specified, os automatically + * choose available port. */ void bind(uint16_t port, int flags = AI_PASSIVE); diff --git a/src/TimeBasedCommand.h b/src/TimeBasedCommand.h index d8d17b34..69390914 100644 --- a/src/TimeBasedCommand.h +++ b/src/TimeBasedCommand.h @@ -54,7 +54,7 @@ private: * setting exit_ to true if this command's job has finished and you want to * delete this command. * The exit_ variable is evaluated after preProcess(), process(), - * postProcess(), and terminate processing immediately and excute() returns + * postProcess(), and terminate processing immediately and execute() returns * true. */ bool exit_; @@ -70,18 +70,18 @@ protected: public: /** - * preProcess() is called each time when excute() is called. + * preProcess() is called each time when execute() is called. */ virtual void preProcess(){}; /** - * process() is called only when excute() is called and specified time has + * process() is called only when execute() is called and specified time has * elapsed. */ virtual void process() = 0; /** - * postProcess() is called each time when excute() is called. + * postProcess() is called each time when execute() is called. */ virtual void postProcess(){}; diff --git a/src/UnknownLengthPieceStorage.h b/src/UnknownLengthPieceStorage.h index a8384cee..9c3845dd 100644 --- a/src/UnknownLengthPieceStorage.h +++ b/src/UnknownLengthPieceStorage.h @@ -136,7 +136,7 @@ public: virtual std::shared_ptr getPiece(size_t index) CXX11_OVERRIDE; /** - * Tells that the download of the specfied piece completes. + * Tells that the download of the specified piece completes. */ virtual void completePiece(const std::shared_ptr& piece) CXX11_OVERRIDE; diff --git a/src/crypto_endian.h b/src/crypto_endian.h index b282fb15..9f05451a 100644 --- a/src/crypto_endian.h +++ b/src/crypto_endian.h @@ -40,7 +40,7 @@ namespace crypto { #if !defined(LITTLE_ENDIAN) || !defined(BIG_ENDIAN) || !defined(BYTE_ORDER) || \ (LITTLE_ENDIAN != BYTE_ORDER && BIG_ENDIAN != BYTE_ORDER) -#error Unsupported byte order/endianess +#error Unsupported byte order/endianness #endif // Lets spend some quality time mucking around with byte swap and endian-ness. diff --git a/test/GZipDecoder.cc b/test/GZipDecoder.cc index 80bac711..f7adaaf5 100644 --- a/test/GZipDecoder.cc +++ b/test/GZipDecoder.cc @@ -55,7 +55,7 @@ void GZipDecoder::init() strm_->avail_in = 0; strm_->next_in = Z_NULL; - // initalize z_stream with gzip/zlib format auto detection enabled. + // initialize z_stream with gzip/zlib format auto detection enabled. if (Z_OK != inflateInit2(strm_, 47)) { throw DL_ABORT_EX("Initializing z_stream failed."); } diff --git a/test/HttpResponseTest.cc b/test/HttpResponseTest.cc index ab1e5a8f..c1b4ef43 100644 --- a/test/HttpResponseTest.cc +++ b/test/HttpResponseTest.cc @@ -131,7 +131,7 @@ void HttpResponseTest::testGetContentType() httpHeader->put(HttpHeader::CONTENT_TYPE, "application/metalink+xml; charset=UTF-8"); httpResponse.setHttpHeader(std::move(httpHeader)); - // See paramter is ignored. + // See parameter is ignored. CPPUNIT_ASSERT_EQUAL(std::string("application/metalink+xml"), httpResponse.getContentType()); } diff --git a/test/HttpResponseTest.cc.8905 b/test/HttpResponseTest.cc.8905 new file mode 100644 index 00000000..495cf4eb --- /dev/null +++ b/test/HttpResponseTest.cc.8905 @@ -0,0 +1,246 @@ +#include "HttpResponse.h" + +#include + +#include + +#include "TestUtil.h" +#include "prefs.h" +#include "PiecedSegment.h" +#include "Piece.h" +#include "Request.h" +#include "HttpHeader.h" +#include "HttpRequest.h" +#include "Exception.h" +#include "A2STR.h" +#include "DlRetryEx.h" +#include "CookieStorage.h" +#include "AuthConfigFactory.h" +#include "AuthConfig.h" +#include "StreamFilter.h" +#include "MetalinkHttpEntry.h" +#include "Option.h" +#include "Checksum.h" + +namespace aria2 { + +class HttpResponseTest : public CppUnit::TestFixture { + + CPPUNIT_TEST_SUITE(HttpResponseTest); + CPPUNIT_TEST(testGetContentLength_null); + CPPUNIT_TEST(testGetContentLength_contentLength); + // CPPUNIT_TEST(testGetContentLength_range); + CPPUNIT_TEST(testGetEntityLength); + CPPUNIT_TEST(testGetContentType); + CPPUNIT_TEST(testDetermineFilename_without_ContentDisposition); + CPPUNIT_TEST(testDetermineFilename_with_ContentDisposition_zero_length); + CPPUNIT_TEST(testDetermineFilename_with_ContentDisposition); + CPPUNIT_TEST(testGetRedirectURI_without_Location); + CPPUNIT_TEST(testGetRedirectURI_with_Location); + CPPUNIT_TEST(testIsRedirect); + CPPUNIT_TEST(testIsTransferEncodingSpecified); + CPPUNIT_TEST(testGetTransferEncoding); + CPPUNIT_TEST(testGetTransferEncodingStreamFilter); + CPPUNIT_TEST(testIsContentEncodingSpecified); + CPPUNIT_TEST(testGetContentEncoding); + CPPUNIT_TEST(testGetContentEncodingStreamFilter); + CPPUNIT_TEST(testValidateResponse); + CPPUNIT_TEST(testValidateResponse_good_range); + CPPUNIT_TEST(testValidateResponse_bad_range); + CPPUNIT_TEST(testValidateResponse_chunked); + CPPUNIT_TEST(testValidateResponse_withIfModifiedSince); + CPPUNIT_TEST(testProcessRedirect); + CPPUNIT_TEST(testRetrieveCookie); + CPPUNIT_TEST(testSupportsPersistentConnection); + CPPUNIT_TEST(testGetMetalinKHttpEntries); + CPPUNIT_TEST(testGetDigest); + CPPUNIT_TEST_SUITE_END(); + +private: +public: + void setUp() {} + + void testGetContentLength_null(); + void testGetContentLength_contentLength(); + void testGetEntityLength(); + void testGetContentType(); + void testDetermineFilename_without_ContentDisposition(); + void testDetermineFilename_with_ContentDisposition_zero_length(); + void testDetermineFilename_with_ContentDisposition(); + void testGetRedirectURI_without_Location(); + void testGetRedirectURI_with_Location(); + void testIsRedirect(); + void testIsTransferEncodingSpecified(); + void testGetTransferEncoding(); + void testGetTransferEncodingStreamFilter(); + void testIsContentEncodingSpecified(); + void testGetContentEncoding(); + void testGetContentEncodingStreamFilter(); + void testValidateResponse(); + void testValidateResponse_good_range(); + void testValidateResponse_bad_range(); + void testValidateResponse_chunked(); + void testValidateResponse_withIfModifiedSince(); + void testProcessRedirect(); + void testRetrieveCookie(); + void testSupportsPersistentConnection(); + void testGetMetalinKHttpEntries(); + void testGetDigest(); +}; + +CPPUNIT_TEST_SUITE_REGISTRATION(HttpResponseTest); + +void HttpResponseTest::testGetContentLength_null() +{ + HttpResponse httpResponse; + + CPPUNIT_ASSERT_EQUAL((int64_t)0LL, httpResponse.getContentLength()); +} + +void HttpResponseTest::testGetContentLength_contentLength() +{ + HttpResponse httpResponse; + + auto httpHeader = make_unique(); + httpHeader->put(HttpHeader::CONTENT_LENGTH, "4294967296"); + + httpResponse.setHttpHeader(std::move(httpHeader)); + + CPPUNIT_ASSERT_EQUAL((int64_t)4294967296LL, httpResponse.getContentLength()); +} + +void HttpResponseTest::testGetEntityLength() +{ + HttpResponse httpResponse; + + auto httpHeader = make_unique(); + httpHeader->put(HttpHeader::CONTENT_LENGTH, "4294967296"); + + httpResponse.setHttpHeader(std::move(httpHeader)); + CPPUNIT_ASSERT_EQUAL((int64_t)4294967296LL, httpResponse.getEntityLength()); + + httpResponse.getHttpHeader()->put(HttpHeader::CONTENT_RANGE, + "bytes 1-4294967296/4294967297"); + CPPUNIT_ASSERT_EQUAL((int64_t)4294967297LL, httpResponse.getEntityLength()); +} + +void HttpResponseTest::testGetContentType() +{ + HttpResponse httpResponse; + auto httpHeader = make_unique(); + httpHeader->put(HttpHeader::CONTENT_TYPE, + "application/metalink+xml; charset=UTF-8"); + httpResponse.setHttpHeader(std::move(httpHeader)); + // See parameter is ignored. + CPPUNIT_ASSERT_EQUAL(std::string("application/metalink+xml"), + httpResponse.getContentType()); +} + +void HttpResponseTest::testDetermineFilename_without_ContentDisposition() +{ + HttpResponse httpResponse; + auto httpRequest = make_unique(); + auto request = std::make_shared(); + request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2"); + httpRequest->setRequest(request); + + httpResponse.setHttpHeader(make_unique()); + httpResponse.setHttpRequest(std::move(httpRequest)); + + CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), + httpResponse.determineFilename(false)); +} + +void HttpResponseTest:: + testDetermineFilename_with_ContentDisposition_zero_length() +{ + HttpResponse httpResponse; + auto httpHeader = make_unique(); + httpHeader->put(HttpHeader::CONTENT_DISPOSITION, "attachment; filename=\"\""); + auto httpRequest = make_unique(); + auto request = std::make_shared(); + request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2"); + httpRequest->setRequest(request); + + httpResponse.setHttpHeader(std::move(httpHeader)); + httpResponse.setHttpRequest(std::move(httpRequest)); + + CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), + httpResponse.determineFilename(false)); +} + +void HttpResponseTest::testDetermineFilename_with_ContentDisposition() +{ + HttpResponse httpResponse; + auto httpHeader = make_unique(); + httpHeader->put(HttpHeader::CONTENT_DISPOSITION, + "attachment; filename=\"aria2-current.tar.bz2\""); + auto httpRequest = make_unique(); + auto request = std::make_shared(); + request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2"); + httpRequest->setRequest(request); + + httpResponse.setHttpHeader(std::move(httpHeader)); + httpResponse.setHttpRequest(std::move(httpRequest)); + + CPPUNIT_ASSERT_EQUAL(std::string("aria2-current.tar.bz2"), + httpResponse.determineFilename(false)); +} + +void HttpResponseTest::testGetRedirectURI_without_Location() +{ + HttpResponse httpResponse; + + httpResponse.setHttpHeader(make_unique()); + + CPPUNIT_ASSERT_EQUAL(std::string(""), httpResponse.getRedirectURI()); +} + +void HttpResponseTest::testGetRedirectURI_with_Location() +{ + HttpResponse httpResponse; + auto httpHeader = make_unique(); + httpHeader->put(HttpHeader::LOCATION, + "http://localhost/download/aria2-1.0.0.tar.bz2"); + httpResponse.setHttpHeader(std::move(httpHeader)); + + CPPUNIT_ASSERT_EQUAL( + std::string("http://localhost/download/aria2-1.0.0.tar.bz2"), + httpResponse.getRedirectURI()); +} + +void HttpResponseTest::testIsRedirect() +{ + HttpResponse httpResponse; + httpResponse.setHttpHeader(make_unique()); + + httpResponse.getHttpHeader()->setStatusCode(301); + CPPUNIT_ASSERT(!httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(200); + CPPUNIT_ASSERT(!httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->put( + HttpHeader::LOCATION, "http://localhost/download/aria2-1.0.0.tar.bz2"); + + CPPUNIT_ASSERT(!httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(300); + CPPUNIT_ASSERT(httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(301); + CPPUNIT_ASSERT(httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(302); + CPPUNIT_ASSERT(httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(303); + CPPUNIT_ASSERT(httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(304); + CPPUNIT_ASSERT(!httpResponse.isRedirect()); + + httpResponse.getHttpHeader()->setStatusCode(305); + CPPUNIT_ASSERT(!httpResponse.isRedirect()); + + httpResp \ No newline at end of file From aa5567d774692e54cb0c6761a34f9d84faccc8f7 Mon Sep 17 00:00:00 2001 From: klemens Date: Mon, 20 Mar 2017 22:46:38 +0100 Subject: [PATCH 2/2] spelling fixes --- test/HttpResponseTest.cc.8905 | 246 ---------------------------------- 1 file changed, 246 deletions(-) delete mode 100644 test/HttpResponseTest.cc.8905 diff --git a/test/HttpResponseTest.cc.8905 b/test/HttpResponseTest.cc.8905 deleted file mode 100644 index 495cf4eb..00000000 --- a/test/HttpResponseTest.cc.8905 +++ /dev/null @@ -1,246 +0,0 @@ -#include "HttpResponse.h" - -#include - -#include - -#include "TestUtil.h" -#include "prefs.h" -#include "PiecedSegment.h" -#include "Piece.h" -#include "Request.h" -#include "HttpHeader.h" -#include "HttpRequest.h" -#include "Exception.h" -#include "A2STR.h" -#include "DlRetryEx.h" -#include "CookieStorage.h" -#include "AuthConfigFactory.h" -#include "AuthConfig.h" -#include "StreamFilter.h" -#include "MetalinkHttpEntry.h" -#include "Option.h" -#include "Checksum.h" - -namespace aria2 { - -class HttpResponseTest : public CppUnit::TestFixture { - - CPPUNIT_TEST_SUITE(HttpResponseTest); - CPPUNIT_TEST(testGetContentLength_null); - CPPUNIT_TEST(testGetContentLength_contentLength); - // CPPUNIT_TEST(testGetContentLength_range); - CPPUNIT_TEST(testGetEntityLength); - CPPUNIT_TEST(testGetContentType); - CPPUNIT_TEST(testDetermineFilename_without_ContentDisposition); - CPPUNIT_TEST(testDetermineFilename_with_ContentDisposition_zero_length); - CPPUNIT_TEST(testDetermineFilename_with_ContentDisposition); - CPPUNIT_TEST(testGetRedirectURI_without_Location); - CPPUNIT_TEST(testGetRedirectURI_with_Location); - CPPUNIT_TEST(testIsRedirect); - CPPUNIT_TEST(testIsTransferEncodingSpecified); - CPPUNIT_TEST(testGetTransferEncoding); - CPPUNIT_TEST(testGetTransferEncodingStreamFilter); - CPPUNIT_TEST(testIsContentEncodingSpecified); - CPPUNIT_TEST(testGetContentEncoding); - CPPUNIT_TEST(testGetContentEncodingStreamFilter); - CPPUNIT_TEST(testValidateResponse); - CPPUNIT_TEST(testValidateResponse_good_range); - CPPUNIT_TEST(testValidateResponse_bad_range); - CPPUNIT_TEST(testValidateResponse_chunked); - CPPUNIT_TEST(testValidateResponse_withIfModifiedSince); - CPPUNIT_TEST(testProcessRedirect); - CPPUNIT_TEST(testRetrieveCookie); - CPPUNIT_TEST(testSupportsPersistentConnection); - CPPUNIT_TEST(testGetMetalinKHttpEntries); - CPPUNIT_TEST(testGetDigest); - CPPUNIT_TEST_SUITE_END(); - -private: -public: - void setUp() {} - - void testGetContentLength_null(); - void testGetContentLength_contentLength(); - void testGetEntityLength(); - void testGetContentType(); - void testDetermineFilename_without_ContentDisposition(); - void testDetermineFilename_with_ContentDisposition_zero_length(); - void testDetermineFilename_with_ContentDisposition(); - void testGetRedirectURI_without_Location(); - void testGetRedirectURI_with_Location(); - void testIsRedirect(); - void testIsTransferEncodingSpecified(); - void testGetTransferEncoding(); - void testGetTransferEncodingStreamFilter(); - void testIsContentEncodingSpecified(); - void testGetContentEncoding(); - void testGetContentEncodingStreamFilter(); - void testValidateResponse(); - void testValidateResponse_good_range(); - void testValidateResponse_bad_range(); - void testValidateResponse_chunked(); - void testValidateResponse_withIfModifiedSince(); - void testProcessRedirect(); - void testRetrieveCookie(); - void testSupportsPersistentConnection(); - void testGetMetalinKHttpEntries(); - void testGetDigest(); -}; - -CPPUNIT_TEST_SUITE_REGISTRATION(HttpResponseTest); - -void HttpResponseTest::testGetContentLength_null() -{ - HttpResponse httpResponse; - - CPPUNIT_ASSERT_EQUAL((int64_t)0LL, httpResponse.getContentLength()); -} - -void HttpResponseTest::testGetContentLength_contentLength() -{ - HttpResponse httpResponse; - - auto httpHeader = make_unique(); - httpHeader->put(HttpHeader::CONTENT_LENGTH, "4294967296"); - - httpResponse.setHttpHeader(std::move(httpHeader)); - - CPPUNIT_ASSERT_EQUAL((int64_t)4294967296LL, httpResponse.getContentLength()); -} - -void HttpResponseTest::testGetEntityLength() -{ - HttpResponse httpResponse; - - auto httpHeader = make_unique(); - httpHeader->put(HttpHeader::CONTENT_LENGTH, "4294967296"); - - httpResponse.setHttpHeader(std::move(httpHeader)); - CPPUNIT_ASSERT_EQUAL((int64_t)4294967296LL, httpResponse.getEntityLength()); - - httpResponse.getHttpHeader()->put(HttpHeader::CONTENT_RANGE, - "bytes 1-4294967296/4294967297"); - CPPUNIT_ASSERT_EQUAL((int64_t)4294967297LL, httpResponse.getEntityLength()); -} - -void HttpResponseTest::testGetContentType() -{ - HttpResponse httpResponse; - auto httpHeader = make_unique(); - httpHeader->put(HttpHeader::CONTENT_TYPE, - "application/metalink+xml; charset=UTF-8"); - httpResponse.setHttpHeader(std::move(httpHeader)); - // See parameter is ignored. - CPPUNIT_ASSERT_EQUAL(std::string("application/metalink+xml"), - httpResponse.getContentType()); -} - -void HttpResponseTest::testDetermineFilename_without_ContentDisposition() -{ - HttpResponse httpResponse; - auto httpRequest = make_unique(); - auto request = std::make_shared(); - request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2"); - httpRequest->setRequest(request); - - httpResponse.setHttpHeader(make_unique()); - httpResponse.setHttpRequest(std::move(httpRequest)); - - CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), - httpResponse.determineFilename(false)); -} - -void HttpResponseTest:: - testDetermineFilename_with_ContentDisposition_zero_length() -{ - HttpResponse httpResponse; - auto httpHeader = make_unique(); - httpHeader->put(HttpHeader::CONTENT_DISPOSITION, "attachment; filename=\"\""); - auto httpRequest = make_unique(); - auto request = std::make_shared(); - request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2"); - httpRequest->setRequest(request); - - httpResponse.setHttpHeader(std::move(httpHeader)); - httpResponse.setHttpRequest(std::move(httpRequest)); - - CPPUNIT_ASSERT_EQUAL(std::string("aria2-1.0.0.tar.bz2"), - httpResponse.determineFilename(false)); -} - -void HttpResponseTest::testDetermineFilename_with_ContentDisposition() -{ - HttpResponse httpResponse; - auto httpHeader = make_unique(); - httpHeader->put(HttpHeader::CONTENT_DISPOSITION, - "attachment; filename=\"aria2-current.tar.bz2\""); - auto httpRequest = make_unique(); - auto request = std::make_shared(); - request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2"); - httpRequest->setRequest(request); - - httpResponse.setHttpHeader(std::move(httpHeader)); - httpResponse.setHttpRequest(std::move(httpRequest)); - - CPPUNIT_ASSERT_EQUAL(std::string("aria2-current.tar.bz2"), - httpResponse.determineFilename(false)); -} - -void HttpResponseTest::testGetRedirectURI_without_Location() -{ - HttpResponse httpResponse; - - httpResponse.setHttpHeader(make_unique()); - - CPPUNIT_ASSERT_EQUAL(std::string(""), httpResponse.getRedirectURI()); -} - -void HttpResponseTest::testGetRedirectURI_with_Location() -{ - HttpResponse httpResponse; - auto httpHeader = make_unique(); - httpHeader->put(HttpHeader::LOCATION, - "http://localhost/download/aria2-1.0.0.tar.bz2"); - httpResponse.setHttpHeader(std::move(httpHeader)); - - CPPUNIT_ASSERT_EQUAL( - std::string("http://localhost/download/aria2-1.0.0.tar.bz2"), - httpResponse.getRedirectURI()); -} - -void HttpResponseTest::testIsRedirect() -{ - HttpResponse httpResponse; - httpResponse.setHttpHeader(make_unique()); - - httpResponse.getHttpHeader()->setStatusCode(301); - CPPUNIT_ASSERT(!httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(200); - CPPUNIT_ASSERT(!httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->put( - HttpHeader::LOCATION, "http://localhost/download/aria2-1.0.0.tar.bz2"); - - CPPUNIT_ASSERT(!httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(300); - CPPUNIT_ASSERT(httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(301); - CPPUNIT_ASSERT(httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(302); - CPPUNIT_ASSERT(httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(303); - CPPUNIT_ASSERT(httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(304); - CPPUNIT_ASSERT(!httpResponse.isRedirect()); - - httpResponse.getHttpHeader()->setStatusCode(305); - CPPUNIT_ASSERT(!httpResponse.isRedirect()); - - httpResp \ No newline at end of file