ソースを参照

added head command

marius.rescheleit 5 年 前
コミット
d5dbb022ff
2 ファイル変更21 行追加0 行削除
  1. 5 0
      daemon/include/JsonCommander.h
  2. 16 0
      daemon/src/JsonCommander.cpp

+ 5 - 0
daemon/include/JsonCommander.h

@@ -120,6 +120,11 @@ private:
    * Executes the getdata command
    */
   Response executeGetdata(const Json::Value &message);
+
+  /**
+   * Executes the head command
+   */
+  Response executeHead(const Json::Value &message);
 };
 
 #endif

+ 16 - 0
daemon/src/JsonCommander.cpp

@@ -11,6 +11,7 @@ JsonCommander::JsonCommander(FileManager &fileManager)
   commandsMap["putdata"] = &JsonCommander::executePutdata;
   commandsMap["get"] = &JsonCommander::executeGet;
   commandsMap["getdata"] = &JsonCommander::executeGetdata;
+  commandsMap["head"] = &JsonCommander::executeHead;
 }
 
 JsonCommander::~JsonCommander() {}
@@ -310,6 +311,21 @@ JsonCommander::executeGetdata(const Json::Value &message) {
   return response;
 }
 
+JsonCommander::Response JsonCommander::executeHead(const Json::Value &message) {
+  JsonCommander::Response response;
+  response.action = send;
+  response.json["command"] = "head";
+
+  if(!message["file"].isString()) {
+    response.json["accept"] = false;
+    response.json["file"] = "";
+    response.json["data"] = "";
+    response.json["error"] = "incorrect heaed command request";
+  }
+
+  return response;
+}
+
 JsonCommander::Response JsonCommander::testVersion(const Json::Value &message) {
   JsonCommander::Response response;
   response.json["version"] = this->protocolVersion;