[Gambas-user] Support for IMAP in gb.net.curl
Benoît Minisini
gambas at ...1...
Wed Sep 27 02:59:24 CEST 2017
Hi, Tony.
I have just pushed the 'rework-stream-interface' branch to the gitlab
repository.
I have reworked the internal interpreter stream interface, so that
incomplete reads are retried automatically until all the data is read or
an error occurs, whatever the underlying stream.
Can you try it and tell me if it fixes the incomplete read on TCP sockets?
Regards,
Le 24/09/2017 à 04:07, Tony Morehen a écrit :
> 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?
>
--
Benoît Minisini
More information about the User
mailing list