[Gambas-user] Support for IMAP in gb.net.curl
Tony Morehen
tmorehen at ...3602...
Sun Sep 24 04:07:22 CEST 2017
I came across an interesting issue when working on Imap's Fetch
command. Fetch is used to down load messages. The response to a Fetch
has 4 parts:
1) a single line providing the size of the download, say, 69000 bytes.
2) the mime-encoded download (a string 69000 bytes long)
3) one line whose only contents is ")"
4) one line status line.
So my code does:
Readline
response = Read #stream, iSize 'iSize=69000
Readline
Readline
Using a TCP socket, the Read # line has no error but the download is
incomplete, say only 50000 bytes. The remaining 19000 byes is read by
the next Readline. However, the response variable is the correct 69000
bytes in length, with the last 19000 bytes zero-filled. Its like the
Read # timed out but the timeout is set to 10000 and 10 seconds had not
elapsed. Socket.blocking was set to True.
Using an openssl process, the Read # line raises an error: Error 9, Bad
file descriptor.
I have a workaround: Read # is replaced with
Dim result as new String[]
Bytesread=0
Do While BytesRead < iSize
Response = Read #$hStream, IIf(iSize - BytesRead > 4096, 4096,
iSize - BytesRead)
result.Add(Response)
bytesread += 4096
Loop
Response = result.Join("")
Now both TCP and openssl work, no zero-fill no errors.
Any ideas? Other fixes?
On 2017-09-23 09:09 PM, Tony Morehen wrote:
> Just a quick update on an Imap class. The following methods have been
> implemented and, for the most part, tested:
>
> Abort, AddMessageFlags, Authed, BuildSequenceSet, Capabilities,
> CleanUpMailBoxList, Connect, CopyMessage, CopyMessages, CreateMailbox,
> Debug,
> DeleteMailbox, DeleteMessage, DeleteMessages, Encrypt, Exec, Expunge,
> FindValue, GetMessage, GetMessageFlags, Host, LSub, List, ListMailboxes,
> ListSubscribedMailboxes, Logout, MailboxInfo, MailboxStatus,
> MoveMessage, MoveMessages, Noop, Password, Port, RemoveMessageFlags,
> RenameMailbox, Search, SelectMailbox, SetMessageFlags, User, Welcome
>
> The testing has been done on a static email account. As a result,
> copy, move and delete messages have not been properly tested. I'll
> follow up on that in another message.
>
>
>
>
> ------------------------------------------------------------------------------
>
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
More information about the User
mailing list