You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I am trying to optimize my code running on an ESP8266, which uploads the measurements of a BME280.
A ineffective section, I think, is the calculation of "Content-Length", so I want to change it.
Hi,
I am trying to optimize my code running on an ESP8266, which uploads the measurements of a BME280.
A ineffective section, I think, is the calculation of "Content-Length", so I want to change it.
client.print(F("POST /boxes/"));
printHexToStream(SENSEBOX_ID, 12, client);
client.println(F("/data HTTP/1.1"));
// print once to Serial to get the content-length
int contentLen = printCsvToStream(Serial);
// Send the required header parameters
client.print(F("Host: "));
client.println(server);
client.println(F("Content-Type: text/csv\nConnection: close"));
client.print(F("Content-Length: "));
client.println(contentLen);
client.println();
printCsvToStream(client);
client.println();
client.flush();
client.stop();`
Expected Behavior
I tried leaving the "Content-Length" header out with the manual POST-request tool Postman and it worked!
Actual Behavior
But using the ESP the measurements don´t update.
What is my mistake?
Is it not possible to leave the length out? How can I optimize this instead?
The text was updated successfully, but these errors were encountered: