curl: add %{stderr} and %{stdout} for --write-out

Closes #3115
This commit is contained in:
Frank Gevaerts 2018-10-08 23:54:01 +02:00 committed by Daniel Stenberg
parent 8a49b291cb
commit e431daf013
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
5 changed files with 86 additions and 11 deletions

View file

@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
* Copyright (C) 1998 - 2017, Daniel Stenberg, <daniel@haxx.se>, et al.
* Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@ -60,6 +60,8 @@ typedef enum {
VAR_LOCAL_PORT,
VAR_HTTP_VERSION,
VAR_SCHEME,
VAR_STDOUT,
VAR_STDERR,
VAR_NUM_OF_VARS /* must be the last */
} replaceid;
@ -101,6 +103,8 @@ static const struct variable replacements[]={
{"local_port", VAR_LOCAL_PORT},
{"http_version", VAR_HTTP_VERSION},
{"scheme", VAR_SCHEME},
{"stdout", VAR_STDOUT},
{"stderr", VAR_STDERR},
{NULL, VAR_NONE}
};
@ -320,6 +324,12 @@ void ourWriteOut(CURL *curl, struct OutStruct *outs, const char *writeinfo)
curl_easy_getinfo(curl, CURLINFO_SCHEME,
&stringp))
fprintf(stream, "%s", stringp);
/* FALLTHROUGH */
case VAR_STDOUT:
stream = stdout;
break;
case VAR_STDERR:
stream = stderr;
break;
default:
break;