pull/538/head
Tatsuhiro Tsujikawa 2015-12-23 17:34:09 +09:00
parent 8512fe992e
commit bc1c9cae00
1 changed files with 23 additions and 23 deletions

View File

@ -188,7 +188,6 @@ void HttpSkipResponseCommand::poolConnection() const
bool HttpSkipResponseCommand::processResponse()
{
int statusCode;
if(httpResponse_->isRedirect()) {
int rnum =
httpResponse_->getHttpRequest()->getRequest()->getRedirectCount();
@ -198,43 +197,44 @@ bool HttpSkipResponseCommand::processResponse()
}
httpResponse_->processRedirect();
return prepareForRetry(0);
} else if((statusCode = httpResponse_->getStatusCode()) >= 400) {
if(statusCode == 401) {
}
auto statusCode = httpResponse_->getStatusCode();
if (statusCode >= 400) {
switch (statusCode) {
case 401:
if (getOption()->getAsBool(PREF_HTTP_AUTH_CHALLENGE) &&
!httpResponse_->getHttpRequest()->authenticationUsed() &&
getDownloadEngine()->getAuthConfigFactory()->activateBasicCred
(getRequest()->getHost(), getRequest()->getPort(),
getDownloadEngine()->getAuthConfigFactory()->activateBasicCred(
getRequest()->getHost(), getRequest()->getPort(),
getRequest()->getDir(), getOption().get())) {
return prepareForRetry(0);
} else {
throw DL_ABORT_EX2(EX_AUTH_FAILED,
error_code::HTTP_AUTH_FAILED);
}
} else if(statusCode == 404) {
throw DL_ABORT_EX2(EX_AUTH_FAILED, error_code::HTTP_AUTH_FAILED);
case 404:
if (getOption()->getAsInt(PREF_MAX_FILE_NOT_FOUND) == 0) {
throw DL_ABORT_EX2(MSG_RESOURCE_NOT_FOUND,
error_code::RESOURCE_NOT_FOUND);
}
throw DL_RETRY_EX2(MSG_RESOURCE_NOT_FOUND,
error_code::RESOURCE_NOT_FOUND);
} else if(statusCode == 503) {
case 503:
// Only retry if pretry-wait > 0. Hammering 'busy' server is not
// a good idea.
if (getOption()->getAsInt(PREF_RETRY_WAIT) > 0) {
throw DL_RETRY_EX2(fmt(EX_BAD_STATUS, statusCode),
error_code::HTTP_SERVICE_UNAVAILABLE);
} else {
}
throw DL_ABORT_EX2(fmt(EX_BAD_STATUS, statusCode),
error_code::HTTP_SERVICE_UNAVAILABLE);
}
} else {
};
throw DL_ABORT_EX2(fmt(EX_BAD_STATUS, statusCode),
error_code::HTTP_PROTOCOL_ERROR);
}
} else {
return prepareForRetry(0);
}
}
void HttpSkipResponseCommand::disableSocketCheck()
{