/* */ #ifndef _D_FTP_CONNECTION_H_ #define _D_FTP_CONNECTION_H_ #include "common.h" #include "SharedHandle.h" #include "TimeA2.h" #include #include namespace aria2 { class Option; class Logger; class Segment; class Request; class SocketCore; class FtpConnection { private: int32_t cuid; SharedHandle socket; SharedHandle req; const Option* option; Logger* logger; std::string strbuf; unsigned int getStatus(const std::string& response) const; std::string::size_type findEndOfResponse(unsigned int status, const std::string& buf) const; bool bulkReceiveResponse(std::pair& response); static const std::string A; static const std::string I; public: FtpConnection(int32_t cuid, const SharedHandle& socket, const SharedHandle& req, const Option* op); ~FtpConnection(); void sendUser() const; void sendPass() const; void sendType() const; void sendCwd() const; void sendMdtm() const; void sendSize() const; void sendPasv() const; SharedHandle sendPort() const; void sendRest(const SharedHandle& segment) const; void sendRetr() const; unsigned int receiveResponse(); unsigned int receiveSizeResponse(uint64_t& size); // Returns status code of MDTM reply. If the status code is 213, parses // time-val and store it in time. // If a code other than 213 is returned, time is not touched. // Expect MDTM reply is YYYYMMDDhhmmss in GMT. If status is 213 but returned // date cannot be parsed, then executes time.setTimeInSec(-1). // If reply is not received yet, returns 0. unsigned int receiveMdtmResponse(Time& time); unsigned int receivePasvResponse(std::pair& dest); }; } // namespace aria2 #endif // _D_FTP_CONNECTION_H_