curl-library
Re: truncated files retrieved via FTP in ASCII mode
Date: Mon, 18 Jan 2010 13:10:19 -0700
I've attached my change to ftp.c along with new test129 (which is based on
test106 and didn't need an FTP server update after all).
Thank you,
-David
On Thu, Jan 14, 2010 at 3:28 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:
> On Wed, 13 Jan 2010, David McCreedy wrote:
>
> The FTP server is returning the wrong SIZE for the file because it doesn't
>> take the mode into account. (I think this is a common FTP server bug.)
>>
>
> Yeah, I think it is so common that FTP server authors probably don't even
> consider it to be a bug.
>
>
> I can kludge the ftp_state_get_resp function in ftp.c to get back to the
>> old behavior:
>>
>
> + if((instate != FTP_LIST) && (data->set.prefer_ascii))
>>
>> + size = -1; /* kludge for servers that misstate file size in ASCII
>> mode */
>>
>
> ...
>
>
> But there must be a better way to deal with this...
>>
>
> libcurl has a very long-standing TODO about not properly supporting FTP
> ASCII mode transfers (http://curl.haxx.se/docs/todo.html#ASCII_support)
> and this is related to that.
>
> I can only think of one better way to deal with this issue, and that is to
> somehow count the number of CRLF occurances in the data and increase the
> amount of expected downloaded bytes by that number. But that's kind of an
> after-the-fact approach that doesn't quite help since we must first download
> the proper amount of data before we can check for contents and count
> patterns etc...
>
> I think we should work on getting a test case like this added to the test
> suite so that we can fix this in a way that won't get broken again in 6
> months. Unfortunately I think it requires a modification of the test FTP
> server.
>
> --
>
> / daniel.haxx.se
> -------------------------------------------------------------------
> List admin: http://cool.haxx.se/list/listinfo/curl-library
> Etiquette: http://curl.haxx.se/mail/etiquette.html
>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
- application/octet-stream attachment: patch-size.20100118.diff