mirror of
https://github.com/cesanta/mongoose.git
synced 2025-08-01 02:16:14 +08:00
23 lines
928 B
Diff
23 lines
928 B
Diff
diff --git a/mongoose.c b/mongoose.c
|
|
index 44539e81..b3f1c83a 100644
|
|
--- a/mongoose.c
|
|
+++ b/mongoose.c
|
|
@@ -11300,9 +11300,16 @@ void mg_tls_free(struct mg_connection *c) {
|
|
long mg_tls_send(struct mg_connection *c, const void *buf, size_t len) {
|
|
struct tls_data *tls = (struct tls_data *) c->tls;
|
|
long n = MG_IO_WAIT;
|
|
+ size_t maxsize = 256, encrypted = 0;
|
|
if (len > MG_IO_SIZE) len = MG_IO_SIZE;
|
|
if (len > 16384) len = 16384;
|
|
- mg_tls_encrypt(c, (const uint8_t *) buf, len, MG_TLS_APP_DATA);
|
|
+ while (encrypted < len) {
|
|
+ const uint8_t *chunk = (const uint8_t *) buf + encrypted;
|
|
+ size_t chunksize = len - encrypted;
|
|
+ if (chunksize > maxsize) chunksize = maxsize;
|
|
+ mg_tls_encrypt(c, chunk, chunksize, MG_TLS_APP_DATA);
|
|
+ encrypted += chunksize;
|
|
+ }
|
|
while (tls->send.len > 0 &&
|
|
(n = mg_io_send(c, tls->send.buf, tls->send.len)) > 0) {
|
|
mg_iobuf_del(&tls->send, 0, (size_t) n);
|