summaryrefslogtreecommitdiffstats
path: root/imap
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2019-11-11 08:34:49 +0100
committerKevin McCarthy <kevin@8t8.us>2019-11-30 13:59:51 -0800
commit136ae0add512f21bc418f9e31a2f1b970ad1a490 (patch)
tree82797901e6688047b77fb05a6d4865db2e260cbb /imap
parent1dd65e6beb0f1d211d63f936d92aecc792d2f72b (diff)
imap: add support for COMPRESS=DEFLATE, RFC 4978
- added mutt_zstrm which allows wrapping an existing connection with deflate/inflate (zlib compression) - call mutt_zstrm_wrap_conn when setting up an IMAP connection if the server supports COMPRESSION=DEFLATE and imap_deflate evaluates to yes - add config quad-option imap_deflate enable/disable use of (de)compression for IMAP connections, defaulting to yes - add configure check for zlib, --with-zlib to detect if mutt_zstrm can (or should) be built Tested against a Dovecot IMAP server, observed easily 7x compression rates on received data, and 5x on sent data for a normal session. Rates can be observed when the connection is closed on debug level 4 and higher. Bug: https://gitlab.com/muttmua/mutt/issues/92
Diffstat (limited to 'imap')
-rw-r--r--imap/command.c1
-rw-r--r--imap/imap.c14
-rw-r--r--imap/imap_private.h1
3 files changed, 16 insertions, 0 deletions
diff --git a/imap/command.c b/imap/command.c
index 69ac0b02..cb3f9c0c 100644
--- a/imap/command.c
+++ b/imap/command.c
@@ -74,6 +74,7 @@ static const char * const Capabilities[] = {
"CONDSTORE",
"QRESYNC",
"LIST-EXTENDED",
+ "COMPRESS=DEFLATE",
NULL
};
diff --git a/imap/imap.c b/imap/imap.c
index 4bbe65c7..8e8684f8 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -34,6 +34,9 @@
#if defined(USE_SSL)
# include "mutt_ssl.h"
#endif
+#if defined(USE_ZLIB)
+# include "mutt_zstrm.h"
+#endif
#include "buffy.h"
#if USE_HCACHE
#include "hcache.h"
@@ -426,6 +429,17 @@ IMAP_DATA* imap_conn_find (const ACCOUNT* account, int flags)
/* capabilities may have changed */
imap_exec (idata, "CAPABILITY", IMAP_CMD_QUEUE);
+#if defined(USE_ZLIB)
+ /* RFC 4978 */
+ if (mutt_bit_isset (idata->capabilities, COMPRESS_DEFLATE))
+ {
+ if (query_quadoption (OPT_IMAPDEFLATE,
+ _("Use deflate compression on connection?")) == MUTT_YES &&
+ imap_exec (idata, "COMPRESS DEFLATE", IMAP_CMD_FAIL_OK) != -2)
+ mutt_zstrm_wrap_conn (idata->conn);
+ }
+#endif
+
/* enable RFC6855, if the server supports that */
if (mutt_bit_isset (idata->capabilities, ENABLE))
imap_exec (idata, "ENABLE UTF8=ACCEPT", IMAP_CMD_QUEUE);
diff --git a/imap/imap_private.h b/imap/imap_private.h
index 88af5a48..3d1d9993 100644
--- a/imap/imap_private.h
+++ b/imap/imap_private.h
@@ -121,6 +121,7 @@ enum
CONDSTORE, /* RFC 7162 */
QRESYNC, /* RFC 7162 */
LIST_EXTENDED, /* RFC 5258: IMAP4 - LIST Command Extensions */
+ COMPRESS_DEFLATE, /* RFC 4978: COMPRESS=DEFLATE */
CAPMAX
};