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

Method fetchNextItem

Sming/Libraries/OtaNetwork/src/HttpUpgrader.cpp:23–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23void HttpUpgrader::fetchNextItem()
24{
25 if(currentItem >= items.count()) {
26 return;
27 }
28
29 auto& it = items[currentItem];
30 debug_d("Download file:\r\n"
31 " (%u) %s -> %s @ 0x%X",
32 currentItem, it.url.c_str(), it.partition.name().c_str(), it.partition.address());
33
34 HttpRequest* request;
35 if(baseRequest != nullptr) {
36 request = baseRequest->clone();
37 request->setURL(it.url);
38 } else {
39 request = new HttpRequest(it.url);
40 }
41
42 request->setMethod(HTTP_GET);
43 request->setResponseStream(it.getStream());
44
45 request->onRequestComplete(RequestCompletedDelegate(&HttpUpgrader::itemComplete, this));
46
47 if(!send(request)) {
48 debug_e("ERROR: Rejected sending new request.");
49 it.stream.release();
50 downloadFailed();
51 }
52}
53
54int HttpUpgrader::itemComplete(HttpConnection&, bool success)
55{

Callers

nothing calls this directly

Calls 11

addressMethod · 0.80
cloneMethod · 0.80
setURLMethod · 0.80
setResponseStreamMethod · 0.80
onRequestCompleteMethod · 0.80
countMethod · 0.45
c_strMethod · 0.45
nameMethod · 0.45
setMethodMethod · 0.45
getStreamMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected