curl: make -w's %{stderr} use the file set with --stderr

Reported-by: u20221022 on github
Fixes #10491
Closes #10569
This commit is contained in:
Jay Satiro 2023-02-20 14:16:41 +01:00 committed by Daniel Stenberg
parent 80b7f05baf
commit d9b7f6e750
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 8 additions and 4 deletions

View File

@ -661,7 +661,7 @@ static CURLcode post_per_transfer(struct GlobalConfig *global,
/* Write the --write-out data before cleanup but after result is final */
if(config->writeout)
ourWriteOut(config->writeout, per, result);
ourWriteOut(config, per, result);
/* Close function-local opened file descriptors */
if(per->heads.fopened && per->heads.stream)

View File

@ -376,15 +376,19 @@ static int writeOffset(FILE *stream, const struct writeoutvar *wovar,
return 1; /* return 1 if anything was written */
}
void ourWriteOut(const char *writeinfo, struct per_transfer *per,
void ourWriteOut(struct OperationConfig *config, struct per_transfer *per,
CURLcode per_result)
{
FILE *stream = stdout;
const char *writeinfo = config->writeout;
const char *ptr = writeinfo;
bool done = FALSE;
struct curl_certinfo *certinfo;
CURLcode res = curl_easy_getinfo(per->curl, CURLINFO_CERTINFO, &certinfo);
if(!writeinfo)
return;
if(!res && certinfo)
per->certinfo = certinfo;
@ -423,7 +427,7 @@ void ourWriteOut(const char *writeinfo, struct per_transfer *per,
stream = stdout;
break;
case VAR_STDERR:
stream = stderr;
stream = config->global->errors;
break;
case VAR_JSON:
ourWriteOutJSON(stream, variables, per, per_result);

View File

@ -84,7 +84,7 @@ struct writeoutvar {
bool use_json);
};
void ourWriteOut(const char *writeinfo, struct per_transfer *per,
void ourWriteOut(struct OperationConfig *config, struct per_transfer *per,
CURLcode per_result);
#endif /* HEADER_CURL_TOOL_WRITEOUT_H */