Skip to content
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 from

Conversation

jay
Copy link
Member

@jay 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

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

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

Closes #XXXX
@mention-bot
Copy link

@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
Copy link
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
Copy link
Member Author

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
Copy link
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...

Copy link
Member

@bagder bagder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@jay jay closed this in 45c1c54 Sep 18, 2016
@jay jay deleted the fix_example_imap-append branch September 19, 2016 20:05
@lock lock bot locked as resolved and limited conversation to collaborators Jan 19, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

Successfully merging this pull request may close these issues.

None yet

4 participants