diff options
Diffstat (limited to 'src/tool_writeout_json.c')
-rw-r--r-- | src/tool_writeout_json.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/tool_writeout_json.c b/src/tool_writeout_json.c index dfe51b9ff..bae7f5c15 100644 --- a/src/tool_writeout_json.c +++ b/src/tool_writeout_json.c @@ -103,13 +103,20 @@ static int writeString(FILE *str, CURL *curl, const char *key, CURLINFO ci) return 0; } -static int writeLong(FILE *str, CURL *curl, const char *key, CURLINFO ci) +static int writeLong(FILE *str, CURL *curl, const char *key, CURLINFO ci, + struct per_transfer *per, const struct writeoutvar *wovar) { - long val = 0; - if(CURLE_OK == curl_easy_getinfo(curl, ci, &val)) { - fprintf(str, "\"%s\":%ld", key, val); + if(wovar->id == VAR_NUM_HEADERS) { + fprintf(str, "\"%s\":%ld", key, per->num_headers); return 1; } + else { + long val = 0; + if(CURLE_OK == curl_easy_getinfo(curl, ci, &val)) { + fprintf(str, "\"%s\":%ld", key, val); + return 1; + } + } return 0; } @@ -149,12 +156,13 @@ static int writeVersion(FILE *str, CURL *curl, const char *key, CURLINFO ci) } void ourWriteOutJSON(const struct writeoutvar mappings[], CURL *curl, - struct OutStruct *outs, FILE *stream) + struct per_transfer *per, FILE *stream) { int i; fputs("{", stream); for(i = 0; mappings[i].name != NULL; i++) { + const struct writeoutvar *wovar = &mappings[i]; const char *name = mappings[i].name; CURLINFO cinfo = mappings[i].cinfo; int ok = 0; @@ -168,7 +176,7 @@ void ourWriteOutJSON(const struct writeoutvar mappings[], CURL *curl, ok = writeString(stream, curl, name, cinfo); break; case JSON_LONG: - ok = writeLong(stream, curl, name, cinfo); + ok = writeLong(stream, curl, name, cinfo, per, wovar); break; case JSON_OFFSET: ok = writeOffset(stream, curl, name, cinfo); @@ -177,7 +185,7 @@ void ourWriteOutJSON(const struct writeoutvar mappings[], CURL *curl, ok = writeTime(stream, curl, name, cinfo); break; case JSON_FILENAME: - ok = writeFilename(stream, name, outs->filename); + ok = writeFilename(stream, name, per->outs.filename); break; case JSON_VERSION: ok = writeVersion(stream, curl, name, cinfo); |