mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-12 01:53:07 +03:00
Add WiFiClient parameter to HTTPClient (#4980)
Make HTTPClient take a WiFiClient parameter, allowing you to pass in a simple HTTP WiFiClient or a BearSSL or axTLS WiFiClientSecure with any desired verification options. Deprecate the older, TLSTraits methods. Add basic HttpsClient example. Add optional LED feedback to the Update class
This commit is contained in:
committed by
Earle F. Philhower, III
parent
9bc8ea1b58
commit
13f374666d
@ -11,8 +11,8 @@
|
||||
|
||||
#include <ESP8266HTTPClient.h>
|
||||
|
||||
const char* ssid = "........";
|
||||
const char* ssidPassword = "........";
|
||||
const char* ssid = "SSID";
|
||||
const char* ssidPassword = "PASSWORD";
|
||||
|
||||
const char *username = "admin";
|
||||
const char *password = "admin";
|
||||
@ -76,7 +76,7 @@ String getDigestAuth(String& authReq, const String& username, const String& pass
|
||||
}
|
||||
|
||||
void setup() {
|
||||
Serial.begin(9600);
|
||||
Serial.begin(115200);
|
||||
|
||||
WiFi.mode(WIFI_STA);
|
||||
WiFi.begin(ssid, ssidPassword);
|
||||
@ -95,10 +95,12 @@ void setup() {
|
||||
void loop() {
|
||||
HTTPClient http;
|
||||
|
||||
WiFiClient client;
|
||||
|
||||
Serial.print("[HTTP] begin...\n");
|
||||
|
||||
// configure traged server and url
|
||||
http.begin(String(server) + String(uri));
|
||||
http.begin(client, String(server) + String(uri));
|
||||
|
||||
|
||||
const char *keys[] = {"WWW-Authenticate"};
|
||||
@ -115,7 +117,7 @@ void loop() {
|
||||
String authorization = getDigestAuth(authReq, String(username), String(password), String(uri), 1);
|
||||
|
||||
http.end();
|
||||
http.begin(String(server) + String(uri));
|
||||
http.begin(client, String(server) + String(uri));
|
||||
|
||||
http.addHeader("Authorization", authorization);
|
||||
|
||||
|
Reference in New Issue
Block a user