Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion src/_CPlugin_Helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,35 @@ bool client_available(WiFiClient& client) {
bool send_via_http(const String& logIdentifier, WiFiClient& client, const String& postStr, bool must_check_reply) {
bool success = !must_check_reply;
// This will send the request to the server
client.print(postStr);
byte written = client.print(postStr);
// as of 2018/11/01 the print function only returns one byte (upd to 256 chars sent). However if the string sent can be longer than this therefore we calculate modulo 256.
// see discussion here https://github.com/letscontrolit/ESPEasy/pull/1979
// and implementation here https://github.com/esp8266/Arduino/blob/561426c0c77e9d05708f2c4bf2a956d3552a3706/libraries/ESP8266WiFi/src/include/ClientContext.h#L437-L467
// this needs to be adjusted if the WiFiClient.print method changes.
if (written != (postStr.length()%256)) {
if (loglevelActiveFor(LOG_LEVEL_ERROR)) {
String log = F("HTTP : ");
log += logIdentifier;
log += F(" Error: could not write to client (");
log += written;
log += "/";
log += postStr.length();
log += ")";
addLog(LOG_LEVEL_ERROR, log);
}
success = false;
} else {
if (loglevelActiveFor(LOG_LEVEL_DEBUG)) {
String log = F("HTTP : ");
log += logIdentifier;
log += F(" written to client (");
log += written;
log += "/";
log += postStr.length();
log += ")";
addLog(LOG_LEVEL_DEBUG, log);
}
}

if (must_check_reply) {
unsigned long timer = millis() + 200;
Expand Down