From: Casey Bodley Date: Mon, 21 Nov 2016 16:18:42 +0000 (-0500) Subject: rgw: only set CURLOPT_UPLOAD for PUT/POST requests X-Git-Tag: v10.2.6~70^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ece622dbc5d656928dddb1f63b963f219314b19c;p=ceph.git rgw: only set CURLOPT_UPLOAD for PUT/POST requests 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 (cherry picked from commit f3a0c40f106e3eaf3d8b3f8a6c34664bb2722a6c) --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index d8b4ca94167a..c3f58d902a1c 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -203,6 +203,14 @@ static curl_slist *headers_to_slist(list >& 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); }