diff --git a/ChangeLog b/ChangeLog index d71bbd5b..54f6439a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2009-02-07 Tatsuhiro Tsujikawa + + Changed the default value of --proxy-method option from 'tunnel' + to 'get'. Use 'tunnel' for HTTPS regardless of --proxy-method + option. + * src/AbstractCommand.cc + * src/AbstractCommand.h + * src/FtpInitiateConnectionCommand.cc + * src/HttpDownloadCommand.cc + * src/HttpInitiateConnectionCommand.cc + * src/HttpInitiateConnectionCommand.h + * src/OptionHandlerFactory.cc + 2009-02-07 Tatsuhiro Tsujikawa Initialized _logger diff --git a/src/AbstractCommand.cc b/src/AbstractCommand.cc index c2d440b1..361c4bdd 100644 --- a/src/AbstractCommand.cc +++ b/src/AbstractCommand.cc @@ -323,14 +323,6 @@ static bool isProxyRequest(const std::string& protocol, const Option* option) (protocol == Request::PROTO_FTP && isProxyUsed(PREF_FTP_PROXY, option)); } -static bool isProxyGETRequest(const std::string& protocol, const Option* option) -{ - if(option->get(PREF_PROXY_METHOD) != V_GET) { - return false; - } - return isProxyRequest(protocol, option); -} - class DomainMatch { private: std::string _hostname; @@ -478,7 +470,8 @@ void AbstractCommand::checkIfConnectionEstablished std::string error = socket->getSocketError(); if(!error.empty()) { // Don't set error if proxy server is used and its method is GET. - if(!isProxyGETRequest(req->getProtocol(), e->option)) { + if(resolveProxyMethod(req->getProtocol()) != V_GET || + !isProxyRequest(req->getProtocol(), e->option)) { e->_requestGroupMan->getOrCreateServerStat (req->getHost(), req->getProtocol())->setError(); } @@ -488,4 +481,15 @@ void AbstractCommand::checkIfConnectionEstablished } } +const std::string& AbstractCommand::resolveProxyMethod +(const std::string& protocol) const +{ + if(e->option->get(PREF_PROXY_METHOD) == V_TUNNEL || + Request::PROTO_HTTPS == protocol) { + return V_TUNNEL; + } else { + return V_GET; + } +} + } // namespace aria2 diff --git a/src/AbstractCommand.h b/src/AbstractCommand.h index 6d3d1f70..a4570c95 100644 --- a/src/AbstractCommand.h +++ b/src/AbstractCommand.h @@ -112,6 +112,11 @@ protected: * If no valid proxy is defined, then returns SharedHandle(). */ SharedHandle createProxyRequest() const; + + + // Returns proxy method for given protocol. Either V_GET or V_TUNNEL + // is returned. For HTTPS, always returns V_TUNNEL. + const std::string& resolveProxyMethod(const std::string& protocol) const; private: bool checkSocketIsReadable; bool checkSocketIsWritable; diff --git a/src/FtpInitiateConnectionCommand.cc b/src/FtpInitiateConnectionCommand.cc index f0f65948..f4b2b005 100644 --- a/src/FtpInitiateConnectionCommand.cc +++ b/src/FtpInitiateConnectionCommand.cc @@ -71,6 +71,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand std::map options; SharedHandle pooledSocket = e->popPooledSocket(options, req->getHost(), req->getPort()); + std::string proxyMethod = resolveProxyMethod(req->getProtocol()); if(pooledSocket.isNull()) { logger->info(MSG_CONNECTING_TO_SERVER, cuid, proxyRequest->getHost().c_str(), proxyRequest->getPort()); @@ -78,7 +79,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand socket->establishConnection(resolvedAddresses.front(), proxyRequest->getPort()); - if(e->option->get(PREF_PROXY_METHOD) == V_GET) { + if(proxyMethod == V_GET) { SharedHandle hc (new HttpConnection(cuid, socket, e->option)); @@ -86,7 +87,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand new HttpRequestCommand(cuid, req, _requestGroup, hc, e, socket); c->setProxyRequest(proxyRequest); command = c; - } else if(e->option->get(PREF_PROXY_METHOD) == V_TUNNEL) { + } else if(proxyMethod == V_TUNNEL) { command = new FtpTunnelRequestCommand(cuid, req, _requestGroup, e, proxyRequest, socket); } else { @@ -94,12 +95,12 @@ Command* FtpInitiateConnectionCommand::createNextCommand throw DlAbortEx("ERROR"); } } else { - if(e->option->get(PREF_PROXY_METHOD) == V_TUNNEL) { + if(proxyMethod == V_TUNNEL) { command = new FtpNegotiationCommand(cuid, req, _requestGroup, e, pooledSocket, FtpNegotiationCommand::SEQ_SEND_CWD, options["baseWorkingDir"]); - } else if(e->option->get(PREF_PROXY_METHOD) == V_GET) { + } else if(proxyMethod == V_GET) { SharedHandle hc (new HttpConnection(cuid, pooledSocket, e->option)); diff --git a/src/HttpDownloadCommand.cc b/src/HttpDownloadCommand.cc index df5711f7..69b09be1 100644 --- a/src/HttpDownloadCommand.cc +++ b/src/HttpDownloadCommand.cc @@ -71,7 +71,7 @@ bool HttpDownloadCommand::prepareForNextSegment() { socket); // Set proxy request here. aria2 sends the HTTP request specialized for // proxy. - if(e->option->get(PREF_PROXY_METHOD) == V_GET) { + if(resolveProxyMethod(req->getProtocol()) == V_GET) { command->setProxyRequest(createProxyRequest()); } e->commands.push_back(command); diff --git a/src/HttpInitiateConnectionCommand.cc b/src/HttpInitiateConnectionCommand.cc index 6e67718a..35211c56 100644 --- a/src/HttpInitiateConnectionCommand.cc +++ b/src/HttpInitiateConnectionCommand.cc @@ -67,6 +67,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand if(!proxyRequest.isNull()) { SharedHandle pooledSocket = e->popPooledSocket(req->getHost(), req->getPort()); + std::string proxyMethod = resolveProxyMethod(req->getProtocol()); if(pooledSocket.isNull()) { logger->info(MSG_CONNECTING_TO_SERVER, cuid, proxyRequest->getHost().c_str(), proxyRequest->getPort()); @@ -74,10 +75,10 @@ Command* HttpInitiateConnectionCommand::createNextCommand socket->establishConnection(resolvedAddresses.front(), proxyRequest->getPort()); - if(useProxyTunnel()) { + if(proxyMethod == V_TUNNEL) { command = new HttpProxyRequestCommand(cuid, req, _requestGroup, e, proxyRequest, socket); - } else if(useProxyGet()) { + } else if(proxyMethod == V_GET) { SharedHandle httpConnection (new HttpConnection(cuid, socket, e->option)); HttpRequestCommand* c = new HttpRequestCommand(cuid, req, _requestGroup, @@ -95,7 +96,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand HttpRequestCommand* c = new HttpRequestCommand(cuid, req, _requestGroup, httpConnection, e, pooledSocket); - if(useProxyGet()) { + if(proxyMethod == V_GET) { c->setProxyRequest(proxyRequest); } command = c; @@ -118,14 +119,4 @@ Command* HttpInitiateConnectionCommand::createNextCommand return command; } -bool HttpInitiateConnectionCommand::useProxyGet() const -{ - return e->option->get(PREF_PROXY_METHOD) == V_GET; -} - -bool HttpInitiateConnectionCommand::useProxyTunnel() const -{ - return e->option->get(PREF_PROXY_METHOD) == V_TUNNEL; -} - } // namespace aria2 diff --git a/src/HttpInitiateConnectionCommand.h b/src/HttpInitiateConnectionCommand.h index a469b7a1..cd7ec83c 100644 --- a/src/HttpInitiateConnectionCommand.h +++ b/src/HttpInitiateConnectionCommand.h @@ -40,9 +40,6 @@ namespace aria2 { class HttpInitiateConnectionCommand : public InitiateConnectionCommand { -private: - bool useProxyGet() const; - bool useProxyTunnel() const; protected: virtual Command* createNextCommand (const std::deque& resolvedAddresses, diff --git a/src/OptionHandlerFactory.cc b/src/OptionHandlerFactory.cc index df0df63c..a7432944 100644 --- a/src/OptionHandlerFactory.cc +++ b/src/OptionHandlerFactory.cc @@ -751,7 +751,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers() SharedHandle op(new ParameterOptionHandler (PREF_PROXY_METHOD, TEXT_PROXY_METHOD, - V_TUNNEL, + V_GET, V_GET, V_TUNNEL)); op->addTag(TAG_FTP); op->addTag(TAG_HTTP);