| 178 | } |
| 179 | |
| 180 | Response 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 | |
| 222 | Response S3RESTfulService::post(const string &url, HTTPHeaders &headers, |
| 223 | const vector<uint8_t> &data) { |