benchmark: fix request size collection and add invariant check
authorFlorian Dold <florian.dold@gmail.com>
Thu, 2 May 2019 23:01:39 +0000 (01:01 +0200)
committerFlorian Dold <florian.dold@gmail.com>
Thu, 2 May 2019 23:01:49 +0000 (01:01 +0200)
src/curl/curl.c

index 4bd2a55d094ffce4230e0f4f4f6c7d4002291438..1c352f195915ab9e9bc7ab8ab897e79fc371833f 100644 (file)
@@ -526,11 +526,20 @@ GNUNET_CURL_perform2 (struct GNUNET_CURL_Context *ctx,
                                      &size_long));
     bytes_sent += size_long;
 
+    /* We obtain this value to check an invariant, but never use it otherwise. */
     GNUNET_break (CURLE_OK ==
                   curl_easy_getinfo (cmsg->easy_handle,
                                      CURLINFO_SIZE_UPLOAD_T,
                                      &size_curl));
-    bytes_sent += size_curl;
+
+    /* CURLINFO_SIZE_UPLOAD_T <= CURLINFO_REQUEST_SIZE should
+       be an invariant.
+       As verified with
+         curl -w "foo%{size_request} -XPOST --data "ABC" $URL
+      the CURLINFO_REQUEST_SIZE should be the whole size of the request
+      including headers and body.
+     */
+    GNUNET_break (size_curl <= size_long);
 
     urd = get_url_benchmark_data (url, (unsigned int) response_code);
     urd->count++;