0

I’m having some problems at understanding rfc4978.
As I understand it, everything is compressed after the server returnsOKincluding the command names. However it seems I misunderstood several things (because[Gmail]/sfgsisn’t renamed and obviously the file isn’t sent).

 $ cat deflatecommands /dev/stdin | socat - OPENSSL:imap.googlemail.com:993,compress=none
* CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT APPENDLIMIT=35882577 LIST-EXTENDED LIST-STATUS
a001 OK myus.tyer@gmail.com authenticated (Success)
a002 OK Success
2016/04/28 21:47:03 socat[16204.25769803872] E SSL_write(): Broken pipe

where deflatecommands contains :

a001 LOGIN myus.tyer mypassord
a002 COMPRESS DEFLATE
xÚK400VrõsôuUPŠvÏMÌ̉Õ/NK/VBp+@‰— Ô)

which uncompressed gives :

a001 LOGIN myus.tyer mypassord
a002 COMPRESS DEFLATE
a003 RENAME "[Gmail]/sfgs" "[Gmail]/xxxxxxxxxxx"

Of coursedeflatecommandsusescrflline endings in both uncompressed and compressed parts. deflatecommandsis created with :

$ openssl zlib a003 > a003.zlib
$ cat a001 a002 a003.zlib > defaltecommands
Community
  • 1
  • 1
user2284570
  • 2,891
  • 3
  • 26
  • 74
  • A last thing due to the speed of my connection, nothing is sent before`a002 OK Success`if printed on the screen. – user2284570 Apr 28 '16 at 20:33
  • I'm not sure that will work. All three commands will be sent in one packet, but the server will likely flush the input buffer when enabling compression. You will probably need a pause between compress and the compressed command. Also, if there is a CRLF in the compressed part, that will be a problem as well. You'll need to edit the file in binary mode and make sure there is not a cleartext CRLF. – Max Apr 29 '16 at 15:10
  • @Max : There’s no uncompressed ᴄʀʟꜰ in`a003.zlib`. And again, not any compressed bytes are send before GImap returned`OK Success`. – user2284570 Apr 29 '16 at 21:01
  • If you're just catting them in, they are going out before any responses are received. Otherwise update your question with what you're doing :) – Max Apr 30 '16 at 00:41
  • @Max : Ok, I now use a one liner script do delay between cat commands *(while steel piping)*. But it would add too much confusion to my question *(and for course in reality I want to send lot of data that require compression which means not just a rename command)*. The point is still the server close the connection as soon as it receive the first bytes compressed with`openssl zlib`. – user2284570 Apr 30 '16 at 16:12

1 Answers1

0

Why do you need to talk IMAP from shell? While I applaud your choice of heavy pipelining which IMAP indeed supports, there's a limit to the allowed pipelineable commands. LOGIN is safe, in theory, but I would not personally enqueue anything right after it without waiting for its result (and this is the moment where your naive shell pipe will hit its limits). COMPRESS DEFLATE is not safe to pipeline by any means because the server has to switch on transparent compression. In many languages, this usually involves a flush of the network buffer(s) on various layers.

Why are you complicating the whole matter with activation of the COMPRESS extension? It is by no means necessary, and it won't really save you any measurable amount of bytes in this particular scenario.

Jan Kundrát
  • 3,700
  • 1
  • 18
  • 29
  • `It is by no means necessary, and it won't really save you any measurable amount of bytes in this particular scenario.` **It’s wrong !** I’m planning sending something Gb large but that give 50Mb once deflate compressed. It is too large to be done though a traditional e‑mail client and would take too much time on 243Kb/s *(upload speed)* internet connection if uncompressed. Please don’t assume I’m trying to solve the wrong problem . http://stackoverflow.com/q/14959461/2284570 *(and in fact I now use a small shell script for waiting sever responses before continuing)*. – user2284570 Apr 30 '16 at 15:11
  • Good luck trying to save something "GB large" into GMail. Anyway, you chose to use shell scripting, well, you'll have to deal with the induced pain. – Jan Kundrát May 12 '16 at 22:08