Index: lib/http.c
===================================================================
RCS file: /repository/curl/lib/http.c,v
retrieving revision 1.178
diff -u -r1.178 http.c
--- lib/http.c	7 Jan 2004 09:19:35 -0000	1.178
+++ lib/http.c	8 Jan 2004 08:21:47 -0000
@@ -1036,7 +1036,6 @@
   char *ptr;
   char *request;
   bool authdone=TRUE; /* if the authentication phase is done */
-  Curl_HttpReq httpreq;  /* type of HTTP request */
 
   if(!conn->proto.http) {
     /* Only allocate this struct if we don't already have it! */
@@ -1437,13 +1436,11 @@
     http->postdata = NULL;  /* nothing to post at this point */
     Curl_pgrsSetUploadSize(data, 0); /* upload size is 0 atm */
 
-    if(!authdone)
-      /* until the auth is done, pretend we only do GET */
-      httpreq = HTTPREQ_GET;
-    else
-      httpreq = data->set.httpreq;
+    /* If 'authdone' is still FALSE, we must not set the write socket index to
+       the Curl_transfer() call below, as we're not ready to actually upload
+       any data yet. */
 
-    switch(httpreq) {
+    switch(data->set.httpreq) {
 
     case HTTPREQ_POST_FORM:
       if(Curl_FormInit(&http->form, http->sendit)) {
@@ -1508,8 +1505,8 @@
         /* setup variables for the upcoming transfer */
         result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE,
                                &http->readbytecount,
-                               FIRSTSOCKET,
-                               &http->writebytecount);
+                               authdone?FIRSTSOCKET:-1,
+                               authdone?&http->writebytecount:NULL);
       if(result) {
         Curl_formclean(http->sendit); /* free that whole lot */
         return result;
@@ -1538,8 +1535,8 @@
         /* prepare for transfer */
         result = Curl_Transfer(conn, FIRSTSOCKET, -1, TRUE,
                                &http->readbytecount,
-                               FIRSTSOCKET,
-                               &http->writebytecount);
+                               authdone?FIRSTSOCKET:-1,
+                               authdone?&http->writebytecount:NULL);
       if(result)
         return result;
       break;
@@ -1569,7 +1566,11 @@
 
       add_buffer(req_buffer, "\r\n", 2);
 
-      if(data->set.postfields) {
+      if(!authdone) {
+        /* we're not done with the authentication phase, so we don't actually
+           send off any data. http->postdata remains set to NULL */
+      }
+      else if(data->set.postfields) {
 
         if(postsize < (100*1024)) {
           /* The post data is less than 100K, then append it to the header.
