| 30 | } |
| 31 | |
| 32 | Response S3InterfaceService::getResponseWithRetries(const string &url, HTTPHeaders &headers, |
| 33 | uint64_t retries) { |
| 34 | string code; |
| 35 | string message; |
| 36 | uint64_t retry = retries; |
| 37 | |
| 38 | while (retry--) { |
| 39 | try { |
| 40 | return this->restfulService->get(url, headers); |
| 41 | } catch (S3ConnectionError &e) { |
| 42 | message = e.getMessage(); |
| 43 | if (S3QueryIsAbortInProgress()) { |
| 44 | S3_DIE(S3QueryAbort, "Downloading is interrupted"); |
| 45 | } |
| 46 | S3WARN("Failed to get a good response in GET from '%s', retrying ...", url.c_str()); |
| 47 | } catch (S3LogicError &e) { |
| 48 | code = e.getCode(); |
| 49 | if (code == "NoSuchKey") { |
| 50 | sleep(1); |
| 51 | continue; |
| 52 | } else { |
| 53 | throw e; |
| 54 | } |
| 55 | } |
| 56 | }; |
| 57 | |
| 58 | S3_DIE(S3FailedAfterRetry, url, retries, message); |
| 59 | }; |
| 60 | |
| 61 | Response S3InterfaceService::putResponseWithRetries(const string &url, HTTPHeaders &headers, |
| 62 | S3VectorUInt8 &data, uint64_t retries) { |