2008-12-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added --use-head option to toggle whether HEAD method should be
	used in the first HTTP request. By default aria2 uses HEAD
	method as the first request. When the server doesn't recognize
	HEAD, then give aria2 --use-head=false to force aria2 to use GET
	method instead.
	* src/OptionHandlerFactory.cc
	* src/RequestGroupMan.cc
	* src/option_processing.cc
	* src/prefs.cc
	* src/prefs.h
	* src/usage_text.h
pull/1/head
Tatsuhiro Tsujikawa 2008-12-29 14:05:39 +00:00
parent 992f82eb5a
commit 5db28b5a03
7 changed files with 48 additions and 2 deletions

View File

@ -1,3 +1,17 @@
2008-12-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added --use-head option to toggle whether HEAD method should be
used in the first HTTP request. By default aria2 uses HEAD method
as the first request. When the server doesn't recognize HEAD, then
give aria2 --use-head=false to force aria2 to use GET method
instead.
* src/OptionHandlerFactory.cc
* src/RequestGroupMan.cc
* src/option_processing.cc
* src/prefs.cc
* src/prefs.h
* src/usage_text.h
2008-12-29 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Fixed the bug that BitTorrent download doesn't finish when REJECT

View File

@ -539,6 +539,14 @@ OptionHandlers OptionHandlerFactory::createOptionHandlers()
op->addTag(TAG_HTTP);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new DefaultOptionHandler
(PREF_USE_HEAD,
TEXT_USE_HEAD,
V_TRUE));
op->addTag(TAG_HTTP);
handlers.push_back(op);
}
{
SharedHandle<OptionHandler> op(new DefaultOptionHandler
(PREF_USER_AGENT,

View File

@ -268,6 +268,17 @@ void RequestGroupMan::configureRequestGroup
}
}
static void createInitialCommand(const SharedHandle<RequestGroup>& requestGroup,
std::deque<Command*>& commands,
DownloadEngine* e,
bool useHead)
{
requestGroup->createInitialCommand(commands, e,
useHead ?
Request::METHOD_HEAD :
Request::METHOD_GET);
}
void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
{
RequestGroups temp;
@ -284,7 +295,8 @@ void RequestGroupMan::fillRequestGroupFromReserver(DownloadEngine* e)
}
configureRequestGroup(groupToAdd);
Commands commands;
groupToAdd->createInitialCommand(commands, e);
createInitialCommand(groupToAdd, commands, e,
_option->getAsBool(PREF_USE_HEAD));
_requestGroups.push_back(groupToAdd);
++count;
e->addCommand(commands);
@ -308,7 +320,8 @@ void RequestGroupMan::getInitialCommands(std::deque<Command*>& commands,
try {
if((*itr)->isDependencyResolved()) {
configureRequestGroup(*itr);
(*itr)->createInitialCommand(commands, e);
createInitialCommand(*itr, commands, e,
_option->getAsBool(PREF_USE_HEAD));
++itr;
} else {
_reservedGroups.push_front((*itr));

View File

@ -189,6 +189,7 @@ Option* option_processing(int argc, char* const argv[])
{ PREF_CA_CERTIFICATE.c_str(), optional_argument, &lopt, 233 },
{ PREF_CHECK_CERTIFICATE.c_str(), optional_argument, &lopt, 234 },
{ PREF_NO_PROXY.c_str(), required_argument, &lopt, 235 },
{ PREF_USE_HEAD.c_str(), optional_argument, &lopt, 236 },
#if defined ENABLE_BITTORRENT || defined ENABLE_METALINK
{ PREF_SHOW_FILES.c_str(), no_argument, NULL, 'S' },
{ PREF_SELECT_FILE.c_str(), required_argument, &lopt, 21 },
@ -470,6 +471,9 @@ Option* option_processing(int argc, char* const argv[])
case 235:
cmdstream << PREF_NO_PROXY << "=" << optarg << "\n";
break;
case 236:
cmdstream << PREF_USE_HEAD << "=" << toBoolArg(optarg) << "\n";
break;
}
break;
}

View File

@ -188,6 +188,8 @@ const std::string PREF_PRIVATE_KEY("private-key");
const std::string PREF_CA_CERTIFICATE("ca-certificate");
// value: true | false
const std::string PREF_CHECK_CERTIFICATE("check-certificate");
// value: true | false
const std::string PREF_USE_HEAD("use-head");
/**
* Proxy related preferences

View File

@ -192,6 +192,8 @@ extern const std::string PREF_PRIVATE_KEY;
extern const std::string PREF_CA_CERTIFICATE;
// value: true | false
extern const std::string PREF_CHECK_CERTIFICATE;
// value: true | false
extern const std::string PREF_USE_HEAD;
/**;
* Proxy related preferences

View File

@ -434,3 +434,6 @@ _(" --check-certificate[=true|false] Verify the peer using certificates specifie
#define TEXT_NO_PROXY \
_(" --no-proxy=DOMAINS Specify comma separated hostnames or domains where\n"\
" proxy should not be used.")
#define TEXT_USE_HEAD \
_(" --use-head[=true|false] Use HEAD method for the first request to the HTTP\n"\
" server.")