New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

examples/imap-append: Set size of data to be uploaded #1011

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
4 participants
@jay
Member

jay commented Sep 14, 2016

Prior to this commit this example failed with error
'Cannot APPEND with unknown input file size'.

Bug: #1008
Reported-by: lukaszgn@users.noreply.github.com

Closes #XXXX

examples/imap-append: Set size of data to be uploaded
Prior to this commit this example failed with error
'Cannot APPEND with unknown input file size'.

Bug: #1008
Reported-by: lukaszgn@users.noreply.github.com

Closes #XXXX
@mention-bot

This comment has been minimized.

Show comment
Hide comment
@mention-bot

mention-bot Sep 14, 2016

@jay, thanks for your PR! By analyzing the annotation information on this pull request, we identified @captain-caveman2k and @bagder to be potential reviewers

mention-bot commented Sep 14, 2016

@jay, thanks for your PR! By analyzing the annotation information on this pull request, we identified @captain-caveman2k and @bagder to be potential reviewers

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Sep 14, 2016

Member

It seems like a fine fix to me, the question is however why it is needed. An upload should stop when a zero is returned from the read callback as that example already does, so while this fix makes the example run fine again it might also just mask a bug...

Member

bagder commented Sep 14, 2016

It seems like a fine fix to me, the question is however why it is needed. An upload should stop when a zero is returned from the read callback as that example already does, so while this fix makes the example run fine again it might also just mask a bug...

@jay

This comment has been minimized.

Show comment
Hide comment
@jay

jay Sep 14, 2016

Member

The problem is I don't think you can do that with IMAP. I assume the example must have worked at some point and I reviewed its history but I don't see the size was ever set. IMAP send extra data seems to be knowing the continuation size and communicating it to the server beforehand, like COMMAND OPTIONS {data-byte-count}. For example right now an APPEND starts like this:
A003 APPEND "[Gmail]/Sent Mail" (\Seen) {381}<CRLF>
Then the server replies
+ any message here<CRLF>
Then upload 381 bytes

More detail from IMAP RFC for APPEND:

APPEND Command

   Arguments:  mailbox name
               OPTIONAL flag parenthesized list
               OPTIONAL date/time string
               message literal

It doesn't define 'message literal' explicitly but earlier says:

   There are two cases in which a line from the client does not
   represent a complete command.  In one case, a command argument is
   quoted with an octet count (see the description of literal in String
   under Data Formats); in the other case, the command arguments require
   server feedback (see the AUTHENTICATE command).  In either case, the
   server sends a command continuation request response if it is ready
   for the octets (if appropriate) and the remainder of the command.
   This response is prefixed with the token "+".

And literal is defined in String as:

   A literal is a sequence of zero or more octets (including CR and
   LF), prefix-quoted with an octet count in the form of an open
   brace ("{"), the number of octets, close brace ("}"), and CRLF.

So I think we have to calculate the size beforehand.

Member

jay commented Sep 14, 2016

The problem is I don't think you can do that with IMAP. I assume the example must have worked at some point and I reviewed its history but I don't see the size was ever set. IMAP send extra data seems to be knowing the continuation size and communicating it to the server beforehand, like COMMAND OPTIONS {data-byte-count}. For example right now an APPEND starts like this:
A003 APPEND "[Gmail]/Sent Mail" (\Seen) {381}<CRLF>
Then the server replies
+ any message here<CRLF>
Then upload 381 bytes

More detail from IMAP RFC for APPEND:

APPEND Command

   Arguments:  mailbox name
               OPTIONAL flag parenthesized list
               OPTIONAL date/time string
               message literal

It doesn't define 'message literal' explicitly but earlier says:

   There are two cases in which a line from the client does not
   represent a complete command.  In one case, a command argument is
   quoted with an octet count (see the description of literal in String
   under Data Formats); in the other case, the command arguments require
   server feedback (see the AUTHENTICATE command).  In either case, the
   server sends a command continuation request response if it is ready
   for the octets (if appropriate) and the remainder of the command.
   This response is prefixed with the token "+".

And literal is defined in String as:

   A literal is a sequence of zero or more octets (including CR and
   LF), prefix-quoted with an octet count in the form of an open
   brace ("{"), the number of octets, close brace ("}"), and CRLF.

So I think we have to calculate the size beforehand.

@bagder

This comment has been minimized.

Show comment
Hide comment
@bagder

bagder Sep 15, 2016

Member

The problem is I don't think you can do that with IMAP

Ah, it has clearly been too long since I was hands-on with IMAP since I have totally forgotten about that detail. Then I'm in agreement with you. That's a necessary change of the example and we should even figure out somewhere where this is best documented...

Member

bagder commented Sep 15, 2016

The problem is I don't think you can do that with IMAP

Ah, it has clearly been too long since I was hands-on with IMAP since I have totally forgotten about that detail. Then I'm in agreement with you. That's a necessary change of the example and we should even figure out somewhere where this is best documented...

@bagder

bagder approved these changes Sep 15, 2016

👍

@jay jay closed this in 45c1c54 Sep 18, 2016

@jay jay deleted the jay:fix_example_imap-append branch Sep 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment