cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_RESUME_FROM problem (fwd)

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Wed, 28 Nov 2007 16:21:15 +0100 (CET)

(Forwared message with permission - because for some reason Norbert's mails
don't come through to the list!)

---------- Forwarded message ----------
Date: Wed, 28 Nov 2007 13:08:58 +0100
From: nf2 <nf2_at_scheinwelt.at>
Subject: CURLOPT_RESUME_FROM problem

trying to restart an ftp upload with CURLOPT_RESUME_FROM in curlftpfs i
get a weird "Could only read 4096 bytes from the input" error:

* Connecting to 192.168.5.2 (192.168.5.2) port 46604
* FTP 0x80e6cf0 state change from PASV to STOP
* DO phase is complete
* DO-MORE phase starts
> TYPE I
* FTP 0x80e6cf0 state change from STOP to STOR_TYPE
< 200 Type set to I
1195783943 ftpfs.c:427 write_data_bg: data_avail eof=0
1195783943 ftpfs.c:432 write_data_bg: 16384 4096
1195783943 ftpfs.c:448 write_data_bg: data_need
* Could only read 4096 bytes from the input
* DO-MORE phase ends with 31
* Closing connection #0
1195783943 ftpfs.c:491 write problem: 31(FTP: command REST failed)
text=Could only read 4096 bytes from the input

i don't understand why in the function ftp_state_ul_setup() libcurl
expects that fread_func returns exactly "readthisamountnow" (16384) bytes.

-----------------------------------------------
      actuallyread = (curl_off_t)
        conn->fread_func(data->state.buffer, 1, (size_t)readthisamountnow,
                    conn->fread_in);

      passed += actuallyread;
      if(actuallyread != readthisamountnow) {
        failf(data, "Could only read %" FORMAT_OFF_T
              " bytes from the input", passed);
        return CURLE_FTP_COULDNT_USE_REST;
      }
-----------------------------------------------

i guess CURLOPT_RESUME_FROM wants me to resend the entire content of the
file again in one go. unfortunately in curlftpfs i lost this data,
because i don't cache it. i just want to REST/STOR from the end of the
existing file.

what i would need is a CURLOPT_RANGE for uploads, but i think
CURLOPT_RANGE is ignored here. i could use CURLOPT_APPEND, but i think
REST/STOR would be safer, because it probably checks the size of the
existing file on the server side...

regards,
norbert
Received on 2007-11-28