]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: only set CURLOPT_UPLOAD for PUT/POST requests 12313/head
authorCasey Bodley <cbodley@redhat.com>
Mon, 21 Nov 2016 16:18:42 +0000 (11:18 -0500)
committerLoic Dachary <ldachary@redhat.com>
Mon, 5 Dec 2016 09:01:33 +0000 (10:01 +0100)
when set on GET requests, curl sends a 'Transfer-encoding: chunked'
header, but doesn't do the actual encoding to terminate the message

Fixes: http://tracker.ceph.com/issues/17822
Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit f3a0c40f106e3eaf3d8b3f8a6c34664bb2722a6c)

src/rgw/rgw_http_client.cc

index d8b4ca94167a5f978ef57f9cb7b805c09c2bfcee..c3f58d902a1cc79b203e2f9b8d6822e9efa5fe31 100644 (file)
@@ -203,6 +203,14 @@ static curl_slist *headers_to_slist(list<pair<string, string> >& headers)
   return h;
 }
 
+static bool is_upload_request(const char *method)
+{
+  if (method == nullptr) {
+    return false;
+  }
+  return strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0;
+}
+
 /*
  * process a single simple one off request, not going through RGWHTTPManager. Not using
  * req_data.
@@ -237,7 +245,9 @@ int RGWHTTPClient::process(const char *method, const char *url)
   }
   curl_easy_setopt(curl_handle, CURLOPT_READFUNCTION, simple_send_http_data);
   curl_easy_setopt(curl_handle, CURLOPT_READDATA, (void *)this);
-  curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L); 
+  if (is_upload_request(method)) {
+    curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L);
+  }
   if (has_send_len) {
     curl_easy_setopt(curl_handle, CURLOPT_INFILESIZE, (void *)send_len); 
   }
@@ -313,7 +323,9 @@ int RGWHTTPClient::init_request(const char *method, const char *url, rgw_http_re
   }
   curl_easy_setopt(easy_handle, CURLOPT_READFUNCTION, send_http_data);
   curl_easy_setopt(easy_handle, CURLOPT_READDATA, (void *)req_data);
-  curl_easy_setopt(easy_handle, CURLOPT_UPLOAD, 1L); 
+  if (is_upload_request(method)) {
+    curl_easy_setopt(easy_handle, CURLOPT_UPLOAD, 1L);
+  }
   if (has_send_len) {
     curl_easy_setopt(easy_handle, CURLOPT_INFILESIZE, (void *)send_len); 
   }