From 903b6e05565bf826b4194447864288642214b094 Mon Sep 17 00:00:00 2001
From: Daniel Stenberg <daniel@haxx.se>
Date: Tue, 23 Jun 2015 17:48:37 -0700
Subject: [PATCH] pretransfer: init state.infilesize here, not in add_handle
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

... to properly support that options are set to the handle after it is
added to the multi handle.

Bug: http://curl.haxx.se/mail/lib-2015-06/0122.html
Reported-by: Stefan Bühler
---
 lib/multi.c    | 5 -----
 lib/transfer.c | 5 +++++
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/lib/multi.c b/lib/multi.c
index b63f8bf..a8d3e38 100644
--- a/lib/multi.c
+++ b/lib/multi.c
@@ -400,15 +400,10 @@ CURLMcode curl_multi_add_handle(CURLM *multi_handle,
   }
 
   /* Point to the multi's connection cache */
   data->state.conn_cache = &multi->conn_cache;
 
-  if(data->set.httpreq == HTTPREQ_PUT)
-    data->state.infilesize = data->set.filesize;
-  else
-    data->state.infilesize = data->set.postfieldsize;
-
   /* This adds the new entry at the 'end' of the doubly-linked circular
      list of SessionHandle structs to try and maintain a FIFO queue so
      the pipelined requests are in order. */
 
   /* We add this new entry last in the list. */
diff --git a/lib/transfer.c b/lib/transfer.c
index 28cc61e..32e8702 100644
--- a/lib/transfer.c
+++ b/lib/transfer.c
@@ -1313,10 +1313,15 @@ CURLcode Curl_pretransfer(struct SessionHandle *data)
   data->state.authhost.want = data->set.httpauth;
   data->state.authproxy.want = data->set.proxyauth;
   Curl_safefree(data->info.wouldredirect);
   data->info.wouldredirect = NULL;
 
+  if(data->set.httpreq == HTTPREQ_PUT)
+    data->state.infilesize = data->set.filesize;
+  else
+    data->state.infilesize = data->set.postfieldsize;
+
   /* If there is a list of cookie files to read, do it now! */
   if(data->change.cookielist)
     Curl_cookie_loadfiles(data);
 
   /* If there is a list of host pairs to deal with */
-- 
2.1.4

