Merge pull request #737 from FlorianLudwig/master
treat http headers case insensitive in OTA
This commit is contained in:
commit
14af4b2d09
14
src/ota.cpp
14
src/ota.cpp
@ -189,6 +189,8 @@ int do_ota_update() {
|
|||||||
|
|
||||||
while (client.available()) {
|
while (client.available()) {
|
||||||
String line = client.readStringUntil('\n');
|
String line = client.readStringUntil('\n');
|
||||||
|
String lineLowerCase = line;
|
||||||
|
lineLowerCase.toLowerCase();
|
||||||
// Check if the line is end of headers by removing space symbol
|
// Check if the line is end of headers by removing space symbol
|
||||||
line.trim();
|
line.trim();
|
||||||
// if the the line is empty, this is the end of the headers
|
// if the the line is empty, this is the end of the headers
|
||||||
@ -213,8 +215,8 @@ int do_ota_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Extracting new redirect location
|
// Extracting new redirect location
|
||||||
if (line.startsWith("Location: ")) {
|
if (lineLowerCase.startsWith("location: ")) {
|
||||||
String newUrl = getHeaderValue(line, "Location: ");
|
String newUrl = getHeaderValue(line, "location: ");
|
||||||
ESP_LOGI(TAG, "Got new url: %s", newUrl.c_str());
|
ESP_LOGI(TAG, "Got new url: %s", newUrl.c_str());
|
||||||
newUrl.remove(0, newUrl.indexOf("//") + 2);
|
newUrl.remove(0, newUrl.indexOf("//") + 2);
|
||||||
currentHost = newUrl.substring(0, newUrl.indexOf('/'));
|
currentHost = newUrl.substring(0, newUrl.indexOf('/'));
|
||||||
@ -224,14 +226,14 @@ int do_ota_update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Checking headers
|
// Checking headers
|
||||||
if (line.startsWith("Content-Length: ")) {
|
if (lineLowerCase.startsWith("content-length: ")) {
|
||||||
contentLength =
|
contentLength =
|
||||||
atoi((getHeaderValue(line, "Content-Length: ")).c_str());
|
atoi((getHeaderValue(line, "content-length: ")).c_str());
|
||||||
ESP_LOGI(TAG, "Got %d bytes from server", contentLength);
|
ESP_LOGI(TAG, "Got %d bytes from server", contentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line.startsWith("Content-Type: ")) {
|
if (lineLowerCase.startsWith("content-type: ")) {
|
||||||
String contentType = getHeaderValue(line, "Content-Type: ");
|
String contentType = getHeaderValue(line, "content-type: ");
|
||||||
ESP_LOGI(TAG, "Got %s payload", contentType.c_str());
|
ESP_LOGI(TAG, "Got %s payload", contentType.c_str());
|
||||||
if (contentType == "application/octet-stream") {
|
if (contentType == "application/octet-stream") {
|
||||||
isValidContentType = true;
|
isValidContentType = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user