MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / assertResponseIsOk

Function assertResponseIsOk

src/IO/HTTPCommon.cpp:71–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void 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
92Exception HTTPException::makeExceptionMessage(
93 int code,

Callers 3

receiveResponseFunction · 0.85
callImplMethod · 0.85
registerSchemaMethod · 0.85

Calls 3

isRedirectFunction · 0.85
HTTPExceptionClass · 0.85
getStatusMethod · 0.45

Tested by

no test coverage detected