Hi,

If the Expect: 100-continue header has been set by the application through 
curl_easy_setopt with CURLOPT_HTTPHEADER, the library should set 
data->state.expect100header accordingly - the current code (in 7.19.7 at 
least) doesn't handle this properly. The two attached patches fixes this.

// Martin
--- curl-7.19.7-orig/lib/http.c	2009-10-31 00:24:48.000000000 +0200
+++ curl-7.19.7/lib/http.c	2009-11-30 16:30:44.000000000 +0200
@@ -1983,15 +1983,22 @@
   CURLcode result = CURLE_OK;
   data->state.expect100header = FALSE; /* default to false unless it is set
                                           to TRUE below */
-  if(use_http_1_1(data, conn) && !checkheaders(data, "Expect:")) {
+  const char *ptr;
+  if(use_http_1_1(data, conn)) {
     /* if not doing HTTP 1.0 or disabled explicitly, we add a Expect:
        100-continue to the headers which actually speeds up post
        operations (as there is one packet coming back from the web
        server) */
-    result = add_bufferf(req_buffer,
-                         "Expect: 100-continue\r\n");
-    if(result == CURLE_OK)
-      data->state.expect100header = TRUE;
+    ptr = checkheaders(data, "Expect:");
+    if (ptr) {
+      data->state.expect100header =
+        Curl_compareheader(ptr, "Expect:", "100-continue");
+    } else {
+      result = add_bufferf(req_buffer,
+                           "Expect: 100-continue\r\n");
+      if(result == CURLE_OK)
+        data->state.expect100header = TRUE;
+    }
   }
   return result;
 }
--- curl-7.19.7-orig/lib/http.c	2009-10-31 00:24:48.000000000 +0200
+++ curl-7.19.7/lib/http.c	2009-11-30 16:34:58.000000000 +0200
@@ -2837,7 +2837,12 @@
        the somewhat bigger ones we allow the app to disable it. Just make
        sure that the expect100header is always set to the preferred value
        here. */
-    if(postsize > TINY_INITIAL_POST_SIZE) {
+    ptr = checkheaders(data, "Expect:");
+    if(ptr) {
+      data->state.expect100header = 
+        Curl_compareheader(ptr, "Expect:", "100-continue");
+    }
+    else if(postsize > TINY_INITIAL_POST_SIZE) {
       result = expect100(data, conn, req_buffer);
       if(result)
         return result;
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html

Reply via email to