get() will execute HTTP GET RESTful API with given url/headers/params, and return raw response content. This method does not care about response format, caller need to handle response format accordingly.
| 144 | // This method does not care about response format, caller need to handle |
| 145 | // response format accordingly. |
| 146 | Response S3RESTfulService::get(const string &url, HTTPHeaders &headers) { |
| 147 | Response response(RESPONSE_ERROR, this->s3MemContext); |
| 148 | response.getRawData().reserve(this->chunkBufferSize); |
| 149 | |
| 150 | headers.CreateList(); |
| 151 | CURLWrapper wrapper(url, headers.GetList(), this->lowSpeedLimit, this->lowSpeedTime, |
| 152 | this->debugCurl, this->proxy); |
| 153 | CURL *curl = wrapper.curl; |
| 154 | |
| 155 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, (void *)&response); |
| 156 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, RESTfulServiceWriteFuncCallback); |
| 157 | curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, this->verifyCert); |
| 158 | |
| 159 | this->performCurl(curl, response); |
| 160 | |
| 161 | if (response.getStatus() == RESPONSE_OK) { |
| 162 | return response; |
| 163 | } |
| 164 | |
| 165 | S3MessageParser s3msg(response); |
| 166 | ResponseCode responseCode = response.getResponseCode(); |
| 167 | |
| 168 | if ((responseCode == 500) || (responseCode == 503)) { |
| 169 | S3_DIE(S3ConnectionError, s3msg.getMessage()); |
| 170 | } |
| 171 | if (responseCode == 400) { |
| 172 | if (s3msg.getCode().compare("RequestTimeout") == 0) { |
| 173 | S3_DIE(S3ConnectionError, s3msg.getMessage()); |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | return response; |
| 178 | } |
| 179 | |
| 180 | Response S3RESTfulService::put(const string &url, HTTPHeaders &headers, const S3VectorUInt8 &data) { |
| 181 | Response response(RESPONSE_ERROR); |