Removed Request::PROTO_*

pull/28/head
Tatsuhiro Tsujikawa 2012-09-25 22:41:03 +09:00
parent c186e93488
commit be77d1394e
7 changed files with 16 additions and 30 deletions

View File

@ -590,17 +590,17 @@ std::string getProxyOptionFor
std::string getProxyUri std::string getProxyUri
(const std::string& protocol, const Option* option) (const std::string& protocol, const Option* option)
{ {
if(protocol == Request::PROTO_HTTP) { if(protocol == "http") {
return getProxyOptionFor(PREF_HTTP_PROXY, return getProxyOptionFor(PREF_HTTP_PROXY,
PREF_HTTP_PROXY_USER, PREF_HTTP_PROXY_USER,
PREF_HTTP_PROXY_PASSWD, PREF_HTTP_PROXY_PASSWD,
option); option);
} else if(protocol == Request::PROTO_HTTPS) { } else if(protocol == "https") {
return getProxyOptionFor(PREF_HTTPS_PROXY, return getProxyOptionFor(PREF_HTTPS_PROXY,
PREF_HTTPS_PROXY_USER, PREF_HTTPS_PROXY_USER,
PREF_HTTPS_PROXY_PASSWD, PREF_HTTPS_PROXY_PASSWD,
option); option);
} else if(protocol == Request::PROTO_FTP) { } else if(protocol == "ftp") {
return getProxyOptionFor(PREF_FTP_PROXY, return getProxyOptionFor(PREF_FTP_PROXY,
PREF_FTP_PROXY_USER, PREF_FTP_PROXY_USER,
PREF_FTP_PROXY_PASSWD, PREF_FTP_PROXY_PASSWD,
@ -865,7 +865,7 @@ const std::string& AbstractCommand::resolveProxyMethod
(const std::string& protocol) const (const std::string& protocol) const
{ {
if(getOption()->get(PREF_PROXY_METHOD) == V_TUNNEL || if(getOption()->get(PREF_PROXY_METHOD) == V_TUNNEL ||
Request::PROTO_HTTPS == protocol) { protocol == "https") {
return V_TUNNEL; return V_TUNNEL;
} else { } else {
return V_GET; return V_GET;

View File

@ -60,8 +60,7 @@ AuthConfigHandle
AuthConfigFactory::createAuthConfig AuthConfigFactory::createAuthConfig
(const SharedHandle<Request>& request, const Option* op) (const SharedHandle<Request>& request, const Option* op)
{ {
if(request->getProtocol() == Request::PROTO_HTTP || if(request->getProtocol() == "http" || request->getProtocol() == "https") {
request->getProtocol() == Request::PROTO_HTTPS) {
if(op->getAsBool(PREF_HTTP_AUTH_CHALLENGE)) { if(op->getAsBool(PREF_HTTP_AUTH_CHALLENGE)) {
if(!request->getUsername().empty()) { if(!request->getUsername().empty()) {
@ -89,7 +88,7 @@ AuthConfigFactory::createAuthConfig
createHttpAuthResolver(op)->resolveAuthConfig(request->getHost()); createHttpAuthResolver(op)->resolveAuthConfig(request->getHost());
} }
} }
} else if(request->getProtocol() == Request::PROTO_FTP) { } else if(request->getProtocol() == "ftp") {
if(!request->getUsername().empty()) { if(!request->getUsername().empty()) {
if(request->hasPassword()) { if(request->hasPassword()) {
return createAuthConfig(request->getUsername(), request->getPassword()); return createAuthConfig(request->getUsername(), request->getPassword());

View File

@ -145,7 +145,7 @@ std::string HttpRequest::createRequest()
std::string requestLine = request_->getMethod(); std::string requestLine = request_->getMethod();
requestLine += " "; requestLine += " ";
if(proxyRequest_) { if(proxyRequest_) {
if(getProtocol() == Request::PROTO_FTP && if(getProtocol() == "ftp" &&
request_->getUsername().empty() && authConfig_) { request_->getUsername().empty() && authConfig_) {
// Insert user into URI, like ftp://USER@host/ // Insert user into URI, like ftp://USER@host/
std::string uri = getCurrentURI(); std::string uri = getCurrentURI();
@ -201,7 +201,7 @@ std::string HttpRequest::createRequest()
std::string rangeHeader(fmt("bytes=%" PRId64 "-", getStartByte())); std::string rangeHeader(fmt("bytes=%" PRId64 "-", getStartByte()));
if(request_->isPipeliningEnabled()) { if(request_->isPipeliningEnabled()) {
rangeHeader += util::itos(getEndByte()); rangeHeader += util::itos(getEndByte());
} else if(getProtocol() != Request::PROTO_FTP && endOffsetOverride_ > 0) { } else if(getProtocol() != "ftp" && endOffsetOverride_ > 0) {
// FTP via http proxy does not support endbytes // FTP via http proxy does not support endbytes
rangeHeader += util::itos(endOffsetOverride_-1); rangeHeader += util::itos(endOffsetOverride_-1);
} }
@ -231,7 +231,7 @@ std::string HttpRequest::createRequest()
std::vector<Cookie> cookies = std::vector<Cookie> cookies =
cookieStorage_->criteriaFind(getHost(), path, cookieStorage_->criteriaFind(getHost(), path,
Time().getTime(), Time().getTime(),
getProtocol() == Request::PROTO_HTTPS); getProtocol() == "https");
for(std::vector<Cookie>::const_iterator itr = cookies.begin(), for(std::vector<Cookie>::const_iterator itr = cookies.begin(),
eoi = cookies.end(); itr != eoi; ++itr) { eoi = cookies.end(); itr != eoi; ++itr) {
cookiesValue += (*itr).toString(); cookiesValue += (*itr).toString();

View File

@ -122,7 +122,7 @@ createHttpRequest(const SharedHandle<Request>& req,
bool HttpRequestCommand::executeInternal() { bool HttpRequestCommand::executeInternal() {
//socket->setBlockingMode(); //socket->setBlockingMode();
if(getRequest()->getProtocol() == Request::PROTO_HTTPS) { if(getRequest()->getProtocol() == "https") {
getSocket()->prepareSecureConnection(); getSocket()->prepareSecureConnection();
if(!getSocket()->initiateSecureConnection(getRequest()->getHost())) { if(!getSocket()->initiateSecureConnection(getRequest()->getHost())) {
setReadCheckSocketIf(getSocket(), getSocket()->wantRead()); setReadCheckSocketIf(getSocket(), getSocket()->wantRead());
@ -150,8 +150,8 @@ bool HttpRequestCommand::executeInternal() {
getDownloadEngine()->getAuthConfigFactory(), getDownloadEngine()->getAuthConfigFactory(),
proxyRequest_)); proxyRequest_));
if(getOption()->getAsBool(PREF_CONDITIONAL_GET) && if(getOption()->getAsBool(PREF_CONDITIONAL_GET) &&
(getRequest()->getProtocol() == Request::PROTO_HTTP || (getRequest()->getProtocol() == "http" ||
getRequest()->getProtocol() == Request::PROTO_HTTPS)) { getRequest()->getProtocol() == "https")) {
if(getFileEntry()->getPath().empty() && if(getFileEntry()->getPath().empty() &&
getRequest()->getFile().empty()) { getRequest()->getFile().empty()) {
A2_LOG_DEBUG("Conditional-Get is disabled because file name" A2_LOG_DEBUG("Conditional-Get is disabled because file name"

View File

@ -55,10 +55,10 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand
RequestGroup* requestGroup, RequestGroup* requestGroup,
DownloadEngine* e) DownloadEngine* e)
{ {
if(req->getProtocol() == Request::PROTO_HTTP if(req->getProtocol() == "http"
#ifdef ENABLE_SSL #ifdef ENABLE_SSL
// for SSL // for SSL
|| req->getProtocol() == Request::PROTO_HTTPS || req->getProtocol() == "https"
#endif // ENABLE_SSL #endif // ENABLE_SSL
) { ) {
@ -71,7 +71,7 @@ InitiateConnectionCommandFactory::createInitiateConnectionCommand
return return
new HttpInitiateConnectionCommand(cuid, req, fileEntry, requestGroup, e); new HttpInitiateConnectionCommand(cuid, req, fileEntry, requestGroup, e);
} else if(req->getProtocol() == Request::PROTO_FTP) { } else if(req->getProtocol() == "ftp") {
if(req->getFile().empty()) { if(req->getFile().empty()) {
throw DL_ABORT_EX throw DL_ABORT_EX
(fmt("FTP URI %s doesn't contain file path.", (fmt("FTP URI %s doesn't contain file path.",

View File

@ -50,12 +50,6 @@ const std::string Request::METHOD_GET = "GET";
const std::string Request::METHOD_HEAD = "HEAD"; const std::string Request::METHOD_HEAD = "HEAD";
const std::string Request::PROTO_HTTP("http");
const std::string Request::PROTO_HTTPS("https");
const std::string Request::PROTO_FTP("ftp");
Request::Request(): Request::Request():
method_(METHOD_GET), method_(METHOD_GET),
tryCount_(0), tryCount_(0),

View File

@ -224,14 +224,7 @@ public:
static const std::string METHOD_GET; static const std::string METHOD_GET;
static const std::string METHOD_HEAD; static const std::string METHOD_HEAD;
static const std::string PROTO_HTTP;
static const std::string PROTO_HTTPS;
static const std::string PROTO_FTP;
static const int MAX_REDIRECT = 20; static const int MAX_REDIRECT = 20;
}; };
} // namespace aria2 } // namespace aria2