/* */ #include "AbstractProxyRequestCommand.h" #include "DownloadEngine.h" #include "RequestGroup.h" #include "Request.h" #include "HttpConnection.h" #include "HttpRequest.h" #include "Segment.h" #include "Option.h" #include "prefs.h" #include "SocketCore.h" #include "DownloadContext.h" #include "SocketRecvBuffer.h" #include "fmt.h" #include "LogFactory.h" namespace aria2 { AbstractProxyRequestCommand::AbstractProxyRequestCommand (cuid_t cuid, const std::shared_ptr& req, const std::shared_ptr& fileEntry, RequestGroup* requestGroup, DownloadEngine* e, const std::shared_ptr& proxyRequest, const std::shared_ptr& s) : AbstractCommand(cuid, req, fileEntry, requestGroup, e, s), proxyRequest_(proxyRequest), httpConnection_ (new HttpConnection (cuid, s, std::shared_ptr(new SocketRecvBuffer(s)))) { setTimeout(getOption()->getAsInt(PREF_CONNECT_TIMEOUT)); disableReadCheckSocket(); setWriteCheckSocket(getSocket()); } AbstractProxyRequestCommand::~AbstractProxyRequestCommand() {} bool AbstractProxyRequestCommand::executeInternal() { //socket->setBlockingMode(); if(httpConnection_->sendBufferIsEmpty()) { auto httpRequest = make_unique(); httpRequest->setUserAgent(getOption()->get(PREF_USER_AGENT)); httpRequest->setRequest(getRequest()); httpRequest->setProxyRequest(proxyRequest_); httpConnection_->sendProxyRequest(std::move(httpRequest)); } else { httpConnection_->sendPendingData(); } if(httpConnection_->sendBufferIsEmpty()) { getDownloadEngine()->addCommand(getNextCommand()); return true; } else { setWriteCheckSocket(getSocket()); addCommandSelf(); return false; } } } // namespace aria2