[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnurl] 88/264: writeout_json: Fix data type issues
From: |
gnunet |
Subject: |
[gnurl] 88/264: writeout_json: Fix data type issues |
Date: |
Thu, 30 Apr 2020 16:06:31 +0200 |
This is an automated email from the git hooks/post-receive script.
nikita pushed a commit to branch master
in repository gnurl.
commit 884de1a763af186984cbcbe7b35b551c06025284
Author: Michael Kaufmann <address@hidden>
AuthorDate: Thu Mar 26 23:15:37 2020 +0100
writeout_json: Fix data type issues
Load long values correctly (e.g. for http_code).
Use curl_off_t (not long) for:
- size_download (CURLINFO_SIZE_DOWNLOAD_T)
- size_upload (CURLINFO_SIZE_UPLOAD_T)
The unit for these values is bytes/second, not microseconds:
- speed_download (CURLINFO_SPEED_DOWNLOAD_T)
- speed_upload (CURLINFO_SPEED_UPLOAD_T)
Fixes #5131
Closes #5152
---
src/tool_writeout.c | 8 ++++----
src/tool_writeout.h | 1 +
src/tool_writeout_json.c | 15 ++++++++++++++-
tests/data/test970 | 2 +-
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/src/tool_writeout.c b/src/tool_writeout.c
index 9fbc8665d..32c95b45f 100644
--- a/src/tool_writeout.c
+++ b/src/tool_writeout.c
@@ -55,13 +55,13 @@ static const struct writeoutvar variables[] = {
{"size_request", VAR_REQUEST_SIZE, 0,
CURLINFO_REQUEST_SIZE, JSON_LONG},
{"size_download", VAR_SIZE_DOWNLOAD, 0,
- CURLINFO_SIZE_DOWNLOAD_T, JSON_LONG},
+ CURLINFO_SIZE_DOWNLOAD_T, JSON_OFFSET},
{"size_upload", VAR_SIZE_UPLOAD, 0,
- CURLINFO_SIZE_UPLOAD_T, JSON_LONG},
+ CURLINFO_SIZE_UPLOAD_T, JSON_OFFSET},
{"speed_download", VAR_SPEED_DOWNLOAD, 0,
- CURLINFO_SPEED_DOWNLOAD_T, JSON_TIME},
+ CURLINFO_SPEED_DOWNLOAD_T, JSON_OFFSET},
{"speed_upload", VAR_SPEED_UPLOAD, 0,
- CURLINFO_SPEED_UPLOAD_T, JSON_TIME},
+ CURLINFO_SPEED_UPLOAD_T, JSON_OFFSET},
{"content_type", VAR_CONTENT_TYPE, 0,
CURLINFO_CONTENT_TYPE, JSON_STRING},
{"num_connects", VAR_NUM_CONNECTS, 0,
diff --git a/src/tool_writeout.h b/src/tool_writeout.h
index 64d759575..a21787ab9 100644
--- a/src/tool_writeout.h
+++ b/src/tool_writeout.h
@@ -65,6 +65,7 @@ typedef enum {
JSON_NONE,
JSON_STRING,
JSON_LONG,
+ JSON_OFFSET,
JSON_TIME,
JSON_VERSION,
JSON_FILENAME
diff --git a/src/tool_writeout_json.c b/src/tool_writeout_json.c
index 70235c209..dfe51b9ff 100644
--- a/src/tool_writeout_json.c
+++ b/src/tool_writeout_json.c
@@ -105,7 +105,7 @@ static int writeString(FILE *str, CURL *curl, const char
*key, CURLINFO ci)
static int writeLong(FILE *str, CURL *curl, const char *key, CURLINFO ci)
{
- curl_off_t val = 0;
+ long val = 0;
if(CURLE_OK == curl_easy_getinfo(curl, ci, &val)) {
fprintf(str, "\"%s\":%ld", key, val);
return 1;
@@ -113,6 +113,16 @@ static int writeLong(FILE *str, CURL *curl, const char
*key, CURLINFO ci)
return 0;
}
+static int writeOffset(FILE *str, CURL *curl, const char *key, CURLINFO ci)
+{
+ curl_off_t val = 0;
+ if(CURLE_OK == curl_easy_getinfo(curl, ci, &val)) {
+ fprintf(str, "\"%s\":%" CURL_FORMAT_CURL_OFF_T, key, val);
+ return 1;
+ }
+ return 0;
+}
+
static int writeFilename(FILE *str, const char *key, const char *filename)
{
if(filename) {
@@ -160,6 +170,9 @@ void ourWriteOutJSON(const struct writeoutvar mappings[],
CURL *curl,
case JSON_LONG:
ok = writeLong(stream, curl, name, cinfo);
break;
+ case JSON_OFFSET:
+ ok = writeOffset(stream, curl, name, cinfo);
+ break;
case JSON_TIME:
ok = writeTime(stream, curl, name, cinfo);
break;
diff --git a/tests/data/test970 b/tests/data/test970
index 04a663bc9..54e34cc5b 100644
--- a/tests/data/test970
+++ b/tests/data/test970
@@ -60,7 +60,7 @@ Accept: */*
</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":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
[...]
+{"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":13,"speed_upload":13,"content_type":"text/html","num_connects":1,"time_redirect":0.000013,"num_redirects":0,"ssl_verify_result":0,"proxy_ssl_
[...]
</stdout>
</verify>
</testcase>
--
To stop receiving notification emails like this one, please contact
address@hidden.
- [gnurl] 126/264: appveyor: show failed tests in log even if test is ignored, (continued)
- [gnurl] 126/264: appveyor: show failed tests in log even if test is ignored, gnunet, 2020/04/30
- [gnurl] 101/264: checksrc: warn on obvious conditional blocks on the same line as if(), gnunet, 2020/04/30
- [gnurl] 133/264: scripts/release-notes.pl: add helper script for RELEASE-NOTES maintenance, gnunet, 2020/04/30
- [gnurl] 132/264: configure: don't check for Security.framework when cross-compiling, gnunet, 2020/04/30
- [gnurl] 74/264: copyright: fix out-of-date copyright ranges and missing headers, gnunet, 2020/04/30
- [gnurl] 39/264: windows: suppress UI in all CryptAcquireContext() calls, gnunet, 2020/04/30
- [gnurl] 53/264: mbedtls: remove the BACKEND define kludge, gnunet, 2020/04/30
- [gnurl] 61/264: curl_setup: define _WIN32_WINNT_[OS] symbols, gnunet, 2020/04/30
- [gnurl] 55/264: test970: fix static ip:port instead of dynamic values being used, gnunet, 2020/04/30
- [gnurl] 84/264: SSLCERTS.md: Fix example code for setting CA cert file, gnunet, 2020/04/30
- [gnurl] 88/264: writeout_json: Fix data type issues,
gnunet <=
- [gnurl] 93/264: KNOWN_BUGS: DoH doesn't inherit all transfer options, gnunet, 2020/04/30
- [gnurl] 179/264: cmake: add aliases so exported target names are available in tree, gnunet, 2020/04/30
- [gnurl] 46/264: writeout_json: use curl_off_t printf() option for the time output, gnunet, 2020/04/30
- [gnurl] 58/264: tests: add test 430, 431 and 432 to verify the --config fix, gnunet, 2020/04/30
- [gnurl] 60/264: curl-functions.m4: remove inappropriate AC_REQUIRE, gnunet, 2020/04/30
- [gnurl] 119/264: KNOWN_BUGS: Store TLS context per transfer instead of per connection, gnunet, 2020/04/30
- [gnurl] 92/264: KNOWN_BUGS: DoH leaks memory after followlocation, gnunet, 2020/04/30
- [gnurl] 98/264: SECURITY.md: minor rephrase, gnunet, 2020/04/30
- [gnurl] 125/264: appveyor: turn disabled tests into ignored result tests, gnunet, 2020/04/30
- [gnurl] 130/264: lib: never define CURL_CA_BUNDLE with a getenv, gnunet, 2020/04/30