generated from duckdb/extension-template
    
        
        - 
                Notifications
    You must be signed in to change notification settings 
- Fork 0
Open
Description
duckdb-curl-filesystem/src/httpfs_curl_client.cpp
Lines 295 to 331 in a27dd4a
| unique_ptr<HTTPResponse> Post(PostRequestInfo &info) override { | |
| if (state) { | |
| state->post_count++; | |
| state->total_bytes_sent += info.buffer_in_len; | |
| } | |
| auto curl_headers = TransformHeadersCurl(info.headers); | |
| 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; | |
| { | |
| curl_easy_setopt(*curl, CURLOPT_URL, request_info->url.c_str()); | |
| curl_easy_setopt(*curl, CURLOPT_POST, 1L); | |
| // Set POST body | |
| curl_easy_setopt(*curl, CURLOPT_POSTFIELDS, const_char_ptr_cast(info.buffer_in)); | |
| curl_easy_setopt(*curl, CURLOPT_POSTFIELDSIZE, info.buffer_in_len); | |
| // Add headers if any | |
| curl_easy_setopt(*curl, CURLOPT_HTTPHEADER, curl_headers ? curl_headers.headers : nullptr); | |
| // Execute POST request | |
| res = curl->Execute(); | |
| } | |
| curl_easy_getinfo(*curl, CURLINFO_RESPONSE_CODE, &request_info->response_code); | |
| info.buffer_out = request_info->body; | |
| // Construct HTTPResponse | |
| return TransformResponseCurl(res); | |
| } | 
Metadata
Metadata
Assignees
Labels
No labels