[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnurl] 09/208: curl: allow --header and --proxy-header rea
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnurl] 09/208: curl: allow --header and --proxy-header read from file |
Date: |
Wed, 09 Aug 2017 17:33:26 +0200 |
This is an automated email from the git hooks/post-receive script.
ng0 pushed a commit to annotated tag gnurl-7.55.0
in repository gnurl.
commit 84b9458837551a2749b45d924089f2015415a324
Author: Daniel Stenberg <address@hidden>
AuthorDate: Thu Jun 15 11:08:31 2017 +0200
curl: allow --header and --proxy-header read from file
So many headers can be provided as @filename.
Suggested-by: Timothe Litt
Closes #1486
---
docs/cmdline-opts/header.d | 9 ++++++---
docs/cmdline-opts/proxy-header.d | 8 ++++++--
src/tool_getparam.c | 42 ++++++++++++++++++++++++++++++++++------
3 files changed, 48 insertions(+), 11 deletions(-)
diff --git a/docs/cmdline-opts/header.d b/docs/cmdline-opts/header.d
index 90af7359e..d8292ed77 100644
--- a/docs/cmdline-opts/header.d
+++ b/docs/cmdline-opts/header.d
@@ -1,10 +1,9 @@
Long: header
Short: H
-Arg: <header>
-Help: Pass custom header LINE to server
+Arg: <header/@file>
+Help: Pass custom header(s) to server
Protocols: HTTP
---
-
Extra header to include in the request when sending HTTP to a server. You may
specify any number of extra headers. Note that if you should add a custom
header that has the same name as one of the internal ones curl would use, your
@@ -21,6 +20,10 @@ end-of-line marker, you should thus \fBnot\fP add that as a
part of the header
content: do not add newlines or carriage returns, they will only mess things up
for you.
+Starting in 7.55.0, this option can take an argument in @filename style, which
+then adds a header for each line in the input file. Using @- will make curl
+read the header file from stdin.
+
See also the --user-agent and --referer options.
Starting in 7.37.0, you need --proxy-header to send custom headers intended
diff --git a/docs/cmdline-opts/proxy-header.d b/docs/cmdline-opts/proxy-header.d
index 1ef696bc7..c1b0bb7c4 100644
--- a/docs/cmdline-opts/proxy-header.d
+++ b/docs/cmdline-opts/proxy-header.d
@@ -1,6 +1,6 @@
Long: proxy-header
-Arg: <header>
-Help: Pass custom header LINE to proxy
+Arg: <header/@file>
+Help: Pass custom header(s) to proxy
Protocols: HTTP
Added: 7.37.0
---
@@ -17,4 +17,8 @@ up for you.
Headers specified with this option will not be included in requests that curl
knows will not be sent to a proxy.
+Starting in 7.55.0, this option can take an argument in @filename style, which
+then adds a header for each line in the input file. Using @- will make curl
+read the header file from stdin.
+
This option can be used multiple times to add/replace/remove multiple headers.
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 56bbbf18f..fabe8f04b 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -1602,12 +1602,42 @@ ParameterError getparameter(const char *flag, /* f or
-long-flag */
break;
case 'H':
/* A custom header to append to a list */
- if(subletter == 'p') /* --proxy-header */
- err = add2list(&config->proxyheaders, nextarg);
- else
- err = add2list(&config->headers, nextarg);
- if(err)
- return err;
+ if(nextarg[0] == '@') {
+ /* read many headers from a file or stdin */
+ char *string;
+ size_t len;
+ bool use_stdin = !strcmp(&nextarg[1], "-");
+ FILE *file = use_stdin?stdin:fopen(&nextarg[1], FOPEN_READTEXT);
+ if(!file)
+ warnf(global, "Failed to open %s!\n", &nextarg[1]);
+ else {
+ if(PARAM_OK == file2memory(&string, &len, file)) {
+ /* Allow strtok() here since this isn't used threaded */
+ /* !checksrc! disable BANNEDFUNC 2 */
+ char *h = strtok(string, "\r\n");
+ while(h) {
+ if(subletter == 'p') /* --proxy-header */
+ err = add2list(&config->proxyheaders, h);
+ else
+ err = add2list(&config->headers, h);
+ if(err)
+ return err;
+ h = strtok(NULL, "\r\n");
+ }
+ free(string);
+ }
+ if(!use_stdin)
+ fclose(file);
+ }
+ }
+ else {
+ if(subletter == 'p') /* --proxy-header */
+ err = add2list(&config->proxyheaders, nextarg);
+ else
+ err = add2list(&config->headers, nextarg);
+ if(err)
+ return err;
+ }
break;
case 'i':
config->include_headers = toggle; /* include the headers as well in the
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnurl] annotated tag gnurl-7.55.0 created (now fe5f0f22e), gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 02/208: dist: make the hugehelp.c not get regenerated unnecessarily, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 17/208: fuzz/README: document how to build, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 13/208: TODO: the generated include file is gone, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 06/208: http-proxy: do the HTTP CONNECT process entirely non-blocking, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 05/208: progress: let "current speed" be UL + DL speeds combined, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 09/208: curl: allow --header and --proxy-header read from file,
gnunet <=
- [GNUnet-SVN] [gnurl] 20/208: dist: add the fuzz dir to the tarball, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 04/208: system.h: fix MinGW build, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 03/208: timers: store internal time stamps as time_t instead of doubles, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 12/208: curl_setup.h: error out on CURL_WANTS_CA_BUNDLE_ENV use, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 07/208: curl/curlver.h: start working on 7.55.0, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 08/208: RELEASE-NOTES: synced with 2ad80eec5, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 11/208: lib/curl_setup.h: remove CURL_WANTS_CA_BUNDLE_ENV, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 18/208: http-proxy: fix build with --disable-proxy or --disable-http, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 15/208: fuzz: bring oss-fuzz initial code converted to C89, gnunet, 2017/08/09
- [GNUnet-SVN] [gnurl] 10/208: test1147: verify -H on a file, gnunet, 2017/08/09