spelling fixes

This commit is contained in:
klemens 2017-03-20 22:44:41 +01:00
parent f0adbde2e6
commit ec2ce4ffe5
17 changed files with 307 additions and 61 deletions

View File

@ -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 <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
Added usege for proxy.
Added usage for proxy.
* doc/aria2c.1.txt
2008-11-09 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
@ -14004,7 +14004,7 @@
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.
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 <tujikawa at rednoah dot com>
Corrected catched exception type.
Corrected caught exception type.
* src/ServerStatMan.cc
2008-11-03 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
@ -14403,7 +14403,7 @@
2008-10-19 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
Added sqlite3 depenency and Firefox3 cookie support.
Added sqlite3 dependency and Firefox3 cookie support.
* README
2008-08-24 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
@ -17791,7 +17791,7 @@
2008-05-10 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
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 <tujikawa at rednoah dot com>
@ -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 <tujikawa at rednoah dot com>
@ -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 <tujikawa at rednoah dot com>
@ -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:

View File

@ -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`; \

View File

@ -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

View File

@ -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__;

View File

@ -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.");
}

View File

@ -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> httpRequest);

View File

@ -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;

View File

@ -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>& piece) = 0;

View File

@ -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

View File

@ -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.
*/

View File

@ -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);

View File

@ -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(){};

View File

@ -136,7 +136,7 @@ public:
virtual std::shared_ptr<Piece> 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>& piece) CXX11_OVERRIDE;

View File

@ -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.

View File

@ -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.");
}

View File

@ -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());
}

View File

@ -0,0 +1,246 @@
#include "HttpResponse.h"
#include <iostream>
#include <cppunit/extensions/HelperMacros.h>
#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>();
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>();
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>();
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<HttpRequest>();
auto request = std::make_shared<Request>();
request->setUri("http://localhost/archives/aria2-1.0.0.tar.bz2");
httpRequest->setRequest(request);
httpResponse.setHttpHeader(make_unique<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_zero_length()
{
HttpResponse httpResponse;
auto httpHeader = make_unique<HttpHeader>();
httpHeader->put(HttpHeader::CONTENT_DISPOSITION, "attachment; filename=\"\"");
auto httpRequest = make_unique<HttpRequest>();
auto request = std::make_shared<Request>();
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>();
httpHeader->put(HttpHeader::CONTENT_DISPOSITION,
"attachment; filename=\"aria2-current.tar.bz2\"");
auto httpRequest = make_unique<HttpRequest>();
auto request = std::make_shared<Request>();
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<HttpHeader>());
CPPUNIT_ASSERT_EQUAL(std::string(""), httpResponse.getRedirectURI());
}
void HttpResponseTest::testGetRedirectURI_with_Location()
{
HttpResponse httpResponse;
auto httpHeader = make_unique<HttpHeader>();
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<HttpHeader>());
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