소스 검색

fix #324: HttpCookie supports saving multiple names

ithewei 3 년 전
부모
커밋
c09a3e2b6c
1개의 변경된 파일8개의 추가작업 그리고 8개의 파일을 삭제
  1. 8 8
      http/HttpMessage.cpp

+ 8 - 8
http/HttpMessage.cpp

@@ -75,19 +75,19 @@ std::string HttpCookie::dump() const {
     assert(!name.empty() || !kv.empty());
     std::string res;
 
-    if (!name.empty()) {
+    if (!kv.empty()) {
+        for (auto& pair : kv) {
+            if (!res.empty()) res += "; ";
+            res += pair.first;
+            res += "=";
+            res += pair.second;
+        }
+    } else {
         res = name;
         res += "=";
         res += value;
     }
 
-    for (auto& pair : kv) {
-        if (!res.empty()) res += "; ";
-        res += pair.first;
-        res += "=";
-        res += pair.second;
-    }
-
     if (!domain.empty()) {
         res += "; Domain=";
         res += domain;