Closed
Description
Description:
Shouldn't WiFiClientSecure::write
send the whole buffer even beyond SSL fragment length? Currently it only writes up to mbedTLS maximum fragment length which is 16KB by default.
According to ARM mbed TLS mbedtls_ssl_write
has the following limitation
If the requested length is greater than the maximum fragment length (either the built-in limit or the one set or negotiated with the peer), then:
- with TLS, less bytes than requested are written.
It appears that mbedtls_ssl_write
is only called once at https://github.com/espressif/arduino-esp32/blob/master/libraries/WiFiClientSecure/src/ssl_client.cpp#L280
Sketch
While the (simplified) workaround below works ok it does feel like such a use case should be handled by WiFiClientSecure
internally. Opinions?
size_t sent = 0;
size_t remaining = fileSize;
size_t offset = 0;
while (true) {
sent = client->write(buffer + offset, remaining);
remaining = remaining - sent;
offset += sent;
if (remaining <= 0 || sent <= 0) {
break;
}
}