2009-02-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

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
pull/1/head
Tatsuhiro Tsujikawa 2009-02-07 13:46:08 +00:00
parent 1b854afe44
commit 997a0c29d1
8 changed files with 42 additions and 31 deletions

View File

@ -1,3 +1,16 @@
2009-02-07 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
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 <t-tujikawa@users.sourceforge.net>
Initialized _logger

View File

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

View File

@ -112,6 +112,11 @@ protected:
* If no valid proxy is defined, then returns SharedHandle<Request>().
*/
SharedHandle<Request> 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;

View File

@ -71,6 +71,7 @@ Command* FtpInitiateConnectionCommand::createNextCommand
std::map<std::string, std::string> options;
SharedHandle<SocketCore> 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<HttpConnection> 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<HttpConnection> hc
(new HttpConnection(cuid, pooledSocket, e->option));

View File

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

View File

@ -67,6 +67,7 @@ Command* HttpInitiateConnectionCommand::createNextCommand
if(!proxyRequest.isNull()) {
SharedHandle<SocketCore> 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> 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

View File

@ -40,9 +40,6 @@
namespace aria2 {
class HttpInitiateConnectionCommand : public InitiateConnectionCommand {
private:
bool useProxyGet() const;
bool useProxyTunnel() const;
protected:
virtual Command* createNextCommand
(const std::deque<std::string>& resolvedAddresses,

View File

@ -751,7 +751,7 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
SharedHandle<OptionHandler> 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);