mirror of
https://github.com/aria2/aria2.git
synced 2024-11-26 23:50:35 +00:00
clang-format-5.0
This commit is contained in:
parent
20a7c43f2d
commit
795a0474df
@ -128,10 +128,11 @@ int main(int argc, char** argv)
|
||||
if (dh) {
|
||||
std::cerr << " [" << aria2::gidToHex(gid) << "] "
|
||||
<< dh->getCompletedLength() << "/" << dh->getTotalLength()
|
||||
<< "(" << (dh->getTotalLength() > 0
|
||||
? (100 * dh->getCompletedLength() /
|
||||
dh->getTotalLength())
|
||||
: 0)
|
||||
<< "("
|
||||
<< (dh->getTotalLength() > 0
|
||||
? (100 * dh->getCompletedLength() /
|
||||
dh->getTotalLength())
|
||||
: 0)
|
||||
<< "%)"
|
||||
<< " D:" << dh->getDownloadSpeed() / 1024
|
||||
<< "KiB/s, U:" << dh->getUploadSpeed() / 1024 << "KiB/s"
|
||||
|
@ -119,7 +119,7 @@ void AbstractDiskWriter::openFile(int64_t totalLength)
|
||||
#else // !__MINGW32__
|
||||
e.getErrNum() == ENOENT
|
||||
#endif // !__MINGW32__
|
||||
) {
|
||||
) {
|
||||
initAndOpenFile(totalLength);
|
||||
}
|
||||
else {
|
||||
@ -201,9 +201,10 @@ HANDLE openFileWithFlags(const std::string& filename, int flags,
|
||||
FILE_ATTRIBUTE_NORMAL, /* hTemplateFile */ 0);
|
||||
if (hn == INVALID_HANDLE_VALUE) {
|
||||
int errNum = GetLastError();
|
||||
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_OPEN, filename.c_str(),
|
||||
fileStrerror(errNum).c_str()),
|
||||
errCode);
|
||||
throw DL_ABORT_EX3(
|
||||
errNum,
|
||||
fmt(EX_FILE_OPEN, filename.c_str(), fileStrerror(errNum).c_str()),
|
||||
errCode);
|
||||
}
|
||||
return hn;
|
||||
}
|
||||
@ -217,9 +218,10 @@ int openFileWithFlags(const std::string& filename, int flags,
|
||||
;
|
||||
if (fd < 0) {
|
||||
int errNum = errno;
|
||||
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_OPEN, filename.c_str(),
|
||||
util::safeStrerror(errNum).c_str()),
|
||||
errCode);
|
||||
throw DL_ABORT_EX3(
|
||||
errNum,
|
||||
fmt(EX_FILE_OPEN, filename.c_str(), util::safeStrerror(errNum).c_str()),
|
||||
errCode);
|
||||
}
|
||||
util::make_fd_cloexec(fd);
|
||||
#if defined(__APPLE__) && defined(__MACH__)
|
||||
@ -454,9 +456,10 @@ void AbstractDiskWriter::writeData(const unsigned char* data, size_t len,
|
||||
error_code::NOT_ENOUGH_DISK_SPACE);
|
||||
}
|
||||
else {
|
||||
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_WRITE, filename_.c_str(),
|
||||
fileStrerror(errNum).c_str()),
|
||||
error_code::FILE_IO_ERROR);
|
||||
throw DL_ABORT_EX3(
|
||||
errNum,
|
||||
fmt(EX_FILE_WRITE, filename_.c_str(), fileStrerror(errNum).c_str()),
|
||||
error_code::FILE_IO_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -467,9 +470,10 @@ ssize_t AbstractDiskWriter::readData(unsigned char* data, size_t len,
|
||||
ssize_t ret;
|
||||
if ((ret = readDataInternal(data, len, offset)) < 0) {
|
||||
int errNum = fileError();
|
||||
throw DL_ABORT_EX3(errNum, fmt(EX_FILE_READ, filename_.c_str(),
|
||||
fileStrerror(errNum).c_str()),
|
||||
error_code::FILE_IO_ERROR);
|
||||
throw DL_ABORT_EX3(
|
||||
errNum,
|
||||
fmt(EX_FILE_READ, filename_.c_str(), fileStrerror(errNum).c_str()),
|
||||
error_code::FILE_IO_ERROR);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@ -526,17 +530,17 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
||||
}
|
||||
#elif defined(__APPLE__) && defined(__MACH__)
|
||||
const auto toalloc = offset + length - size();
|
||||
fstore_t fstore = {
|
||||
F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE,
|
||||
0, toalloc, 0};
|
||||
fstore_t fstore = {F_ALLOCATECONTIG | F_ALLOCATEALL, F_PEOFPOSMODE, 0,
|
||||
toalloc, 0};
|
||||
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
|
||||
// Retry non-contig.
|
||||
fstore.fst_flags = F_ALLOCATEALL;
|
||||
if (fcntl(fd_, F_PREALLOCATE, &fstore) == -1) {
|
||||
int err = errno;
|
||||
throw DL_ABORT_EX3(
|
||||
err, fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s",
|
||||
fstore.fst_length, util::safeStrerror(err).c_str()),
|
||||
err,
|
||||
fmt("fcntl(F_PREALLOCATE) of %" PRId64 " failed. cause: %s",
|
||||
fstore.fst_length, util::safeStrerror(err).c_str()),
|
||||
error_code::FILE_IO_ERROR);
|
||||
}
|
||||
}
|
||||
@ -559,10 +563,11 @@ void AbstractDiskWriter::allocate(int64_t offset, int64_t length, bool sparse)
|
||||
#elif HAVE_POSIX_FALLOCATE
|
||||
int r = posix_fallocate(fd_, offset, length);
|
||||
if (r != 0) {
|
||||
throw DL_ABORT_EX3(r, fmt("posix_fallocate failed. cause: %s",
|
||||
util::safeStrerror(r).c_str()),
|
||||
isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE
|
||||
: error_code::FILE_IO_ERROR);
|
||||
throw DL_ABORT_EX3(
|
||||
r,
|
||||
fmt("posix_fallocate failed. cause: %s", util::safeStrerror(r).c_str()),
|
||||
isDiskFullError(r) ? error_code::NOT_ENOUGH_DISK_SPACE
|
||||
: error_code::FILE_IO_ERROR);
|
||||
}
|
||||
#else
|
||||
#error "no *_fallocate function available."
|
||||
|
@ -107,9 +107,9 @@ bool ActivePeerConnectionCommand::execute()
|
||||
int numConnection = 0;
|
||||
if (pieceStorage_->downloadFinished()) {
|
||||
if (btRuntime_->getMaxPeers() > btRuntime_->getConnections()) {
|
||||
numConnection = std::min(numNewConnection_,
|
||||
btRuntime_->getMaxPeers() -
|
||||
btRuntime_->getConnections());
|
||||
numConnection =
|
||||
std::min(numNewConnection_, btRuntime_->getMaxPeers() -
|
||||
btRuntime_->getConnections());
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -128,6 +128,6 @@ private:
|
||||
OSStatus sockWrite(const void* data, size_t* len);
|
||||
OSStatus sockRead(void* data, size_t* len);
|
||||
};
|
||||
}
|
||||
} // namespace aria2
|
||||
|
||||
#endif // TLS_SESSION_H
|
||||
|
@ -73,7 +73,7 @@ public:
|
||||
,
|
||||
ares_addr_node* servers
|
||||
#endif // HAVE_ARES_ADDR_NODE
|
||||
);
|
||||
);
|
||||
|
||||
~AsyncNameResolver();
|
||||
|
||||
|
@ -93,7 +93,7 @@ void AsyncNameResolverMan::startAsyncFamily(const std::string& hostname,
|
||||
,
|
||||
e->getAsyncDNSServers()
|
||||
#endif // HAVE_ARES_ADDR_NODE
|
||||
);
|
||||
);
|
||||
asyncNameResolver_[numResolver_]->resolve(hostname);
|
||||
setNameResolverCheck(numResolver_, e, command);
|
||||
}
|
||||
|
@ -78,8 +78,9 @@ void ChecksumCheckIntegrityEntry::onDownloadIncomplete(
|
||||
std::vector<std::unique_ptr<Command>>& commands, DownloadEngine* e)
|
||||
{
|
||||
if (redownload_) {
|
||||
proceedFileAllocation(commands, make_unique<StreamFileAllocationEntry>(
|
||||
getRequestGroup(), popNextCommand()),
|
||||
proceedFileAllocation(commands,
|
||||
make_unique<StreamFileAllocationEntry>(
|
||||
getRequestGroup(), popNextCommand()),
|
||||
e);
|
||||
return;
|
||||
}
|
||||
|
@ -245,9 +245,8 @@ bool DHTBucket::operator==(const DHTBucket& bucket) const
|
||||
|
||||
bool DHTBucket::needsRefresh() const
|
||||
{
|
||||
return nodes_.size() < K ||
|
||||
lastUpdated_.difference(global::wallclock()) >=
|
||||
DHT_BUCKET_REFRESH_INTERVAL;
|
||||
return nodes_.size() < K || lastUpdated_.difference(global::wallclock()) >=
|
||||
DHT_BUCKET_REFRESH_INTERVAL;
|
||||
}
|
||||
|
||||
void DHTBucket::notifyUpdate() { lastUpdated_ = global::wallclock(); }
|
||||
|
@ -87,9 +87,8 @@ bool DHTNode::isBad() const { return condition_ >= BAD_CONDITION; }
|
||||
|
||||
bool DHTNode::isQuestionable() const
|
||||
{
|
||||
return !isBad() &&
|
||||
lastContact_.difference(global::wallclock()) >=
|
||||
DHT_NODE_CONTACT_INTERVAL;
|
||||
return !isBad() && lastContact_.difference(global::wallclock()) >=
|
||||
DHT_NODE_CONTACT_INTERVAL;
|
||||
}
|
||||
|
||||
void DHTNode::markGood() { condition_ = 0; }
|
||||
|
@ -55,6 +55,6 @@ struct DHTNodeLookupEntry {
|
||||
bool operator==(const DHTNodeLookupEntry& entry) const;
|
||||
};
|
||||
|
||||
} // namespace aria2;
|
||||
} // namespace aria2
|
||||
|
||||
#endif // D_DHT_NODE_LOOKUP_ENTRY_H
|
||||
|
@ -235,9 +235,9 @@ bool FtpConnection::sendPort(const std::shared_ptr<SocketCore>& serverSocket)
|
||||
bool FtpConnection::sendRest(const std::shared_ptr<Segment>& segment)
|
||||
{
|
||||
if (socketBuffer_.sendBufferIsEmpty()) {
|
||||
std::string request = fmt("REST %" PRId64 "\r\n",
|
||||
segment ? segment->getPositionToWrite()
|
||||
: static_cast<int64_t>(0LL));
|
||||
std::string request =
|
||||
fmt("REST %" PRId64 "\r\n", segment ? segment->getPositionToWrite()
|
||||
: static_cast<int64_t>(0LL));
|
||||
A2_LOG_INFO(fmt(MSG_SENDING_REQUEST, cuid_, request.c_str()));
|
||||
socketBuffer_.pushStr(std::move(request));
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ bool HttpHeader::fieldContains(int hdKey, const char* value)
|
||||
util::splitIter((*i).second.begin(), (*i).second.end(),
|
||||
std::back_inserter(values), ',',
|
||||
true // doStrip
|
||||
);
|
||||
);
|
||||
for (const auto& v : values) {
|
||||
if (util::strieq(v.first, v.second, value)) {
|
||||
return true;
|
||||
|
@ -163,6 +163,6 @@ public:
|
||||
|
||||
int idInterestingHeader(const char* hdName);
|
||||
|
||||
} // namespace
|
||||
} // namespace aria2
|
||||
|
||||
#endif // D_HTTP_HEADER_H
|
||||
|
@ -279,9 +279,8 @@ bool HttpResponseCommand::executeInternal()
|
||||
// we ignore content-length when inflate is required
|
||||
fe->setLength(0);
|
||||
if (req->getMethod() == Request::METHOD_GET &&
|
||||
(totalLength != 0 ||
|
||||
!httpResponse->getHttpHeader()->defined(
|
||||
HttpHeader::CONTENT_LENGTH))) {
|
||||
(totalLength != 0 || !httpResponse->getHttpHeader()->defined(
|
||||
HttpHeader::CONTENT_LENGTH))) {
|
||||
// DownloadContext::knowsTotalLength() == true only when
|
||||
// server says the size of file is 0 explicitly.
|
||||
getDownloadContext()->markTotalLengthIsUnknown();
|
||||
@ -422,9 +421,8 @@ bool HttpResponseCommand::handleOtherEncoding(
|
||||
httpResponse.get(), getContentEncodingStreamFilter(httpResponse.get()));
|
||||
// If chunked transfer-encoding is specified, we have to read end of
|
||||
// chunk markers(0\r\n\r\n, for example).
|
||||
bool chunkedUsed =
|
||||
streamFilter &&
|
||||
streamFilter->getName() == ChunkedDecodingStreamFilter::NAME;
|
||||
bool chunkedUsed = streamFilter && streamFilter->getName() ==
|
||||
ChunkedDecodingStreamFilter::NAME;
|
||||
|
||||
// For zero-length file, check existing file comparing its size
|
||||
if (!chunkedUsed && getDownloadContext()->knowsTotalLength() &&
|
||||
|
@ -57,8 +57,8 @@ namespace util {
|
||||
namespace security {
|
||||
class HMAC;
|
||||
class HMACResult;
|
||||
}
|
||||
}
|
||||
} // namespace security
|
||||
} // namespace util
|
||||
|
||||
enum RequestType { RPC_TYPE_NONE, RPC_TYPE_XML, RPC_TYPE_JSON, RPC_TYPE_JSONP };
|
||||
|
||||
|
@ -58,7 +58,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand(
|
||||
// for SSL
|
||||
|| req->getProtocol() == "https"
|
||||
#endif // ENABLE_SSL
|
||||
) {
|
||||
) {
|
||||
|
||||
if (requestGroup->getOption()->getAsBool(PREF_ENABLE_HTTP_KEEP_ALIVE)) {
|
||||
req->setKeepAliveHint(true);
|
||||
@ -74,7 +74,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand(
|
||||
#ifdef HAVE_LIBSSH2
|
||||
|| req->getProtocol() == "sftp"
|
||||
#endif // HAVE_LIBSSH2
|
||||
) {
|
||||
) {
|
||||
if (req->getFile().empty()) {
|
||||
throw DL_ABORT_EX(fmt("FTP/SFTP URI %s doesn't contain file path.",
|
||||
req->getUri().c_str()));
|
||||
|
@ -107,9 +107,9 @@ int GnuTLSSession::init(sock_t sockfd)
|
||||
|
||||
rv_ = gnutls_init(&sslSession_, flags);
|
||||
#else // GNUTLS_VERSION_NUMBER >= 0x030000
|
||||
rv_ = gnutls_init(&sslSession_,
|
||||
tlsContext_->getSide() == TLS_CLIENT ? GNUTLS_CLIENT
|
||||
: GNUTLS_SERVER);
|
||||
rv_ = gnutls_init(&sslSession_, tlsContext_->getSide() == TLS_CLIENT
|
||||
? GNUTLS_CLIENT
|
||||
: GNUTLS_SERVER);
|
||||
#endif // GNUTLS_VERSION_NUMBER >= 0x030000
|
||||
if (rv_ != GNUTLS_E_SUCCESS) {
|
||||
return TLS_ERR_ERROR;
|
||||
|
@ -125,15 +125,14 @@ OpenSSLTLSContext::OpenSSLTLSContext(TLSSessionSide side, TLSVersion minVer)
|
||||
};
|
||||
|
||||
// Disable SSLv2 and enable all workarounds for buggy servers
|
||||
SSL_CTX_set_options(sslCtx_,
|
||||
SSL_OP_ALL | SSL_OP_NO_SSLv2 | ver_opts
|
||||
SSL_CTX_set_options(sslCtx_, SSL_OP_ALL | SSL_OP_NO_SSLv2 | ver_opts
|
||||
#ifdef SSL_OP_SINGLE_ECDH_USE
|
||||
| SSL_OP_SINGLE_ECDH_USE
|
||||
| SSL_OP_SINGLE_ECDH_USE
|
||||
#endif // SSL_OP_SINGLE_ECDH_USE
|
||||
#ifdef SSL_OP_NO_COMPRESSION
|
||||
| SSL_OP_NO_COMPRESSION
|
||||
| SSL_OP_NO_COMPRESSION
|
||||
#endif // SSL_OP_NO_COMPRESSION
|
||||
);
|
||||
);
|
||||
SSL_CTX_set_mode(sslCtx_, SSL_MODE_AUTO_RETRY);
|
||||
SSL_CTX_set_mode(sslCtx_, SSL_MODE_ENABLE_PARTIAL_WRITE);
|
||||
#ifdef SSL_MODE_RELEASE_BUFFERS
|
||||
|
@ -66,7 +66,7 @@ template <typename T> static void close_callback(uv_handle_t* handle)
|
||||
}
|
||||
|
||||
static void timer_callback(uv_timer_t* handle) { uv_stop(handle->loop); }
|
||||
}
|
||||
} // namespace
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -121,4 +121,4 @@ std::string createLpdRequest(const std::string& multicastAddress,
|
||||
|
||||
} // namespace bittorrent
|
||||
|
||||
} // namespac aria2
|
||||
} // namespace aria2
|
||||
|
@ -61,7 +61,7 @@ HashTypeEntry hashTypes[] = {
|
||||
HashTypeEntry("sha-512", 5), HashTypeEntry("md5", 0),
|
||||
HashTypeEntry("adler32", 0),
|
||||
};
|
||||
} // namespace aria2
|
||||
} // namespace
|
||||
|
||||
MessageDigest::MessageDigest(std::unique_ptr<MessageDigestImpl> impl)
|
||||
: pImpl_{std::move(impl)}
|
||||
|
@ -139,9 +139,10 @@ void Metalink2RequestGroup::generate(
|
||||
const std::shared_ptr<Option>& option, const std::string& baseUri)
|
||||
{
|
||||
std::vector<std::shared_ptr<RequestGroup>> tempgroups;
|
||||
createRequestGroup(tempgroups, metalink::parseAndQuery(binaryStream.get(),
|
||||
option.get(), baseUri),
|
||||
option);
|
||||
createRequestGroup(
|
||||
tempgroups,
|
||||
metalink::parseAndQuery(binaryStream.get(), option.get(), baseUri),
|
||||
option);
|
||||
auto mi = std::make_shared<MetadataInfo>();
|
||||
setMetadataInfo(std::begin(tempgroups), std::end(tempgroups), mi);
|
||||
groups.insert(std::end(groups), std::begin(tempgroups), std::end(tempgroups));
|
||||
|
@ -254,7 +254,7 @@ void MetalinkParserController::commitResourceTransaction()
|
||||
else {
|
||||
tEntry_->resources.push_back(std::move(tResource_));
|
||||
}
|
||||
#else // !ENABLE_BITTORRENT
|
||||
#else // !ENABLE_BITTORRENT
|
||||
tEntry_->resources.push_back(std::move(tResource_));
|
||||
#endif // !ENABLE_BITTORRENT
|
||||
tResource_.reset();
|
||||
|
@ -62,6 +62,6 @@ public:
|
||||
|
||||
} // namespace rpc
|
||||
|
||||
} // aria2
|
||||
} // namespace aria2
|
||||
|
||||
#endif // D_NULL_WEB_SOCKET_SESSION_MAN_H
|
||||
|
@ -67,9 +67,8 @@ void OpenedFileCounter::ensureMaxOpenFileLimit(size_t numNewFiles)
|
||||
auto& requestGroups = rgman_->getRequestGroups();
|
||||
|
||||
auto mark = std::begin(requestGroups);
|
||||
std::advance(
|
||||
mark,
|
||||
SimpleRandomizer::getInstance()->getRandomNumber(requestGroups.size()));
|
||||
std::advance(mark, SimpleRandomizer::getInstance()->getRandomNumber(
|
||||
requestGroups.size()));
|
||||
|
||||
auto closeFun = [&left](const std::shared_ptr<RequestGroup>& group) {
|
||||
auto& ps = group->getPieceStorage();
|
||||
|
@ -755,7 +755,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||
new LocalFilePathOptionHandler(
|
||||
PREF_RPC_CERTIFICATE, TEXT_RPC_CERTIFICATE, NO_DEFAULT_VALUE, false)
|
||||
#endif // HAVE_APPLETLS
|
||||
);
|
||||
);
|
||||
op->addTag(TAG_RPC);
|
||||
handlers.push_back(op);
|
||||
}
|
||||
@ -1041,7 +1041,7 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||
new LocalFilePathOptionHandler(PREF_CERTIFICATE, TEXT_CERTIFICATE,
|
||||
NO_DEFAULT_VALUE, false)
|
||||
#endif // HAVE_APPLETLS
|
||||
);
|
||||
);
|
||||
op->addTag(TAG_HTTP);
|
||||
op->addTag(TAG_HTTPS);
|
||||
handlers.push_back(op);
|
||||
@ -1480,10 +1480,10 @@ std::vector<OptionHandler*> OptionHandlerFactory::createOptionHandlers()
|
||||
handlers.push_back(op);
|
||||
}
|
||||
{
|
||||
OptionHandler* op(new DefaultOptionHandler(PREF_BT_EXCLUDE_TRACKER,
|
||||
TEXT_BT_EXCLUDE_TRACKER,
|
||||
NO_DESCRIPTION, "URI,... "
|
||||
"or *"));
|
||||
OptionHandler* op(new DefaultOptionHandler(
|
||||
PREF_BT_EXCLUDE_TRACKER, TEXT_BT_EXCLUDE_TRACKER, NO_DESCRIPTION,
|
||||
"URI,... "
|
||||
"or *"));
|
||||
op->addTag(TAG_BITTORRENT);
|
||||
op->setInitialOption(true);
|
||||
op->setChangeGlobalOption(true);
|
||||
|
@ -85,7 +85,7 @@ void gnutls_log_callback(int level, const char* str)
|
||||
msg.resize(msg.size() - 1);
|
||||
A2_LOG_DEBUG(fmt("GnuTLS: <%d> %s", level, msg.c_str()));
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#endif // HAVE_LIBGNUTLS
|
||||
|
||||
bool Platform::initialized_ = false;
|
||||
|
@ -791,9 +791,10 @@ void gatherProgress(Dict* entryDict, const std::shared_ptr<RequestGroup>& group,
|
||||
gatherProgressCommon(entryDict, group, keys);
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
if (group->getDownloadContext()->hasAttribute(CTX_ATTR_BT)) {
|
||||
gatherProgressBitTorrent(entryDict, group, bittorrent::getTorrentAttrs(
|
||||
group->getDownloadContext()),
|
||||
e->getBtRegistry()->get(group->getGID()), keys);
|
||||
gatherProgressBitTorrent(
|
||||
entryDict, group,
|
||||
bittorrent::getTorrentAttrs(group->getDownloadContext()),
|
||||
e->getBtRegistry()->get(group->getGID()), keys);
|
||||
}
|
||||
#endif // ENABLE_BITTORRENT
|
||||
if (e->getCheckIntegrityMan()) {
|
||||
@ -1601,7 +1602,7 @@ void changeOption(const std::shared_ptr<RequestGroup>& group,
|
||||
#ifdef ENABLE_BITTORRENT
|
||||
&& !dctx->hasAttribute(CTX_ATTR_BT)
|
||||
#endif // ENABLE_BITTORRENT
|
||||
) {
|
||||
) {
|
||||
// In case of Metalink
|
||||
for (auto& fileEntry : dctx->getFileEntries()) {
|
||||
// PREF_OUT is not applicable to Metalink. We have always
|
||||
|
@ -135,6 +135,6 @@ private:
|
||||
LIBSSH2_SFTP_HANDLE* sftph_;
|
||||
sock_t fd_;
|
||||
};
|
||||
}
|
||||
} // namespace aria2
|
||||
|
||||
#endif // SSH_SESSION_H
|
||||
|
@ -199,7 +199,7 @@ void SelectEventPoll::poll(const struct timeval& tv)
|
||||
// winsock will report non-blocking connect() errors in efds,
|
||||
// unlike posix, which will mark such sockets as writable.
|
||||
retval = select(fdmax_ + 1, &rfds, &wfds, &efds, &ttv);
|
||||
#else // !__MINGW32__
|
||||
#else // !__MINGW32__
|
||||
retval = select(fdmax_ + 1, &rfds, &wfds, nullptr, &ttv);
|
||||
#endif // !__MINGW32__
|
||||
} while (retval == -1 && errno == EINTR);
|
||||
|
@ -223,14 +223,12 @@ bool writeDownloadResult(IOFile& fp, std::set<a2_gid_t>& metainfoCache,
|
||||
// also exists in remaining URIs.
|
||||
{
|
||||
Unique<std::string> unique;
|
||||
if (hasRemaining &&
|
||||
!writeUri(fp, file->getRemainingUris().begin(),
|
||||
file->getRemainingUris().end(), unique)) {
|
||||
if (hasRemaining && !writeUri(fp, file->getRemainingUris().begin(),
|
||||
file->getRemainingUris().end(), unique)) {
|
||||
return false;
|
||||
}
|
||||
if (hasSpent &&
|
||||
!writeUri(fp, file->getSpentUris().begin(),
|
||||
file->getSpentUris().end(), unique)) {
|
||||
if (hasSpent && !writeUri(fp, file->getSpentUris().begin(),
|
||||
file->getSpentUris().end(), unique)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -58,8 +58,9 @@ void StreamCheckIntegrityEntry::onDownloadIncomplete(
|
||||
if (getRequestGroup()->getOption()->getAsBool(PREF_HASH_CHECK_ONLY)) {
|
||||
return;
|
||||
}
|
||||
proceedFileAllocation(commands, make_unique<StreamFileAllocationEntry>(
|
||||
getRequestGroup(), popNextCommand()),
|
||||
proceedFileAllocation(commands,
|
||||
make_unique<StreamFileAllocationEntry>(
|
||||
getRequestGroup(), popNextCommand()),
|
||||
e);
|
||||
}
|
||||
|
||||
|
@ -118,6 +118,6 @@ private:
|
||||
TLSSession(const TLSSession&);
|
||||
TLSSession& operator=(const TLSSession&);
|
||||
};
|
||||
}
|
||||
} // namespace aria2
|
||||
|
||||
#endif // TLS_SESSION_H
|
||||
|
@ -47,7 +47,7 @@ class ValueBase;
|
||||
|
||||
namespace rpc {
|
||||
class XmlRpcRequestParserController;
|
||||
} // namespace rpc;
|
||||
} // namespace rpc
|
||||
|
||||
class ValueBaseStructParserState;
|
||||
|
||||
|
@ -55,8 +55,8 @@ WebSocketResponseCommand::~WebSocketResponseCommand() = default;
|
||||
void WebSocketResponseCommand::afterSend(
|
||||
const std::shared_ptr<HttpServer>& httpServer, DownloadEngine* e)
|
||||
{
|
||||
auto wsSession = std::make_shared<WebSocketSession>(
|
||||
httpServer->getSocket(), getDownloadEngine());
|
||||
auto wsSession = std::make_shared<WebSocketSession>(httpServer->getSocket(),
|
||||
getDownloadEngine());
|
||||
auto command = make_unique<WebSocketInteractionCommand>(
|
||||
getCuid(), wsSession, e, wsSession->getSocket());
|
||||
wsSession->setCommand(command.get());
|
||||
|
@ -69,6 +69,6 @@ private:
|
||||
|
||||
} // namespace rpc
|
||||
|
||||
} // aria2
|
||||
} // namespace aria2
|
||||
|
||||
#endif // D_WEB_SOCKET_SESSION_MAN_H
|
||||
|
@ -612,7 +612,7 @@ restart:
|
||||
// ... and start sending it
|
||||
state_ = st_handshake_write;
|
||||
}
|
||||
// Fall through
|
||||
// Fall through
|
||||
|
||||
case st_handshake_write_last:
|
||||
case st_handshake_write: {
|
||||
@ -644,7 +644,7 @@ restart:
|
||||
// Have to read one or more response messages.
|
||||
state_ = st_handshake_read;
|
||||
}
|
||||
// Fall through
|
||||
// Fall through
|
||||
|
||||
case st_handshake_read: {
|
||||
read:
|
||||
@ -764,7 +764,7 @@ restart:
|
||||
goto restart;
|
||||
}
|
||||
}
|
||||
// Fall through
|
||||
// Fall through
|
||||
|
||||
case st_handshake_done:
|
||||
if (obtainTLSRecordSizes() != 0) {
|
||||
|
@ -48,7 +48,7 @@ namespace {
|
||||
Console consoleCout;
|
||||
Console consoleCerr;
|
||||
Console consoleCoutBackup;
|
||||
};
|
||||
}; // namespace
|
||||
|
||||
void initConsole(bool suppress)
|
||||
{
|
||||
|
403
src/util.cc
403
src/util.cc
@ -323,7 +323,7 @@ bool isUtf8(const std::string& str)
|
||||
firstChar == 0x0au || // \n
|
||||
firstChar == 0x0cu || // \f
|
||||
firstChar == 0x0du // \r
|
||||
) {
|
||||
) {
|
||||
// UTF8-1 (without ctrl chars)
|
||||
}
|
||||
else if (in(firstChar, 0xc2u, 0xdfu)) {
|
||||
@ -810,28 +810,375 @@ static const uint8_t utf8d[] = {
|
||||
* The first part of the table maps bytes to character classes that
|
||||
* to reduce the size of the transition table and create bitmasks.
|
||||
*/
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 9, 9, 9, 9, 9, 9,
|
||||
9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 8, 8, 2, 2, 2, 2, 2, 2,
|
||||
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 10,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 3, 11, 6, 6, 6, 5, 8, 8, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
9,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
7,
|
||||
8,
|
||||
8,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
2,
|
||||
10,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
3,
|
||||
4,
|
||||
3,
|
||||
3,
|
||||
11,
|
||||
6,
|
||||
6,
|
||||
6,
|
||||
5,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
8,
|
||||
|
||||
/*
|
||||
* The second part is a transition table that maps a combination
|
||||
* of a state of the automaton and a character class to a state.
|
||||
*/
|
||||
0, 12, 24, 36, 60, 96, 84, 12, 12, 12, 48, 72, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 12, 12, 12, 12, 0, 12, 12, 12, 12, 12, 0, 12, 0, 12, 12, 12, 24, 12,
|
||||
12, 12, 12, 12, 24, 12, 24, 12, 12, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12,
|
||||
12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12, 24, 12, 12, 12, 12, 12, 12, 12,
|
||||
12, 12, 36, 12, 36, 12, 12, 12, 36, 12, 12, 12, 12, 12, 36, 12, 36, 12, 12,
|
||||
12, 36, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
|
||||
0,
|
||||
12,
|
||||
24,
|
||||
36,
|
||||
60,
|
||||
96,
|
||||
84,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
48,
|
||||
72,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
0,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
0,
|
||||
12,
|
||||
0,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
24,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
24,
|
||||
12,
|
||||
24,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
24,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
24,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
24,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
36,
|
||||
12,
|
||||
36,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
36,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
36,
|
||||
12,
|
||||
36,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
36,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
12,
|
||||
};
|
||||
|
||||
static uint32_t utf8dfa(uint32_t* state, uint32_t* codep, uint32_t byte)
|
||||
@ -1341,7 +1688,7 @@ static BOOL WINAPI HandlerRoutine(DWORD ctrlType)
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
} // namespace
|
||||
#endif
|
||||
|
||||
void setGlobalSignalHandler(int sig, sigset_t* mask, signal_handler_t handler,
|
||||
@ -1444,7 +1791,7 @@ std::string getXDGDir(const std::string& environmentVariable,
|
||||
if (p &&
|
||||
#ifndef __MINGW32__
|
||||
p[0] == '/'
|
||||
#else // __MINGW32__
|
||||
#else // __MINGW32__
|
||||
p[0] && p[1] == ':'
|
||||
#endif // __MINGW32__
|
||||
) {
|
||||
@ -1598,9 +1945,10 @@ void mkdirs(const std::string& dirpath)
|
||||
if (!dir.mkdirs()) {
|
||||
int errNum = errno;
|
||||
if (!dir.isDir()) {
|
||||
throw DL_ABORT_EX3(errNum, fmt(EX_MAKE_DIR, dir.getPath().c_str(),
|
||||
safeStrerror(errNum).c_str()),
|
||||
error_code::DIR_CREATE_ERROR);
|
||||
throw DL_ABORT_EX3(
|
||||
errNum,
|
||||
fmt(EX_MAKE_DIR, dir.getPath().c_str(), safeStrerror(errNum).c_str()),
|
||||
error_code::DIR_CREATE_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1840,12 +2188,11 @@ std::string escapePath(const std::string& s)
|
||||
unsigned char c = cc;
|
||||
if (in(c, 0x00u, 0x1fu) || c == 0x7fu
|
||||
#ifdef __MINGW32__
|
||||
||
|
||||
std::find(std::begin(WIN_INVALID_PATH_CHARS),
|
||||
std::end(WIN_INVALID_PATH_CHARS),
|
||||
c) != std::end(WIN_INVALID_PATH_CHARS)
|
||||
|| std::find(std::begin(WIN_INVALID_PATH_CHARS),
|
||||
std::end(WIN_INVALID_PATH_CHARS),
|
||||
c) != std::end(WIN_INVALID_PATH_CHARS)
|
||||
#endif // __MINGW32__
|
||||
) {
|
||||
) {
|
||||
d += fmt("%%%02X", c);
|
||||
}
|
||||
else {
|
||||
|
@ -209,10 +209,9 @@ void ChunkedDecodingStreamFilterTest::testTransform()
|
||||
void ChunkedDecodingStreamFilterTest::testTransform_withoutTrailer()
|
||||
{
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(ssize_t)0,
|
||||
filter_->transform(writer_, segment_,
|
||||
reinterpret_cast<const unsigned char*>("0\r\n\r\n"),
|
||||
5));
|
||||
(ssize_t)0, filter_->transform(
|
||||
writer_, segment_,
|
||||
reinterpret_cast<const unsigned char*>("0\r\n\r\n"), 5));
|
||||
CPPUNIT_ASSERT(filter_->finished());
|
||||
}
|
||||
|
||||
|
@ -113,12 +113,10 @@ void HandshakeExtensionMessageTest::testDoReceivedAction()
|
||||
msg.doReceivedAction();
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)6889, peer->getPort());
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(uint8_t)1,
|
||||
peer->getExtensionMessageID(ExtensionMessageRegistry::UT_PEX));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(uint8_t)3,
|
||||
peer->getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA));
|
||||
CPPUNIT_ASSERT_EQUAL((uint8_t)1, peer->getExtensionMessageID(
|
||||
ExtensionMessageRegistry::UT_PEX));
|
||||
CPPUNIT_ASSERT_EQUAL((uint8_t)3, peer->getExtensionMessageID(
|
||||
ExtensionMessageRegistry::UT_METADATA));
|
||||
CPPUNIT_ASSERT(peer->isSeeder());
|
||||
auto attrs = bittorrent::getTorrentAttrs(dctx);
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1_k, attrs->metadataSize);
|
||||
|
@ -625,8 +625,9 @@ void HttpRequestTest::testCreateRequest_wantDigest()
|
||||
"Cache-Control: no-cache\r\n"
|
||||
"Connection: close\r\n"
|
||||
"Want-Digest: " +
|
||||
wantDigest + "\r\n"
|
||||
"\r\n";
|
||||
wantDigest +
|
||||
"\r\n"
|
||||
"\r\n";
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(expectedText, httpRequest.createRequest());
|
||||
}
|
||||
|
@ -405,7 +405,7 @@ namespace {
|
||||
struct RemoveOdd {
|
||||
bool operator()(int* p) const { return *p % 2 == 1; }
|
||||
};
|
||||
}
|
||||
} // namespace
|
||||
void IndexedListTest::testRemoveIf()
|
||||
{
|
||||
int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
|
@ -140,7 +140,7 @@ void MetalinkProcessorTest::testParseFileV4()
|
||||
mu->url);
|
||||
CPPUNIT_ASSERT_EQUAL(2, mu->priority);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("torrent"), mu->mediatype);
|
||||
#else // !ENABLE_BITTORRENT
|
||||
#else // !ENABLE_BITTORRENT
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, e->metaurls.size());
|
||||
#endif // !ENABLE_BITTORRENT
|
||||
}
|
||||
|
@ -140,9 +140,8 @@ void PeerSessionResourceTest::testGetExtensionMessageID()
|
||||
res.addExtension(ExtensionMessageRegistry::UT_PEX, 9);
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(uint8_t)9, res.getExtensionMessageID(ExtensionMessageRegistry::UT_PEX));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(uint8_t)0,
|
||||
res.getExtensionMessageID(ExtensionMessageRegistry::UT_METADATA));
|
||||
CPPUNIT_ASSERT_EQUAL((uint8_t)0, res.getExtensionMessageID(
|
||||
ExtensionMessageRegistry::UT_METADATA));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("ut_pex"),
|
||||
std::string(res.getExtensionName(9)));
|
||||
|
@ -149,53 +149,38 @@ void RequestGroupManTest::testChangeReservedGroupPosition()
|
||||
std::make_shared<RequestGroup>(GroupId::create(), util::copy(option_))};
|
||||
RequestGroupMan rm(gs, 0, option_.get());
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)0,
|
||||
rm.changeReservedGroupPosition(gs[0]->getGID(), 0, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)1,
|
||||
rm.changeReservedGroupPosition(gs[0]->getGID(), 1, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)3,
|
||||
rm.changeReservedGroupPosition(gs[0]->getGID(), 10, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)0,
|
||||
rm.changeReservedGroupPosition(gs[0]->getGID(), -10, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), 0, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), 1, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), 10, OFFSET_MODE_SET));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[0]->getGID(), -10, OFFSET_MODE_SET));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)1,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), 0, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)2,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), 1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)1,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), -1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)0,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), -10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)1,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), 1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)3,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), 10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)1,
|
||||
rm.changeReservedGroupPosition(gs[1]->getGID(), -2, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 0, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), -1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), -10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 1, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), 10, OFFSET_MODE_CUR));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, rm.changeReservedGroupPosition(
|
||||
gs[1]->getGID(), -2, OFFSET_MODE_CUR));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)3,
|
||||
rm.changeReservedGroupPosition(gs[3]->getGID(), 0, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)2,
|
||||
rm.changeReservedGroupPosition(gs[3]->getGID(), -1, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)0,
|
||||
rm.changeReservedGroupPosition(gs[3]->getGID(), -10, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL(
|
||||
(size_t)3,
|
||||
rm.changeReservedGroupPosition(gs[3]->getGID(), 10, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), 0, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)2, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), -1, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)0, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), -10, OFFSET_MODE_END));
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)3, rm.changeReservedGroupPosition(
|
||||
gs[3]->getGID(), 10, OFFSET_MODE_END));
|
||||
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)4, rm.getReservedGroups().size());
|
||||
|
||||
|
@ -369,11 +369,10 @@ void RpcMethodTest::testAddTorrent()
|
||||
CPPUNIT_ASSERT_EQUAL(e_->getOption()->get(PREF_DIR) +
|
||||
"/aria2-0.8.2.tar.bz2",
|
||||
group->getFirstFilePath());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1,
|
||||
group->getDownloadContext()
|
||||
->getFirstFileEntry()
|
||||
->getRemainingUris()
|
||||
.size());
|
||||
CPPUNIT_ASSERT_EQUAL((size_t)1, group->getDownloadContext()
|
||||
->getFirstFileEntry()
|
||||
->getRemainingUris()
|
||||
.size());
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("http://localhost/aria2-0.8.2.tar.bz2"),
|
||||
group->getDownloadContext()
|
||||
->getFirstFileEntry()
|
||||
@ -1288,7 +1287,9 @@ void RpcMethodTest::testGetSessionInfo()
|
||||
void RpcMethodTest::testPause()
|
||||
{
|
||||
std::vector<std::string> uris{
|
||||
"http://url1", "http://url2", "http://url3",
|
||||
"http://url1",
|
||||
"http://url2",
|
||||
"http://url3",
|
||||
};
|
||||
option_->put(PREF_FORCE_SEQUENTIAL, A2_V_TRUE);
|
||||
std::vector<std::shared_ptr<RequestGroup>> groups;
|
||||
|
@ -61,9 +61,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user@aria2.sf.net/path/";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
|
||||
@ -72,10 +71,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user:pass@aria2.sf.net/path/";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
|
||||
@ -89,10 +87,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user@foo.com:pass@aria2.sf.net/path/";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user@foo.com:pass"),
|
||||
@ -104,9 +101,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://aria2.sf.net:443/path/";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("https"), mkstr(res, USR_SCHEME, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
|
||||
@ -116,10 +112,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user:pass@aria2.sf.net:443/path/";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH) | (1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
|
||||
@ -131,9 +126,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user@aria2.sf.net:443/path/";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH) | (1 << USR_USERINFO) | (1 << USR_USER));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2.sf.net"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/path/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
|
||||
@ -157,9 +152,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user@aria2";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
@ -167,9 +161,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user:@aria2";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user:"), mkstr(res, USR_USERINFO, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
@ -178,9 +172,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://aria2/?foo#bar";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY) | (1 << USR_FRAGMENT));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY) | (1 << USR_FRAGMENT));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("foo"), mkstr(res, USR_QUERY, uri));
|
||||
@ -207,9 +200,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://aria2:443?foo";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_QUERY));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_QUERY));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("foo"), mkstr(res, USR_QUERY, uri));
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)443, res.port);
|
||||
@ -218,9 +210,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://aria2:443#bar";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_FRAGMENT));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_FRAGMENT));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("bar"), mkstr(res, USR_FRAGMENT, uri));
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)443, res.port);
|
||||
@ -229,10 +220,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user:pass@aria2:443?foo";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_QUERY) | (1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_QUERY) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("pass"), mkstr(res, USR_PASSWD, uri));
|
||||
@ -243,10 +233,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user:pass@aria2:443#bar";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_FRAGMENT) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_FRAGMENT) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("pass"), mkstr(res, USR_PASSWD, uri));
|
||||
@ -257,10 +246,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user:pass@aria2?foo";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_QUERY) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_QUERY) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("pass"), mkstr(res, USR_PASSWD, uri));
|
||||
@ -270,10 +258,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://user:pass@aria2#bar";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_FRAGMENT) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
|
||||
(1 << USR_FRAGMENT) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("pass"), mkstr(res, USR_PASSWD, uri));
|
||||
@ -283,9 +270,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://aria2/?";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), mkstr(res, USR_QUERY, uri));
|
||||
@ -294,9 +280,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://aria2/#";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_FRAGMENT));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_FRAGMENT));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), mkstr(res, USR_FRAGMENT, uri));
|
||||
@ -305,9 +290,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://aria2/?#";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY) | (1 << USR_FRAGMENT));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY) | (1 << USR_FRAGMENT));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("aria2"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string(""), mkstr(res, USR_QUERY, uri));
|
||||
@ -333,9 +317,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user@[::1]";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("::1"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USERINFO, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
@ -345,9 +328,9 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user:pass@[::1]";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("::1"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user"), mkstr(res, USR_USER, uri));
|
||||
@ -357,18 +340,16 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://aria2/f";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_BASENAME));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_BASENAME));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("f"), mkstr(res, USR_BASENAME, uri));
|
||||
|
||||
uri = "http://[::1]/f";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_BASENAME));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_BASENAME));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("::1"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("f"), mkstr(res, USR_BASENAME, uri));
|
||||
@ -376,9 +357,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://[::1]:8080/f";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH) | (1 << USR_BASENAME));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PORT) |
|
||||
(1 << USR_PATH) | (1 << USR_BASENAME));
|
||||
CPPUNIT_ASSERT_EQUAL((uint16_t)8080, res.port);
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("f"), mkstr(res, USR_BASENAME, uri));
|
||||
@ -386,10 +366,10 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "https://user:pass@host/f";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_USERINFO) |
|
||||
(1 << USR_USER) | (1 << USR_PASSWD) | (1 << USR_PATH) |
|
||||
(1 << USR_BASENAME));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) |
|
||||
(1 << USR_USERINFO) | (1 << USR_USER) |
|
||||
(1 << USR_PASSWD) | (1 << USR_PATH) |
|
||||
(1 << USR_BASENAME));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("host"), mkstr(res, USR_HOST, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("user:pass"), mkstr(res, USR_USERINFO, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/f"), mkstr(res, USR_PATH, uri));
|
||||
@ -398,9 +378,8 @@ void UriSplitTest::testUriSplit()
|
||||
uri = "http://aria2/index.html?foo";
|
||||
memset(&res, 0, sizeof(res));
|
||||
CPPUNIT_ASSERT_EQUAL(0, uri_split(&res, uri));
|
||||
CHECK_FIELD_SET(res,
|
||||
(1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY) | (1 << USR_BASENAME));
|
||||
CHECK_FIELD_SET(res, (1 << USR_SCHEME) | (1 << USR_HOST) | (1 << USR_PATH) |
|
||||
(1 << USR_QUERY) | (1 << USR_BASENAME));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("/index.html"), mkstr(res, USR_PATH, uri));
|
||||
CPPUNIT_ASSERT_EQUAL(std::string("index.html"),
|
||||
mkstr(res, USR_BASENAME, uri));
|
||||
|
Loading…
Reference in New Issue
Block a user