Skip to content

Commit 058a5c8

Browse files
committed
Merge pull request #672 from timw1971/patch-1
Improvements to ESP8266WebServer::sendContent
2 parents cf69ea0 + 72ffb52 commit 058a5c8

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

hardware/esp8266com/esp8266/libraries/ESP8266WebServer/src/ESP8266WebServer.cpp

+7-6
Original file line numberDiff line numberDiff line change
@@ -178,17 +178,18 @@ void ESP8266WebServer::send(int code, const String& content_type, const String&
178178
}
179179

180180
void ESP8266WebServer::sendContent(const String& content) {
181+
const size_t unit_size = HTTP_DOWNLOAD_UNIT_SIZE;
181182
size_t size_to_send = content.length();
182-
size_t size_sent = 0;
183-
while(size_to_send) {
184-
const size_t unit_size = HTTP_DOWNLOAD_UNIT_SIZE;
183+
const char* send_start = content.c_str();
184+
185+
while (size_to_send) {
185186
size_t will_send = (size_to_send < unit_size) ? size_to_send : unit_size;
186-
size_t sent = _currentClient.write(content.c_str() + size_sent, will_send);
187-
size_to_send -= sent;
188-
size_sent += sent;
187+
size_t sent = _currentClient.write(send_start, will_send);
189188
if (sent == 0) {
190189
break;
191190
}
191+
size_to_send -= sent;
192+
send_start += sent;
192193
}
193194
}
194195

0 commit comments

Comments
 (0)