MCPcopy Create free account
hub / github.com/Pagghiu/SaneCppLibraries / prepareRequest

Method prepareRequest

Libraries/Http/HttpAsyncClient.cpp:216–235  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214}
215
216Result HttpAsyncClient::prepareRequest(const RequestPreset& preset)
217{
218 response.reset(connection->getHeaderMemory());
219 SC_TRY(
220 response.initBodyStream(connection->buffersPool, {[this]() -> Result { return onResponseBodyStreamRead(); }}));
221
222 SC_TRY(currentURL.parse(preset.url));
223 const bool isHttp = HttpStringIterator::equalsIgnoreCase(currentURL.protocol, "http");
224 const bool isHttps = HttpStringIterator::equalsIgnoreCase(currentURL.protocol, "https");
225 SC_TRY_MSG(isHttp or isHttps, "HttpAsyncClient only supports http and https URLs");
226 SC_TRY_MSG(currentURL.username.isEmpty() and currentURL.password.isEmpty(),
227 "HttpAsyncClient userinfo not supported");
228 if (transportPreflight.isValid())
229 {
230 SC_TRY(transportPreflight(currentURL));
231 }
232 return Result(true);
233}
234
235bool HttpAsyncClient::canReuseConnectionFor(StringSpan protocol, StringSpan host, uint16_t port) const
236{
237 return hasOpenConnection and currentPort == port and currentProtocol == protocol and currentHost == host;
238}

Callers 2

sessionLayerMethod · 0.45
saneMainFunction · 0.45

Calls 6

initBodyStreamMethod · 0.80
ResultClass · 0.50
resetMethod · 0.45
parseMethod · 0.45
isValidMethod · 0.45
isEmptyMethod · 0.45

Tested by 1

sessionLayerMethod · 0.36