8000 Merge branch 'master' into pr-umm_malloc-misc-fix · esp8266/Arduino@63a0c25 · GitHub
[go: up one dir, main page]

Skip to content

Commit 63a0c25

Browse files
Merge branch 'master' into pr-umm_malloc-misc-fix
2 parents 154237e + 7298691 commit 63a0c25

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

libraries/ESP8266WebServer/src/ESP8266WebServer-impl.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
Modified 8 May 2015 by Hristo Gochkov (proper post and file upload handling)
2121
*/
2222

23-
2423
#include <Arduino.h>
2524
#include <libb64/cencode.h>
2625
#include "WiFiServer.h"
@@ -61,6 +60,7 @@ ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(IPAddress addr, i
6160
, _currentHeaders(nullptr)
6261
, _contentLength(0)
6362
, _chunked(false)
63+
, _corsEnabled(false)
6464
{
6565
}
6666

@@ -82,6 +82,7 @@ ESP8266WebServerTemplate<ServerType>::ESP8266WebServerTemplate(int port)
8282
, _currentHeaders(nullptr)
8383
, _contentLength(0)
8484
, _chunked(false)
85+
, _corsEnabled(false)
8586
{
8687
}
8788

@@ -98,6 +99,10 @@ ESP8266WebServerTemplate<ServerType>::~ESP8266WebServerTemplate() {
9899
}
99100
}
8000 100101

102+
template <typename ServerType>
103+
void ESP8266WebServerTemplate<ServerType>::enableCORS(bool enable) {
104+
_corsEnabled = enable;
105+
}
101106
template <typename ServerType>
102107
void ESP8266WebServerTemplate<ServerType>::begin() {
103108
close();
@@ -421,6 +426,9 @@ void ESP8266WebServerTemplate<ServerType>::_prepareHeader(String& response, int
421426
sendHeader(String(F("Accept-Ranges")),String(F("none")));
422427
sendHeader(String(F("Transfer-Encoding")),String(F("chunked")));
423428
}
429+
if (_corsEnabled) {
430+
sendHeader(String(F("Access-Control-Allow-Origin")), String("*"));
431+
}
424432
sendHeader(String(F("Connection")), String(F("close")));
425433

426434
response += _responseHeaders;

libraries/ESP8266WebServer/src/ESP8266WebServer.h

Lines changed: 4 additions & 0 deletions
8000
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ class ESP8266WebServerTemplate
9999
void serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_header = NULL );
100100
void onNotFound(THandlerFunction fn); //called when handler is not assigned
101101
void onFileUpload(THandlerFunction fn); //handle file uploads
102+
void enableCORS(bool enable);
102103

103104
const String& uri() const { return _currentUri; }
104105
HTTPMethod method() const { return _currentMethod; }
@@ -244,11 +245,14 @@ class ESP8266WebServerTemplate
244245

245246
String _hostHeader;
246247
bool _chunked;
248+
bool _corsEnabled;
247249

248250
String _snonce; // Store noance and opaque for future comparison
249251
String _sopaque;
250252
String _srealm; // Store the Auth realm between Calls
251253

254+
255+
252256
};
253257

254258

libraries/ESP8266WiFi/examples/BearSSL_Validation/BearSSL_Validation.ino

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,13 @@ void fetchFingerprint() {
110110
Serial.printf(R"EOF(
111111
The SHA-1 fingerprint of an X.509 certificate can be used to validate it
112112
instead of the while certificate. This is not nearly as secure as real
113-
X.509 validation, but is better than nothing.
113+
X.509 validation, but is better than nothing. Also be aware that these
114+
fingerprints will change if anything changes in the certificate chain
115+
(i.e. re-generating the certificate for a new end date, any updates to
116+
the root authorities, etc.).
114117
)EOF");
115118
BearSSL::WiFiClientSecure client;
116-
static const char fp[] PROGMEM = "5F:F1:60:31:09:04:3E:F2:90:D2:B0:8A:50:38:04:E8:37:9F:BC:76";
119+
static const char fp[] PROGMEM = "59:74:61:88:13:CA:12:34:15:4D:11:0A:C1:7F:E6:67:07:69:42:F5";
117120
client.setFingerprint(fp);
118121
fetchURL(&client, host, port, path);
119122
}

0 commit comments

Comments
 (0)
0