diff --git a/src/httpfs_curl_client.cpp b/src/httpfs_curl_client.cpp index 18b8109..28ad46e 100644 --- a/src/httpfs_curl_client.cpp +++ b/src/httpfs_curl_client.cpp @@ -195,12 +195,8 @@ class HTTPFSCurlClient : public HTTPClient { state->get_count++; } - auto curl_headers = TransformHeadersCurl(info.headers); + auto curl_headers = TransformHeadersCurl(info.headers, info.params); request_info->url = info.url; - if (!info.params.extra_headers.empty()) { - auto curl_params = TransformParamsCurl(info.params); - request_info->url += "?" + curl_params; - } CURLcode res; { @@ -240,15 +236,11 @@ class HTTPFSCurlClient : public HTTPClient { state->total_bytes_sent += info.buffer_in_len; } - auto curl_headers = TransformHeadersCurl(info.headers); + auto curl_headers = TransformHeadersCurl(info.headers, info.params); // Add content type header from info curl_headers.Add("Content-Type: " + info.content_type); // transform parameters request_info->url = info.url; - if (!info.params.extra_headers.empty()) { - auto curl_params = TransformParamsCurl(info.params); - request_info->url += "?" + curl_params; - } CURLcode res; { @@ -276,13 +268,9 @@ class HTTPFSCurlClient : public HTTPClient { state->head_count++; } - auto curl_headers = TransformHeadersCurl(info.headers); + auto curl_headers = TransformHeadersCurl(info.headers, info.params); request_info->url = info.url; // transform parameters - if (!info.params.extra_headers.empty()) { - auto curl_params = TransformParamsCurl(info.params); - request_info->url += "?" + curl_params; - } CURLcode res; { @@ -310,13 +298,9 @@ class HTTPFSCurlClient : public HTTPClient { state->delete_count++; } - auto curl_headers = TransformHeadersCurl(info.headers); + auto curl_headers = TransformHeadersCurl(info.headers, info.params); // transform parameters request_info->url = info.url; - if (!info.params.extra_headers.empty()) { - auto curl_params = TransformParamsCurl(info.params); - request_info->url += "?" + curl_params; - } CURLcode res; { @@ -348,15 +332,11 @@ class HTTPFSCurlClient : public HTTPClient { state->total_bytes_sent += info.buffer_in_len; } - auto curl_headers = TransformHeadersCurl(info.headers); + auto curl_headers = TransformHeadersCurl(info.headers, info.params); const string content_type = "Content-Type: application/octet-stream"; curl_headers.Add(content_type.c_str()); // transform parameters request_info->url = info.url; - if (!info.params.extra_headers.empty()) { - auto curl_params = TransformParamsCurl(info.params); - request_info->url += "?" + curl_params; - } CURLcode res; { @@ -382,7 +362,9 @@ class HTTPFSCurlClient : public HTTPClient { } private: - CURLRequestHeaders TransformHeadersCurl(const HTTPHeaders &header_map) { + CURLRequestHeaders TransformHeadersCurl(const HTTPHeaders &header_map, const HTTPParams ¶ms) { + auto &httpfs_params = params.Cast(); + std::vector headers; for (auto &entry : header_map) { const std::string new_header = entry.first + ": " + entry.second; @@ -392,23 +374,12 @@ class HTTPFSCurlClient : public HTTPClient { for (auto &header : headers) { curl_headers.Add(header); } - return curl_headers; - } - - string TransformParamsCurl(const HTTPParams ¶ms) { - string result = ""; - unordered_map escaped_params; - bool first_param = true; - for (auto &entry : params.extra_headers) { - const string key = entry.first; - const string value = curl_easy_escape(*curl, entry.second.c_str(), 0); - if (!first_param) { - result += "&"; + if (!httpfs_params.pre_merged_headers) { + for (auto &entry : params.extra_headers) { + curl_headers.Add(entry.first + ": " + entry.second); } - result += key + "=" + value; - first_param = false; } - return result; + return curl_headers; } void ResetRequestInfo() { diff --git a/src/s3fs.cpp b/src/s3fs.cpp index 1510bab..a7b6a8d 100644 --- a/src/s3fs.cpp +++ b/src/s3fs.cpp @@ -1236,13 +1236,12 @@ string AWSListObjectV2::Request(string &path, HTTPParams &http_params, S3AuthPar req_params += "&delimiter=%2F"; } - string listobjectv2_url = req_path + "?" + req_params; - auto header_map = CreateS3Header(req_path, req_params, parsed_url.host, "s3", "GET", s3_auth_params, "", "", "", ""); // Get requests use fresh connection string full_host = parsed_url.http_proto + parsed_url.host; + string listobjectv2_url = full_host + req_path + "?" + req_params; std::stringstream response; GetRequestInfo get_request( full_host, listobjectv2_url, header_map, http_params,