Przeglądaj źródła

Removed Request::PROTO_*

Tatsuhiro Tsujikawa 13 lat temu
rodzic
commit
be77d1394e

+ 4 - 4
src/AbstractCommand.cc

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

+ 2 - 3
src/AuthConfigFactory.cc

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

+ 3 - 3
src/HttpRequest.cc

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

+ 3 - 3
src/HttpRequestCommand.cc

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

+ 4 - 4
src/InitiateConnectionCommandFactory.cc

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

+ 0 - 6
src/Request.cc

@@ -50,12 +50,6 @@ const std::string Request::METHOD_GET = "GET";
 
 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():
   method_(METHOD_GET),
   tryCount_(0),

+ 0 - 7
src/Request.h

@@ -224,14 +224,7 @@ public:
   static const std::string METHOD_GET;
   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;
-
 };
 
 } // namespace aria2