| 156 | } |
| 157 | |
| 158 | std::string API::doJWSRequest( |
| 159 | const Poco::URI & url, |
| 160 | const std::string & payload, |
| 161 | std::shared_ptr<Poco::Net::HTTPResponse> response) const |
| 162 | { |
| 163 | LOG_TEST(log, "Making JWS request to URL: {} with payload {}", url.toString(), payload); |
| 164 | |
| 165 | std::string nonce = requestNonce(); |
| 166 | std::string request_data = formatJWSRequestData(url, payload, nonce); |
| 167 | |
| 168 | auto r = Poco::Net::HTTPRequest(Poco::Net::HTTPRequest::HTTP_POST, url.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1); |
| 169 | r.set("User-Agent", fmt::format("ClickHouse/{}", VERSION_STRING)); |
| 170 | r.set("Content-Type", APPLICATION_JOSE_JSON); |
| 171 | r.set("Content-Length", std::to_string(request_data.size())); |
| 172 | |
| 173 | auto session = makeHTTPSession(HTTPConnectionGroupType::HTTP, url, connection_timeout_settings, proxy_configuration); |
| 174 | session->setKeepAlive(false); |
| 175 | |
| 176 | ProfileEvents::increment(ProfileEvents::ACMEAPIRequests); |
| 177 | |
| 178 | auto & ostream = session->sendRequest(r); |
| 179 | ostream << request_data; |
| 180 | |
| 181 | if (!response) |
| 182 | response = std::make_shared<Poco::Net::HTTPResponse>(); |
| 183 | |
| 184 | auto * rstream = receiveResponse(*session, r, *response, /* allow_redirects */ false); |
| 185 | |
| 186 | std::string response_data; |
| 187 | Poco::StreamCopier::copyToString(*rstream, response_data); |
| 188 | |
| 189 | return response_data; |
| 190 | } |
| 191 | |
| 192 | Poco::JSON::Object::Ptr API::doJWSRequestExpectingJSON( |
| 193 | const Poco::URI & url, |
nothing calls this directly
no test coverage detected