浏览代码

Json dump to body directly

ithewei 3 年之前
父节点
当前提交
7761f909c3
共有 1 个文件被更改,包括 3 次插入1 次删除
  1. 3 1
      http/HttpMessage.h

+ 3 - 1
http/HttpMessage.h

@@ -166,7 +166,8 @@ public:
     template<typename T>
     int Json(const T& t) {
         content_type = APPLICATION_JSON;
-        json = t;
+        hv::Json j(t);
+        body = j.dump(2);
         return 200;
     }
     const hv::Json& GetJson() {
@@ -264,6 +265,7 @@ public:
     virtual void Reset() {
         Init();
         headers.clear();
+        cookies.clear();
         body.clear();
 #ifndef WITHOUT_HTTP_CONTENT
         json.clear();