From e4e376b4c26e02dfd2f646185a11fe65d6950602 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Mon, 14 Dec 2015 13:29:13 +0100
Subject: [PATCH] curl --expect100-timeout: added

This is the new command line option to set the value for the existing
libcurl option CURLOPT_EXPECT_100_TIMEOUT_MS
---
 docs/curl.1         | 7 +++++++
 src/tool_cfgable.h  | 1 +
 src/tool_getparam.c | 6 ++++++
 src/tool_help.c     | 1 +
 src/tool_operate.c  | 5 +++++
 5 files changed, 20 insertions(+)

diff --git a/docs/curl.1 b/docs/curl.1
index eabcc96..5cc7c73 100644
--- a/docs/curl.1
+++ b/docs/curl.1
@@ -521,10 +521,17 @@ run-time.
 after having run curl.
 .IP "--egd-file <file>"
 (SSL) Specify the path name to the Entropy Gathering Daemon socket. The socket
 is used to seed the random engine for SSL connections. See also the
 \fI--random-file\fP option.
+.IP "--expect100-timeout <seconds>"
+(HTTP) Maximum time in seconds that you allow curl to wait for a 100-continue
+response when curl emits an Expects: 100-continue header in its request. By
+default curl will wait one second. This option accepts decimal values! When
+curl stops waiting, it will continue as if the response has been received.
+
+(Added in 7.47.0)
 .IP "--cert-type <type>"
 (SSL) Tells curl what certificate type the provided certificate is in. PEM,
 DER and ENG are recognized types.  If not specified, PEM is assumed.
 
 If this option is used several times, the last one will be used.
diff --git a/src/tool_cfgable.h b/src/tool_cfgable.h
index 85b8bcf..b92a273 100644
--- a/src/tool_cfgable.h
+++ b/src/tool_cfgable.h
@@ -212,10 +212,11 @@ struct OperationConfig {
   bool nonpn;                     /* enable/disable TLS NPN extension */
   bool noalpn;                    /* enable/disable TLS ALPN extension */
   char *unix_socket_path;         /* path to Unix domain socket */
   bool falsestart;
   bool path_as_is;
+  double expect100timeout;
   struct GlobalConfig *global;
   struct OperationConfig *prev;
   struct OperationConfig *next;   /* Always last in the struct */
 };
 
diff --git a/src/tool_getparam.c b/src/tool_getparam.c
index fd20cdc..d123e23 100644
--- a/src/tool_getparam.c
+++ b/src/tool_getparam.c
@@ -177,10 +177,11 @@ static const struct LongShort aliases[]= {
   {"$M", "unix-socket",              TRUE},
   {"$N", "path-as-is",               FALSE},
   {"$O", "proxy-service-name",       TRUE},
   {"$P", "service-name",             TRUE},
   {"$Q", "proto-default",            TRUE},
+  {"$R", "expect100-timeout",        TRUE},
   {"0",   "http1.0",                 FALSE},
   {"01",  "http1.1",                 FALSE},
   {"02",  "http2",                   FALSE},
   {"1",  "tlsv1",                    FALSE},
   {"10",  "tlsv1.0",                 FALSE},
@@ -997,10 +998,15 @@ ParameterError getparameter(char *flag,    /* f or -long-flag */
         GetStr(&config->proto_default, nextarg);
         err = check_protocol(config->proto_default);
         if(err)
           return err;
         break;
+      case 'R': /* --expect100-timeout */
+        err = str2udouble(&config->expect100timeout, nextarg);
+        if(err)
+          return err;
+        break;
       }
       break;
     case '#': /* --progress-bar */
       if(toggle)
         global->progressmode = CURL_PROGRESS_BAR;
diff --git a/src/tool_help.c b/src/tool_help.c
index 4f569cd..bbb2f66 100644
--- a/src/tool_help.c
+++ b/src/tool_help.c
@@ -81,10 +81,11 @@ static const char *const helptext[] = {
   "     --egd-file FILE  EGD socket path for random data (SSL)",
   "     --engine ENGINE  Crypto engine (use \"--engine list\" for list) (SSL)",
 #ifdef USE_ENVIRONMENT
   "     --environment   Write results to environment variables (RISC OS)",
 #endif
+  "     --expect100-timeout SECONDS How long to wait for 100-continue (H)",
   " -f, --fail          Fail silently (no output at all) on HTTP errors (H)",
   "     --false-start   Enable TLS False Start.",
   " -F, --form CONTENT  Specify HTTP multipart POST data (H)",
   "     --form-string STRING  Specify HTTP multipart POST data (H)",
   "     --ftp-account DATA  Account data string (F)",
diff --git a/src/tool_operate.c b/src/tool_operate.c
index e5506c6..30d60cb 100644
--- a/src/tool_operate.c
+++ b/src/tool_operate.c
@@ -1356,10 +1356,15 @@ static CURLcode operate_do(struct GlobalConfig *global,
 
         /* new in 7.45.0 */
         if(config->proto_default)
           my_setopt_str(curl, CURLOPT_DEFAULT_PROTOCOL, config->proto_default);
 
+        /* new in 7.47.0 */
+        if(config->expect100timeout > 0)
+          my_setopt_str(curl, CURLOPT_EXPECT_100_TIMEOUT_MS,
+                        (long)(config->expect100timeout*1000));
+
         /* initialize retry vars for loop below */
         retry_sleep_default = (config->retry_delay) ?
           config->retry_delay*1000L : RETRY_SLEEP_DEFAULT; /* ms */
 
         retry_numretries = config->req_retry;
-- 
2.6.4

