Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Header correction in execOTA function #20

Closed
sujeendran opened this issue Feb 6, 2020 · 6 comments · Fixed by #35
Closed

Header correction in execOTA function #20

sujeendran opened this issue Feb 6, 2020 · 6 comments · Fixed by #35
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@sujeendran
Copy link

Hi, execOTA() function I noticed a typo that causes error when downloading the binary file.
The part reading the headers is checking if the line starts with "Content-Type: " where it should be "Content-type: ". Making this change fixed my program.

if (line.startsWith("Content-type: "))
            {
                String contentType = getHeaderValue(line, "Content-type: ");
                Serial.println("Got " + contentType + " payload.");
                if (contentType == "application/octet-stream")
                {
                    isValidContentType = true;
                }
            }
@chrisjoyce911
Copy link
Owner

I have made the change could you please test
https://github.com/chrisjoyce911/esp32FOTA/tree/issue20

@chrisjoyce911 chrisjoyce911 added bug Something isn't working good first issue Good for newcomers labels Feb 6, 2020
@chrisjoyce911 chrisjoyce911 self-assigned this Feb 6, 2020
@sujeendran
Copy link
Author

Tested. Works! Great quick fix!

@DoubleChuang
Copy link
Contributor

DoubleChuang commented Feb 6, 2020

According to rfc2616
message-header = field-name ":" [ field-value ]

Field_ names are case-insensitive.

I would suggest using StringObject Function: equalsignorecase

@Dharmik-Bhavani
Copy link

Dharmik-Bhavani commented Apr 13, 2020

Hi, execOTA() function I noticed a typo that causes error when downloading the binary file.
The part reading the headers is checking if the line starts with "Content-Type: " where it should be "Content-type: ". Making this change fixed my program.

if (line.startsWith("Content-type: "))
            {
                String contentType = getHeaderValue(line, "Content-type: ");
                Serial.println("Got " + contentType + " payload.");
                if (contentType == "application/octet-stream")
                {
                    isValidContentType = true;
                }
            }

I had an simmilar error but mine was fixed with having "Content-Type: " insted of "Content-type: ".
Not able to figure this out why it works sometimes with "Content-Type: " and sometimes with "Content-type: ".

So I made little change in the condition on line 94 in esp32fota.cpp file to
if (line.startsWith("Content-type: ") || line.startsWith("Content-Type: "))

instead of
if (line.startsWith("Content-type: "))

@IoTThinks
Copy link
Contributor

I also have the same issue.
Need to change to line.startsWith("Content-Type: ")
Or it is more reliable to compare ignoring the case.

@szundi
Copy link
Collaborator

szundi commented Jul 8, 2020

@Dharmik-Bhavani can you please submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants