aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Avina <aavina2@gmail.com>2015-04-25 14:49:39 -0400
committerJay Satiro <raysatiro@yahoo.com>2015-04-25 14:51:14 -0400
commit6a7261359b4c7ebddff0c096468047077e7d06ef (patch)
tree47eb925df798f22e2e52b8ca0f79159c035e2505 /src
parentf1e0a0aae714006766b2b1fddbd1f8192dbc933a (diff)
tool: New option --data-raw to HTTP POST data, '@' allowed.
Add new option --data-raw which is almost the same as --data but does not have a special interpretation of the @ character. Prior to this change there was no (easy) way to pass the @ character as the first character in POST data without it being interpreted as a special character. Bug: https://github.com/bagder/curl/issues/198 Reported-by: Jens Rantil
Diffstat (limited to 'src')
-rw-r--r--src/tool_getparam.c5
-rw-r--r--src/tool_help.c1
2 files changed, 4 insertions, 2 deletions
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index 121afc44d..1b5d6d2b0 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -196,6 +196,7 @@ static const struct LongShort aliases[]= {
{"c", "cookie-jar", TRUE},
{"C", "continue-at", TRUE},
{"d", "data", TRUE},
+ {"dr", "data-raw", TRUE},
{"da", "data-ascii", TRUE},
{"db", "data-binary", TRUE},
{"de", "data-urlencode", TRUE},
@@ -1099,6 +1100,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
char *postdata = NULL;
FILE *file;
size_t size = 0;
+ bool raw_mode = (subletter == 'r');
if(subletter == 'e') { /* --data-urlencode*/
/* [name]=[content], we encode the content part only
@@ -1124,7 +1126,6 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
}
if('@' == is_file) {
/* a '@' letter, it means that a file name or - (stdin) follows */
-
if(curlx_strequal("-", p)) {
file = stdin;
set_binmode(stdin);
@@ -1185,7 +1186,7 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
return PARAM_NO_MEM;
}
}
- else if('@' == *nextarg) {
+ else if('@' == *nextarg && !raw_mode) {
/* the data begins with a '@' letter, it means that a file name
or - (stdin) follows */
nextarg++; /* pass the @ */
diff --git a/src/tool_help.c b/src/tool_help.c
index 2f7fefd97..ef26ded0a 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -65,6 +65,7 @@ static const char *const helptext[] = {
" --crlf Convert LF to CRLF in upload",
" --crlfile FILE Get a CRL list in PEM format from the given file",
" -d, --data DATA HTTP POST data (H)",
+ " --data-raw DATA HTTP POST data, '@' allowed (H)",
" --data-ascii DATA HTTP POST ASCII data (H)",
" --data-binary DATA HTTP POST binary data (H)",
" --data-urlencode DATA HTTP POST data url encoded (H)",