MCPcopy Create free account
hub / github.com/SmingHub/Sming / send

Method send

Sming/Components/Network/src/Network/Http/HttpClient.cpp:19–47  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

17SimpleTimer HttpClient::cleanUpTimer;
18
19bool HttpClient::send(HttpRequest* request)
20{
21 String cacheKey = getCacheKey(request->uri);
22
23 HttpClientConnection* connection = nullptr;
24
25 int i = httpConnectionPool.indexOf(cacheKey);
26 if(i >= 0) {
27 // Check existing connection
28 connection = httpConnectionPool.valueAt(i);
29 }
30
31 if(connection == nullptr) {
32 debug_d("Creating new HttpClientConnection");
33 connection = new HttpClientConnection();
34 if(connection == nullptr) {
35 debug_e("Cannot send request. Out of memory");
36 // Out of memory
37 delete request;
38 return false;
39 }
40 httpConnectionPool[cacheKey] = connection;
41 }
42
43 if(!cleanUpTimer.isStarted()) {
44 cleanUpTimer.initializeMs<60000>(HttpClient::cleanInactive).start(); // run every minute
45 }
46 return connection->send(request);
47}
48
49bool HttpClient::downloadFile(const Url& url, const String& saveFileName, RequestCompletedDelegate requestComplete)
50{

Callers

nothing calls this directly

Calls 4

valueAtMethod · 0.80
isStartedMethod · 0.80
indexOfMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected