ithewei 2 lat temu
rodzic
commit
8f86b25b10
3 zmienionych plików z 2 dodań i 13 usunięć
  1. 1 0
      examples/wget.cpp
  2. 0 12
      http/HttpMessage.cpp
  3. 1 1
      http/http_content.cpp

+ 1 - 0
examples/wget.cpp

@@ -68,6 +68,7 @@ static int wget(const char* url, const char* filepath, wget_progress_cb progress
         size_t received_bytes = 0;
         req.http_cb = [&file, &content_length, &received_bytes, &progress_cb]
             (HttpMessage* resp, http_parser_state state, const char* data, size_t size) {
+            if (!resp->headers["Location"].empty()) return;
             if (state == HP_HEADERS_COMPLETE) {
                 content_length = hv::from_string<size_t>(resp->GetHeader("Content-Length"));
                 printd("%s", resp->Dump(true, false).c_str());

+ 0 - 12
http/HttpMessage.cpp

@@ -209,9 +209,6 @@ std::string HttpMessage::GetString(const char* key, const std::string& defvalue)
         else if (value.is_number()) {
             return hv::to_string(value);
         }
-        else if (value.is_null()) {
-            return "null";
-        }
         else if (value.is_boolean()) {
             bool b = value;
             return b ? "true" : "false";
@@ -266,9 +263,6 @@ HV_EXPORT int64_t HttpMessage::Get(const char* key, int64_t defvalue) {
             std::string str = value;
             return atoll(str.c_str());
         }
-        else if (value.is_null()) {
-            return 0;
-        }
         else if (value.is_boolean()) {
             bool b = value;
             return b ? 1 : 0;
@@ -305,9 +299,6 @@ HV_EXPORT double HttpMessage::Get(const char* key, double defvalue) {
             std::string str = value;
             return atof(str.c_str());
         }
-        else if (value.is_null()) {
-            return 0.0f;
-        }
         else {
             return defvalue;
         }
@@ -340,9 +331,6 @@ HV_EXPORT bool HttpMessage::Get(const char* key, bool defvalue) {
             std::string str = value;
             return hv_getboolean(str.c_str());
         }
-        else if (value.is_null()) {
-            return false;
-        }
         else if (value.is_number()) {
             return value != 0;
         }

+ 1 - 1
http/http_content.cpp

@@ -103,7 +103,7 @@ std::string dump_multipart(MultiPart& mp, const char* boundary) {
     }
     str += "--";
     str += boundary;
-    str += "--";
+    str += "--\r\n";
     return str;
 }