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

Method put

gpcontrib/gpcloud/src/s3restful_service.cpp:180–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180Response S3RESTfulService::put(const string &url, HTTPHeaders &headers, const S3VectorUInt8 &data) {
181 Response response(RESPONSE_ERROR);
182
183 headers.CreateList();
184 CURLWrapper wrapper(url, headers.GetList(), this->lowSpeedLimit, this->lowSpeedTime,
185 this->debugCurl, this->proxy);
186 CURL *curl = wrapper.curl;
187
188 curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response);
189 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, RESTfulServiceWriteFuncCallback);
190 curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, this->verifyCert);
191
192 UploadData uploadData(data);
193 curl_easy_setopt(curl, CURLOPT_READDATA, (void *)&uploadData);
194 curl_easy_setopt(curl, CURLOPT_READFUNCTION, RESTfulServiceReadFuncCallback);
195 curl_easy_setopt(curl, CURLOPT_INFILESIZE_LARGE, (curl_off_t)data.size());
196 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
197
198 curl_easy_setopt(curl, CURLOPT_HEADERDATA, (void *)&response);
199 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, RESTfulServiceHeadersWriteFuncCallback);
200
201 this->performCurl(curl, response);
202
203 S3MessageParser s3msg(response);
204 ResponseCode responseCode = response.getResponseCode();
205
206 if (response.getStatus() == RESPONSE_OK) {
207 return response;
208 }
209
210 if ((responseCode == 500) || (responseCode == 503)) {
211 S3_DIE(S3ConnectionError, s3msg.getMessage());
212 }
213 if (responseCode == 400) {
214 if (s3msg.getCode().compare("RequestTimeout") == 0) {
215 S3_DIE(S3ConnectionError, s3msg.getMessage());
216 }
217 }
218
219 return response;
220}
221
222Response S3RESTfulService::post(const string &url, HTTPHeaders &headers,
223 const vector<uint8_t> &data) {

Callers 5

TESTFunction · 0.45
addFinishedWorkItemMethod · 0.45
addCommandMethod · 0.45
haltWorkMethod · 0.45

Calls 8

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

Tested by 1

TESTFunction · 0.36