소스 검색

2008-05-14 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

	Defined "\r\n", "A", "I" as static const std::string
	* src/A2STR.cc
	* src/A2STR.h
	* src/FtpConnection.cc
	* src/FtpConnection.h
Tatsuhiro Tsujikawa 17 년 전
부모
커밋
9a98c71972
5개의 변경된 파일26개의 추가작업 그리고 4개의 파일을 삭제
  1. 8 0
      ChangeLog
  2. 2 0
      src/A2STR.cc
  3. 2 0
      src/A2STR.h
  4. 9 4
      src/FtpConnection.cc
  5. 5 0
      src/FtpConnection.h

+ 8 - 0
ChangeLog

@@ -1,3 +1,11 @@
+2008-05-14  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
+
+	Defined "\r\n", "A", "I" as static const std::string
+	* src/A2STR.cc
+	* src/A2STR.h
+	* src/FtpConnection.cc
+	* src/FtpConnection.h
+
 2008-05-14  Tatsuhiro Tsujikawa  <tujikawa at rednoah dot com>
 
 	Added COLON_C(".") and used it in Request::parseUrl()

+ 2 - 0
src/A2STR.cc

@@ -44,6 +44,8 @@ const std::string A2STR::CR_C("\r");
 
 const std::string A2STR::LF_C("\n");
 
+const std::string A2STR::CRLF("\r\n");
+
 const std::string A2STR::SLASH_C("/");
 
 const std::string A2STR::DOT_C(".");

+ 2 - 0
src/A2STR.h

@@ -51,6 +51,8 @@ public:
 
   static const std::string LF_C;
 
+  static const std::string CRLF;
+
   static const std::string SLASH_C;
 
   static const std::string DOT_C;

+ 9 - 4
src/FtpConnection.cc

@@ -46,9 +46,14 @@
 #include "DlRetryEx.h"
 #include "DlAbortEx.h"
 #include "Socket.h"
+#include "A2STR.h"
 
 namespace aria2 {
 
+const std::string FtpConnection::A("A");
+
+const std::string FtpConnection::I("I");
+
 FtpConnection::FtpConnection(int32_t cuid, const SocketHandle& socket,
 			     const RequestHandle& req, const Option* op):
   cuid(cuid), socket(socket), req(req), option(op),
@@ -74,9 +79,9 @@ void FtpConnection::sendType() const
 {
   std::string type;
   if(option->get(PREF_FTP_TYPE) == V_ASCII) {
-    type = "A";
+    type = FtpConnection::A;
   } else {
-    type = "I";
+    type = FtpConnection::I;
   }
   std::string request = "TYPE "+type+"\r\n";
   logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
@@ -99,7 +104,7 @@ void FtpConnection::sendSize() const
 
 void FtpConnection::sendPasv() const
 {
-  std::string request = "PASV\r\n";
+  static const std::string request("PASV\r\n");
   logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
   socket->writeData(request);
 }
@@ -170,7 +175,7 @@ bool FtpConnection::isEndOfResponse(unsigned int status, const std::string& resp
       return false;
     }
   }
-  if(Util::endsWith(response, "\r\n")) {
+  if(Util::endsWith(response, A2STR::CRLF)) {
     return true;
   } else {
     return false;

+ 5 - 0
src/FtpConnection.h

@@ -61,6 +61,11 @@ private:
   unsigned int getStatus(const std::string& response) const;
   bool isEndOfResponse(unsigned int status, const std::string& response) const;
   bool bulkReceiveResponse(std::pair<unsigned int, std::string>& response);
+
+  static const std::string A;
+
+  static const std::string I;
+
 public:
   FtpConnection(int32_t cuid, const SharedHandle<SocketCore>& socket,
 		const SharedHandle<Request>& req, const Option* op);