From adeead6f0396e2f8551d1182972e277728fd6c8b Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Tue, 3 Jun 2014 23:22:18 +0900 Subject: Revert to existing "proper" coding style The rule is simple: don't try to change the coding style of the existing codebase. --- src/HttpResponseCommand.cc | 127 ++++++++++++++++++++++----------------------- 1 file changed, 63 insertions(+), 64 deletions(-) (limited to 'src/HttpResponseCommand.cc') diff --git a/src/HttpResponseCommand.cc b/src/HttpResponseCommand.cc index 7c44991a..34ae1cc8 100644 --- a/src/HttpResponseCommand.cc +++ b/src/HttpResponseCommand.cc @@ -85,9 +85,9 @@ namespace aria2 { namespace { -std::unique_ptr getTransferEncodingStreamFilter( - HttpResponse* httpResponse, - std::unique_ptr delegate = nullptr) +std::unique_ptr getTransferEncodingStreamFilter +(HttpResponse* httpResponse, + std::unique_ptr delegate = nullptr) { if (httpResponse->isTransferEncodingSpecified()) { auto filter = httpResponse->getTransferEncodingStreamFilter(); @@ -103,9 +103,9 @@ std::unique_ptr getTransferEncodingStreamFilter( return delegate; } -std::unique_ptr getContentEncodingStreamFilter( - HttpResponse* httpResponse, - std::unique_ptr delegate = nullptr) +std::unique_ptr getContentEncodingStreamFilter +(HttpResponse* httpResponse, + std::unique_ptr delegate = nullptr) { if (httpResponse->isContentEncodingSpecified()) { auto filter = httpResponse->getContentEncodingStreamFilter(); @@ -125,16 +125,15 @@ std::unique_ptr getContentEncodingStreamFilter( } // namespace -HttpResponseCommand::HttpResponseCommand( - cuid_t cuid, - const std::shared_ptr& req, - const std::shared_ptr& fileEntry, - RequestGroup* requestGroup, - const std::shared_ptr& httpConnection, - DownloadEngine* e, - const std::shared_ptr& s) - : - AbstractCommand(cuid, req, fileEntry, requestGroup, e, s, +HttpResponseCommand::HttpResponseCommand +(cuid_t cuid, + const std::shared_ptr& req, + const std::shared_ptr& fileEntry, + RequestGroup* requestGroup, + const std::shared_ptr& httpConnection, + DownloadEngine* e, + const std::shared_ptr& s) + : AbstractCommand(cuid, req, fileEntry, requestGroup, e, s, httpConnection->getSocketRecvBuffer()), httpConnection_(httpConnection) { @@ -164,11 +163,11 @@ bool HttpResponseCommand::executeInternal() // Connection: close is received or the remote server is not HTTP/1.1. // We don't care whether non-HTTP/1.1 server returns Connection: keep-alive. auto& req = getRequest(); - req->supportsPersistentConnection( - httpResponse->supportsPersistentConnection()); + req->supportsPersistentConnection + (httpResponse->supportsPersistentConnection()); if (req->isPipeliningEnabled()) { - req->setMaxPipelinedRequest( - getOption()->getAsInt(PREF_MAX_HTTP_PIPELINING)); + req->setMaxPipelinedRequest + (getOption()->getAsInt(PREF_MAX_HTTP_PIPELINING)); } else { req->setMaxPipelinedRequest(1); @@ -297,18 +296,18 @@ bool HttpResponseCommand::executeInternal() // Also we can't resume in this case too. So truncate the file // anyway. getPieceStorage()->getDiskAdaptor()->truncate(0); - auto teFilter = getTransferEncodingStreamFilter( - httpResponse.get(), - getContentEncodingStreamFilter(httpResponse.get())); - getDownloadEngine()->addCommand( - createHttpDownloadCommand(std::move(httpResponse), - std::move(teFilter))); + auto teFilter = getTransferEncodingStreamFilter + (httpResponse.get(), + getContentEncodingStreamFilter(httpResponse.get())); + getDownloadEngine()->addCommand + (createHttpDownloadCommand(std::move(httpResponse), + std::move(teFilter))); } else { auto teFilter = getTransferEncodingStreamFilter(httpResponse.get()); - getDownloadEngine()->addCommand( - createHttpDownloadCommand(std::move(httpResponse), - std::move(teFilter))); + getDownloadEngine()->addCommand + (createHttpDownloadCommand(std::move(httpResponse), + std::move(teFilter))); } return true; @@ -321,8 +320,8 @@ void HttpResponseCommand::updateLastModifiedTime(const Time& lastModified) } } -bool HttpResponseCommand::shouldInflateContentEncoding( - HttpResponse* httpResponse) +bool HttpResponseCommand::shouldInflateContentEncoding +(HttpResponse* httpResponse) { // Basically, on the fly inflation cannot be made with segment // download, because in each segment we don't know where the date @@ -336,11 +335,11 @@ bool HttpResponseCommand::shouldInflateContentEncoding( (ce == "gzip" || ce == "deflate"); } -bool HttpResponseCommand::handleDefaultEncoding( - std::unique_ptr httpResponse) +bool HttpResponseCommand::handleDefaultEncoding +(std::unique_ptr httpResponse) { - auto progressInfoFile = std::make_shared( - getDownloadContext(), std::shared_ptr{}, getOption().get()); + auto progressInfoFile = std::make_shared + (getDownloadContext(), std::shared_ptr{}, getOption().get()); getRequestGroup()->adjustFilename(progressInfoFile); getRequestGroup()->initPieceStorage(); @@ -368,9 +367,9 @@ bool HttpResponseCommand::handleDefaultEncoding( segment && segment->getPositionToWrite() == 0 && !getRequest()->isPipeliningEnabled()) { auto teFilter = getTransferEncodingStreamFilter(httpResponse.get()); - checkEntry->pushNextCommand( - createHttpDownloadCommand(std::move(httpResponse), - std::move(teFilter))); + checkEntry->pushNextCommand + (createHttpDownloadCommand(std::move(httpResponse), + std::move(teFilter))); } else { getSegmentMan()->cancelSegment(getCuid()); @@ -387,8 +386,8 @@ bool HttpResponseCommand::handleDefaultEncoding( return true; } -bool HttpResponseCommand::handleOtherEncoding( - std::unique_ptr httpResponse) +bool HttpResponseCommand::handleOtherEncoding +(std::unique_ptr httpResponse) { // We assume that RequestGroup::getTotalLength() == 0 here if (getOption()->getAsBool(PREF_DRY_RUN)) { @@ -406,8 +405,8 @@ bool HttpResponseCommand::handleOtherEncoding( // In this context, knowsTotalLength() is true only when the file is // really zero-length. - auto streamFilter = getTransferEncodingStreamFilter( - httpResponse.get(), getContentEncodingStreamFilter(httpResponse.get())); + auto streamFilter = getTransferEncodingStreamFilter + (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 && @@ -469,23 +468,23 @@ bool HttpResponseCommand::handleOtherEncoding( // AbstractCommand::execute() getSegmentMan()->getSegmentWithIndex(getCuid(), 0); - getDownloadEngine()->addCommand( - createHttpDownloadCommand(std::move(httpResponse), - std::move(streamFilter))); + getDownloadEngine()->addCommand + (createHttpDownloadCommand(std::move(httpResponse), + std::move(streamFilter))); return true; } -bool HttpResponseCommand::skipResponseBody( - std::unique_ptr httpResponse) +bool HttpResponseCommand::skipResponseBody +(std::unique_ptr httpResponse) { auto filter = getTransferEncodingStreamFilter(httpResponse.get()); // We don't use Content-Encoding here because this response body is just // thrown away. auto httpResponsePtr = httpResponse.get(); - auto command = make_unique( - getCuid(), getRequest(), getFileEntry(), getRequestGroup(), - httpConnection_, std::move(httpResponse), getDownloadEngine(), - getSocket()); + auto command = make_unique + (getCuid(), getRequest(), getFileEntry(), getRequestGroup(), + httpConnection_, std::move(httpResponse), getDownloadEngine(), + getSocket()); command->installStreamFilter(std::move(filter)); // If request method is HEAD or the response body is zero-length, @@ -524,25 +523,25 @@ bool decideFileAllocation(StreamFilter* filter) } // namespace std::unique_ptr -HttpResponseCommand::createHttpDownloadCommand( - std::unique_ptr httpResponse, - std::unique_ptr filter) +HttpResponseCommand::createHttpDownloadCommand +(std::unique_ptr httpResponse, + std::unique_ptr filter) { - auto command = make_unique( - getCuid(), getRequest(), getFileEntry(), getRequestGroup(), - std::move(httpResponse), httpConnection_, getDownloadEngine(), - getSocket()); + auto command = make_unique + (getCuid(), getRequest(), getFileEntry(), getRequestGroup(), + std::move(httpResponse), httpConnection_, getDownloadEngine(), + getSocket()); command->setStartupIdleTime(getOption()->getAsInt(PREF_STARTUP_IDLE_TIME)); - command->setLowestDownloadSpeedLimit( - getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT)); + command->setLowestDownloadSpeedLimit + (getOption()->getAsInt(PREF_LOWEST_SPEED_LIMIT)); if (getRequestGroup()->isFileAllocationEnabled() && !decideFileAllocation(filter.get())) { getRequestGroup()->setFileAllocationEnabled(false); } command->installStreamFilter(std::move(filter)); - getRequestGroup()->getURISelector()->tuneDownloadCommand( - getFileEntry()->getRemainingUris(), command.get()); + getRequestGroup()->getURISelector()->tuneDownloadCommand + (getFileEntry()->getRemainingUris(), command.get()); return std::move(command); } @@ -562,8 +561,8 @@ void HttpResponseCommand::onDryRunFileFound() poolConnection(); } -bool HttpResponseCommand::checkChecksum( - const std::shared_ptr& dctx, const Checksum& checksum) +bool HttpResponseCommand::checkChecksum +(const std::shared_ptr& dctx, const Checksum& checksum) { if (dctx->getHashType() == checksum.getHashType()) { if (dctx->getDigest() != checksum.getDigest()) { -- cgit