浏览代码

cmFileCommand: Do not log raw protocol data from curl (#15589)

Teach cmFileCommandCurlDebugCallback to filter the debug data by type
and show only summary information instead of the raw data.  This avoids
allocating memory for all data transferred by UPLOAD or DOWNLOAD.
Brad King 10 年之前
父节点
当前提交
eba12a4361
共有 1 个文件被更改,包括 26 次插入3 次删除
  1. 26 3
      Source/cmFileCommand.cxx

+ 26 - 3
Source/cmFileCommand.cxx

@@ -2798,13 +2798,36 @@ namespace {
 
 
   static size_t
-  cmFileCommandCurlDebugCallback(CURL *, curl_infotype, char *chPtr,
+  cmFileCommandCurlDebugCallback(CURL *, curl_infotype type, char *chPtr,
                                  size_t size, void *data)
     {
     cmFileCommandVectorOfChar *vec
       = static_cast<cmFileCommandVectorOfChar*>(data);
-    vec->insert(vec->end(), chPtr, chPtr + size);
-    return size;
+    switch(type)
+      {
+      case CURLINFO_TEXT:
+      case CURLINFO_HEADER_IN:
+      case CURLINFO_HEADER_OUT:
+        vec->insert(vec->end(), chPtr, chPtr + size);
+        break;
+      case CURLINFO_DATA_IN:
+      case CURLINFO_DATA_OUT:
+      case CURLINFO_SSL_DATA_IN:
+      case CURLINFO_SSL_DATA_OUT:
+        {
+        char buf[128];
+        int n = sprintf(buf, "[%" cmIML_INT_PRIu64 " bytes data]\n",
+                        static_cast<cmIML_INT_uint64_t>(size));
+        if (n > 0)
+          {
+          vec->insert(vec->end(), buf, buf + n);
+          }
+        }
+        break;
+      default:
+        break;
+      }
+    return 0;
     }