| 69 | } |
| 70 | |
| 71 | void assertResponseIsOk(const String & uri, Poco::Net::HTTPResponse & response, std::istream & istr, const bool allow_redirects) |
| 72 | { |
| 73 | auto status = response.getStatus(); |
| 74 | |
| 75 | if (!(status == Poco::Net::HTTPResponse::HTTP_OK |
| 76 | || status == Poco::Net::HTTPResponse::HTTP_CREATED |
| 77 | || status == Poco::Net::HTTPResponse::HTTP_ACCEPTED |
| 78 | || status == Poco::Net::HTTPResponse::HTTP_PARTIAL_CONTENT /// Reading with Range header was successful. |
| 79 | || (isRedirect(status) && allow_redirects))) |
| 80 | { |
| 81 | int code = status == Poco::Net::HTTPResponse::HTTP_TOO_MANY_REQUESTS |
| 82 | ? ErrorCodes::RECEIVED_ERROR_TOO_MANY_REQUESTS |
| 83 | : ErrorCodes::RECEIVED_ERROR_FROM_REMOTE_IO_SERVER; |
| 84 | |
| 85 | std::string body; |
| 86 | Poco::StreamCopier::copyToString(istr, body); |
| 87 | |
| 88 | throw HTTPException(code, uri, status, response.getReason(), body); |
| 89 | } |
| 90 | } |
| 91 | |
| 92 | Exception HTTPException::makeExceptionMessage( |
| 93 | int code, |
no test coverage detected