Skip to content

Commit 7809283

Browse files
committed
Clean up HTTP examples
1 parent d7c7e2b commit 7809283

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

Diff for: examples/HTTPClient/HTTPClient.ino

+6-9
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
#include "ArduinoCellular.h"
44
#include "arduino_secrets.h"
55

6-
76
const char server[] = "vsh.pp.ua";
87
const char resource[] = "/TinyGSM/logo.txt";
98
const int port = 80;
109

1110
ArduinoCellular cellular = ArduinoCellular();
12-
HttpClient http = cellular.getHTTPClient(server, port);
13-
11+
HttpClient client = cellular.getHTTPClient(server, port);
1412

1513
void setup(){
1614
Serial.begin(115200);
@@ -23,19 +21,18 @@ void loop(){
2321

2422
Serial.println("Making GET request...");
2523

26-
http.get(resource);
24+
client.get(resource);
2725

28-
int status_code = http.responseStatusCode();
29-
String response = http.responseBody();
26+
int statusCode = client.responseStatusCode();
27+
String response = client.responseBody();
3028

3129
Serial.print("Status code: ");
32-
Serial.println(status_code);
30+
Serial.println(statusCode);
3331
Serial.print("Response: ");
3432
Serial.println(response);
3533

36-
http.stop();
34+
client.stop();
3735

3836
delay(5000);
3937

4038
}
41-

Diff for: examples/HTTPSClient/HTTPSClient.ino

+8-11
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
#include <ArduinoHttpClient.h>
55
#include "arduino_secrets.h"
66

7-
87
const char server[] = "example.com";
98
const char resource[] = "/";
109
const int port = 443;
1110

1211
ArduinoCellular cellular = ArduinoCellular();
13-
HttpClient http = cellular.getHTTPSClient(server, port);
12+
HttpClient client = cellular.getHTTPSClient(server, port);
1413

1514
void setup(){
1615
Serial.begin(115200);
@@ -20,21 +19,19 @@ void setup(){
2019
cellular.connect(SECRET_GPRS_APN, SECRET_GPRS_LOGIN, SECRET_GPRS_PASSWORD, SECRET_PINNUMBER);
2120
}
2221

23-
void loop()
24-
{
22+
void loop(){
2523
Serial.println("Making GET request...");
2624

27-
http.get(resource);
25+
client.get(resource);
2826

29-
int status_code = http.responseStatusCode();
30-
String response = http.responseBody();
27+
int statusCode = client.responseStatusCode();
28+
String response = client.responseBody();
3129

3230
Serial.print("Status code: ");
33-
Serial.println(status_code);
31+
Serial.println(statusCode);
3432
Serial.print("Response: ");
3533
Serial.println(response);
3634

37-
http.stop();
38-
35+
client.stop();
3936
delay(5000);
40-
}
37+
}

0 commit comments

Comments
 (0)