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: v11.1.0~107^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F12105%2Fhead;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 --- diff --git a/src/rgw/rgw_http_client.cc b/src/rgw/rgw_http_client.cc index 157644e38e8..076846c3082 100644 --- a/src/rgw/rgw_http_client.cc +++ b/src/rgw/rgw_http_client.cc @@ -226,6 +226,14 @@ static curl_slist *headers_to_slist(param_vec_t& 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. @@ -260,7 +268,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); } @@ -336,7 +346,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); }