MCPcopy Create free account
hub / github.com/apache/cloudberry / post

Method post

gpcontrib/gpcloud/src/s3restful_service.cpp:222–261  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

220}
221
222Response S3RESTfulService::post(const string &url, HTTPHeaders &headers,
223 const vector<uint8_t> &data) {
224 Response response(RESPONSE_ERROR);
225
226 headers.CreateList();
227 CURLWrapper wrapper(url, headers.GetList(), this->lowSpeedLimit, this->lowSpeedTime,
228 this->debugCurl, this->proxy);
229 CURL *curl = wrapper.curl;
230
231 curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response);
232 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, RESTfulServiceWriteFuncCallback);
233 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, this->verifyCert);
234 curl_easy_setopt(curl, CURLOPT_POST, 1L);
235
236 S3VectorUInt8 s3data(data);
237 UploadData uploadData(s3data);
238 curl_easy_setopt(curl, CURLOPT_READDATA, (void *)&uploadData);
239 curl_easy_setopt(curl, CURLOPT_READFUNCTION, RESTfulServiceReadFuncCallback);
240 curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)data.size());
241
242 this->performCurl(curl, response);
243
244 if (response.getStatus() == RESPONSE_OK) {
245 return response;
246 }
247
248 S3MessageParser s3msg(response);
249 ResponseCode responseCode = response.getResponseCode();
250
251 if ((responseCode == 500) || (responseCode == 503)) {
252 S3_DIE(S3ConnectionError, s3msg.getMessage());
253 }
254 if (responseCode == 400) {
255 if (s3msg.getCode().compare("RequestTimeout") == 0) {
256 S3_DIE(S3ConnectionError, s3msg.getMessage());
257 }
258 }
259
260 return response;
261}
262
263// head() will execute HTTP HEAD RESTful API with given url/headers/params, and return the HTTP
264// response code.

Callers 2

TESTFunction · 0.80

Calls 8

performCurlMethod · 0.95
CreateListMethod · 0.80
GetListMethod · 0.80
getStatusMethod · 0.80
getResponseCodeMethod · 0.80
sizeMethod · 0.45
getMessageMethod · 0.45
getCodeMethod · 0.45

Tested by 1

TESTFunction · 0.64