Skip to content

Commit f9c3b22

Browse files
committed
updated to work with Apache 2.4 (getallheaders() returns keys in pascal case now, using change case to lower to work with all versions)
1 parent 1297133 commit f9c3b22

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

doc/ota_updates/readme.rst

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -614,30 +614,30 @@ With this information the script now can check if an update is needed. It is als
614614
}
615615
616616
617-
$headers = getallheaders();
617+
$headers = array_change_key_case(getallheaders(), CASE_LOWER);
618618
619619
header('Content-type: text/plain; charset=utf8', true);
620620
621-
//if (!check_header('HTTP_USER_AGENT', 'ESP8266-http-Update')) {
622-
if (!check_header('User-Agent', 'ESP8266-http-Update')) {
621+
if (!check_header('user-agent', 'ESP8266-http-Update')) {
623622
header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);
624623
echo "Only for ESP8266 updater!\n";
625-
echo "User-Agent: ".$headers['User-Agent']." != ESP8266-http-Update\n";
624+
echo "User-Agent: ".$headers['user-agent']." != ESP8266-http-Update\n";
626625
exit();
627626
}
628627
629628
if (
630-
!check_header('x-ESP8266-mode') ||
631-
!check_header('x-ESP8266-STA-MAC') ||
632-
!check_header('x-ESP8266-AP-MAC') ||
633-
!check_header('x-ESP8266-free-space') ||
634-
!check_header('x-ESP8266-sketch-size') ||
635-
!check_header('x-ESP8266-sketch-md5') ||
636-
!check_header('x-ESP8266-chip-size') ||
637-
!check_header('x-ESP8266-sdk-version')
629+
!check_header('x-esp8266-mode') ||
630+
!check_header('x-esp8266-sta-mac') ||
631+
!check_header('x-esp8266-ap-mac') ||
632+
!check_header('x-esp8266-free-space') ||
633+
!check_header('x-esp8266-sketch-size') ||
634+
!check_header('x-esp8266-sketch-md5') ||
635+
!check_header('x-esp8266-chip-size') ||
636+
!check_header('x-esp8266-sdk-version')
638637
) {
639638
header($_SERVER["SERVER_PROTOCOL"].' 403 Forbidden', true, 403);
640639
echo "Only for ESP8266 updater! (header missing)\n";
640+
print_r($headers);
641641
exit();
642642
}
643643
@@ -646,8 +646,8 @@ With this information the script now can check if an update is needed. It is als
646646
"18:FE:AA:AA:AA:BB": {"file": "TEMP-1.0.0".bin", "version": 1}}';
647647
// $db_string = file_get_contents("arduino-db.json");
648648
$db = json_decode($db_string, true);
649-
$mode = $headers['x-ESP8266-mode'];
650-
$mac = $headers['x-ESP8266-STA-MAC'];
649+
$mode = $headers['x-esp8266-mode'];
650+
$mac = $headers['x-esp8266-sta-mac'];
651651
652652
if (!isset($db[$mac])) {
653653
header($_SERVER["SERVER_PROTOCOL"].' 404 ESP MAC not configured for updates', true, 404);
@@ -668,8 +668,8 @@ With this information the script now can check if an update is needed. It is als
668668
// Check if version has been set and does not match, if not, check if
669669
// MD5 hash between local binary and ESP8266 binary do not match if not.
670670
// then no update has been found.
671-
if ((check_header('x-ESP8266-version') && $headers['x-ESP8266-version'] != $localVersion)) {
672-
// || $headers["x-ESP8266-sketch-md5"] != md5_file($localBinary)) {
671+
if ((check_header('x-esp8266-version') && $headers['x-esp8266-version'] != $localVersion)) {
672+
// || $headers["x-esp8266-sketch-md5"] != md5_file($localBinary)) {
673673
sendFile($localBinary, $localVersion);
674674
} else {
675675
header($_SERVER["SERVER_PROTOCOL"].' 304 Not Modified', true, 304);

0 commit comments

Comments
 (0)