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

Function onDownload

samples/HttpClient/app/application.cpp:14–41  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12HttpClient httpClient;
13
14int onDownload(HttpConnection& connection, bool success)
15{
16 auto& request = *connection.getRequest();
17 auto& response = *connection.getResponse();
18
19 Serial << endl << _F("=========[ URL: ") << request.uri << _F(" ]============") << endl;
20 Serial << _F("RemoteIP: ") << connection.getRemoteIp() << endl;
21 Serial << _F("Got response code: ") << response.code << " " << toString(response.code) << endl;
22 Serial << _F("Success: ") << success << " " << (success ? "OK" : "FAIL") << endl;
23
24 if(request.method != HTTP_HEAD) {
25 Serial.print(_F("Got content: "));
26 auto stream = response.stream;
27 if(stream == nullptr || stream->available() == 0) {
28 Serial.println(_F("EMPTY!"));
29 } else {
30 Serial.copyFrom(stream);
31 Serial.println();
32 }
33 }
34
35 auto ssl = connection.getSsl();
36 if(ssl != nullptr) {
37 ssl->printTo(Serial);
38 }
39
40 return 0; // return 0 on success in your callbacks
41}
42
43void sslRequestInit(Ssl::Session& session, HttpRequest& request)
44{

Callers

nothing calls this directly

Calls 10

getResponseMethod · 0.80
getRemoteIpMethod · 0.80
printlnMethod · 0.80
getSslMethod · 0.80
toStringFunction · 0.50
getRequestMethod · 0.45
printMethod · 0.45
availableMethod · 0.45
copyFromMethod · 0.45
printToMethod · 0.45

Tested by

no test coverage detected