]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
getinfo: provide CURLINFO_HEADER_SIZE and CURLINFO_REQUEST_SIZE override
authorDaniel Stenberg <daniel@haxx.se>
Sun, 22 Mar 2020 11:25:46 +0000 (12:25 +0100)
committerDaniel Stenberg <daniel@haxx.se>
Sun, 22 Mar 2020 22:32:57 +0000 (23:32 +0100)
To let debug-builds return fake values, like in test 970.

Ref: #5131
Closes #5136

lib/getinfo.c
tests/data/test970

index 9aac5e2b8c35c01bc1e0678f117f6892a59a6621..18274e964ea8f7cc4a5a6648ef096d635ec70a0c 100644 (file)
@@ -159,6 +159,19 @@ static CURLcode getinfo_long(struct Curl_easy *data, CURLINFO info,
       break;
     }
   }
+  /* use another variable for this to allow different values */
+  timestr = getenv("CURL_DEBUG_SIZE");
+  if(timestr) {
+    unsigned long val = strtol(timestr, NULL, 10);
+    switch(info) {
+    case CURLINFO_HEADER_SIZE:
+    case CURLINFO_REQUEST_SIZE:
+      *param_longp = (long)val;
+      return CURLE_OK;
+    default:
+      break;
+    }
+  }
 #endif
 
   switch(info) {
index 3496a2a73dd9b431cf7b2691242370cde06fd626..04a663bc9fa3d166e3ae2cae78a0e37be71606e9 100644 (file)
@@ -36,6 +36,7 @@ debug
 </features>
 <setenv>
 CURL_TIME=13
+CURL_DEBUG_SIZE=4019
 CURL_VERSION=curl-unit-test-fake-version
 </setenv>
 <name>
@@ -59,7 +60,7 @@ Accept: */*
 \r
 </protocol>
 <stdout nonewline="yes">
-{"url_effective":"http://%HOSTIP:%HTTPPORT/970","http_code":200,"response_code":200,"http_connect":0,"time_total":0.000013,"time_namelookup":0.000013,"time_connect":0.000013,"time_appconnect":0.000013,"time_pretransfer":0.000013,"time_starttransfer":0.000013,"size_header":252,"size_request":85,"size_download":445,"size_upload":0,"speed_download":0.000013,"speed_upload":0.000013,"content_type":"text/html","num_connects":1,"time_redirect":0.000013,"num_redirects":0,"ssl_verify_result":0,"proxy_ssl_verify_result":0,"filename_effective":"log/out970","remote_ip":"%HOSTIP","remote_port":%HTTPPORT,"local_ip":"127.0.0.1","local_port":13,"http_version":"1.1","scheme":"HTTP","curl_version":"curl-unit-test-fake-version"}
+{"url_effective":"http://%HOSTIP:%HTTPPORT/970","http_code":200,"response_code":200,"http_connect":0,"time_total":0.000013,"time_namelookup":0.000013,"time_connect":0.000013,"time_appconnect":0.000013,"time_pretransfer":0.000013,"time_starttransfer":0.000013,"size_header":4019,"size_request":4019,"size_download":445,"size_upload":0,"speed_download":0.000013,"speed_upload":0.000013,"content_type":"text/html","num_connects":1,"time_redirect":0.000013,"num_redirects":0,"ssl_verify_result":0,"proxy_ssl_verify_result":0,"filename_effective":"log/out970","remote_ip":"%HOSTIP","remote_port":%HTTPPORT,"local_ip":"127.0.0.1","local_port":13,"http_version":"1.1","scheme":"HTTP","curl_version":"curl-unit-test-fake-version"}
 </stdout>
 </verify>
 </testcase>