mirror of https://github.com/aria2/aria2
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Defined HTTP status as static const std::string * src/AbstractProxyResponseCommand.cc * src/HttpHeader.cc * src/HttpHeader.h * src/HttpResponse.cc * src/HttpResponseCommand.cc * src/HttpSkipResponseCommand.ccpull/1/head
parent
9a98c71972
commit
158563d16a
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Defined HTTP status as static const std::string
|
||||
* src/AbstractProxyResponseCommand.cc
|
||||
* src/HttpHeader.cc
|
||||
* src/HttpHeader.h
|
||||
* src/HttpResponse.cc
|
||||
* src/HttpResponseCommand.cc
|
||||
* src/HttpSkipResponseCommand.cc
|
||||
|
||||
2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
|
||||
|
||||
Defined "\r\n", "A", "I" as static const std::string
|
||||
|
|
|
@ -44,6 +44,7 @@
|
|||
#include "Socket.h"
|
||||
#include "DlRetryEx.h"
|
||||
#include "message.h"
|
||||
#include "HttpHeader.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -65,7 +66,7 @@ bool AbstractProxyResponseCommand::executeInternal() {
|
|||
e->commands.push_back(this);
|
||||
return false;
|
||||
}
|
||||
if(httpResponse->getResponseStatus() != "200") {
|
||||
if(httpResponse->getResponseStatus() != HttpHeader::S200) {
|
||||
throw DlRetryEx(EX_PROXY_CONNECTION_FAILED);
|
||||
}
|
||||
e->commands.push_back(getNextCommand());
|
||||
|
|
|
@ -64,6 +64,16 @@ const std::string HttpHeader::CONTENT_RANGE("Content-Range");
|
|||
|
||||
const std::string HttpHeader::HTTP_1_1("HTTP/1.1");
|
||||
|
||||
const std::string HttpHeader::S200("200");
|
||||
|
||||
const std::string HttpHeader::S300("300");
|
||||
|
||||
const std::string HttpHeader::S400("400");
|
||||
|
||||
const std::string HttpHeader::S401("401");
|
||||
|
||||
const std::string HttpHeader::S404("404");
|
||||
|
||||
void HttpHeader::put(const std::string& name, const std::string& value) {
|
||||
std::multimap<std::string, std::string>::value_type vt(Util::toLower(name), value);
|
||||
table.insert(vt);
|
||||
|
|
|
@ -102,6 +102,16 @@ public:
|
|||
static const std::string CONTENT_RANGE;
|
||||
|
||||
static const std::string HTTP_1_1;
|
||||
|
||||
static const std::string S200;
|
||||
|
||||
static const std::string S300;
|
||||
|
||||
static const std::string S400;
|
||||
|
||||
static const std::string S401;
|
||||
|
||||
static const std::string S404;
|
||||
};
|
||||
|
||||
typedef SharedHandle<HttpHeader> HttpHeaderHandle;
|
||||
|
|
|
@ -60,10 +60,10 @@ HttpResponse::~HttpResponse() {}
|
|||
void HttpResponse::validateResponse() const
|
||||
{
|
||||
const std::string& status = getResponseStatus();
|
||||
if(status >= "400") {
|
||||
if(status >= HttpHeader::S400) {
|
||||
return;
|
||||
}
|
||||
if(status >= "300") {
|
||||
if(status >= HttpHeader::S300) {
|
||||
if(!httpHeader->defined(HttpHeader::LOCATION)) {
|
||||
throw DlAbortEx
|
||||
(StringFormat(EX_LOCATION_HEADER_REQUIRED,
|
||||
|
@ -115,7 +115,8 @@ void HttpResponse::retrieveCookie()
|
|||
bool HttpResponse::isRedirect() const
|
||||
{
|
||||
const std::string& status = getResponseStatus();
|
||||
return "300" <= status && status < "400" && httpHeader->defined(HttpHeader::LOCATION);
|
||||
return HttpHeader::S300 <= status && status < HttpHeader::S400 &&
|
||||
httpHeader->defined(HttpHeader::LOCATION);
|
||||
}
|
||||
|
||||
void HttpResponse::processRedirect()
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "prefs.h"
|
||||
#include "StringFormat.h"
|
||||
#include "HttpSkipResponseCommand.h"
|
||||
#include "HttpHeader.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -88,7 +89,7 @@ bool HttpResponseCommand::executeInternal()
|
|||
httpResponse->validateResponse();
|
||||
httpResponse->retrieveCookie();
|
||||
|
||||
if(httpResponse->getResponseStatus() >= "300") {
|
||||
if(httpResponse->getResponseStatus() >= HttpHeader::S300) {
|
||||
return skipResponseBody(httpResponse);
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "Util.h"
|
||||
#include "StringFormat.h"
|
||||
#include "DlAbortEx.h"
|
||||
#include "HttpHeader.h"
|
||||
|
||||
namespace aria2 {
|
||||
|
||||
|
@ -130,10 +131,10 @@ bool HttpSkipResponseCommand::processResponse()
|
|||
return prepareForRetry(0);
|
||||
} else if(_httpResponse->hasRetryAfter()) {
|
||||
return prepareForRetry(_httpResponse->getRetryAfter());
|
||||
} else if(_httpResponse->getResponseStatus() >= "400") {
|
||||
if(_httpResponse->getResponseStatus() == "401") {
|
||||
} else if(_httpResponse->getResponseStatus() >= HttpHeader::S400) {
|
||||
if(_httpResponse->getResponseStatus() == HttpHeader::S401) {
|
||||
throw DlAbortEx(EX_AUTH_FAILED);
|
||||
}else if(_httpResponse->getResponseStatus() == "404") {
|
||||
}else if(_httpResponse->getResponseStatus() == HttpHeader::S404) {
|
||||
throw DlAbortEx(MSG_RESOURCE_NOT_FOUND);
|
||||
} else {
|
||||
throw DlAbortEx(StringFormat(EX_BAD_STATUS, Util::parseUInt(_httpResponse->getResponseStatus())).str());
|
||||
|
|
Loading…
Reference in New Issue