Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 12 additions & 41 deletions src/httpfs_curl_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
{
Expand Down Expand Up @@ -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;
{
Expand Down Expand Up @@ -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;
{
Expand Down Expand Up @@ -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;
{
Expand Down Expand Up @@ -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;
{
Expand All @@ -382,7 +362,9 @@ class HTTPFSCurlClient : public HTTPClient {
}

private:
CURLRequestHeaders TransformHeadersCurl(const HTTPHeaders &header_map) {
CURLRequestHeaders TransformHeadersCurl(const HTTPHeaders &header_map, const HTTPParams &params) {
auto &httpfs_params = params.Cast<HTTPFSParams>();

std::vector<std::string> headers;
for (auto &entry : header_map) {
const std::string new_header = entry.first + ": " + entry.second;
Expand All @@ -392,23 +374,12 @@ class HTTPFSCurlClient : public HTTPClient {
for (auto &header : headers) {
curl_headers.Add(header);
}
return curl_headers;
}

string TransformParamsCurl(const HTTPParams &params) {
string result = "";
unordered_map<string, string> 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() {
Expand Down
3 changes: 1 addition & 2 deletions src/s3fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Loading