summaryrefslogtreecommitdiff
path: root/src/FtpConnection.cc
diff options
context:
space:
mode:
authorTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-09-08 13:06:44 +0000
committerTatsuhiro Tsujikawa <tatsuhiro.t@gmail.com>2008-09-08 13:06:44 +0000
commiteb652b570e765bcf12120fd831bf42b3e7f19652 (patch)
tree22922bda5cae6325d69f003f33f620efc8f0b6e4 /src/FtpConnection.cc
parentdbc8f5b737607db38399385e3b94f8dec9b3576c (diff)
2008-09-08 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented the ability to get timestamp from remote FTP server using MDTM command described in RFC3659. * src/FtpConnection.cc * src/FtpConnection.h * src/FtpNegotiationCommand.cc * src/FtpNegotiationCommand.h * test/FtpConnectionTest.cc * test/Makefile.am
Diffstat (limited to 'src/FtpConnection.cc')
-rw-r--r--src/FtpConnection.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/FtpConnection.cc b/src/FtpConnection.cc
index 8a9062b3..648e5e55 100644
--- a/src/FtpConnection.cc
+++ b/src/FtpConnection.cc
@@ -47,6 +47,7 @@
#include "DlAbortEx.h"
#include "Socket.h"
#include "A2STR.h"
+#include <cstring>
namespace aria2 {
@@ -95,6 +96,13 @@ void FtpConnection::sendCwd() const
socket->writeData(request);
}
+void FtpConnection::sendMdtm() const
+{
+ std::string request = "MDTM "+Util::urlencode(req->getFile())+"\r\n";
+ logger->info(MSG_SENDING_REQUEST, cuid, request.c_str());
+ socket->writeData(request);
+}
+
void FtpConnection::sendSize() const
{
std::string request = "SIZE "+Util::urldecode(req->getFile())+"\r\n";
@@ -257,6 +265,26 @@ unsigned int FtpConnection::receiveSizeResponse(uint64_t& size)
}
}
+unsigned int FtpConnection::receiveMdtmResponse(Time& time)
+{
+ // MDTM command, specified in RFC3659.
+ std::pair<unsigned int, std::string> response;
+ if(bulkReceiveResponse(response)) {
+ if(response.first == 213) {
+ char buf[15]; // YYYYMMDDhhmmss+\0, milli second part is dropped.
+ sscanf(response.second.c_str(), "%*u %14s", buf);
+ if(strlen(buf) == 14) {
+ time = Time::parse(buf, "%Y%m%d%H%M%S");
+ } else {
+ time.setTimeInSec(-1);
+ }
+ }
+ return response.first;
+ } else {
+ return 0;
+ }
+}
+
unsigned int FtpConnection::receivePasvResponse(std::pair<std::string, uint16_t>& dest)
{
std::pair<unsigned int, std::string> response;