cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Issue with partial file transfer

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Fri, 20 Apr 2012 14:30:35 +0200 (CEST)

On Fri, 20 Apr 2012, Grzegorz Sikorski wrote:

>> It is not OK since it changes behavior for existing application in a very
>> drastic way.
>
> I do not agree. If libcurl always assume the file is sought back to the
> start, it is no change anyway.

That's not a correct interpretation.

libcurl assumes that the application provides the stream from exactly the
point where it should be. It can be from the start or it can be from the
middle, it is all fine for libcurl. What is the correct place is only known by
the application.

> The only thing it might brake is situation, when user tries to put on the
> server part of the file and seeks the pointer to the middle before transfer.
> This is rather strange request and I am not sure if it really could success
> anyway.

I disagree with that definition of how libcurl works and what its role is.

libcurl does not upload specific files from specific seek points. It uploads
what the application tells it to upload and it obeys what is getting passed to
it.

> In my opinion libcurl really need to seek back. Its transfer caused the file
> seek and only libcurl may know if the file really needs to be sought back.

Not at all. Your application knows from which point it wants the upload to
happen from. The application then makes sure that the file position is at the
correct place at the beginning of a transfer. That is mandatory for all
transfers.

Sure, this may not be crystal clear in the documentation but then we should
work on improve that!

> Application does not know what is the status of the file on the server side,
> and libcurl knows that from SIZE response. But this is only my opinion.

The situation on the server-side might cause libcurl to seek _forward_, yes in
an upload resume scenario, to skip the initial part of the file that was
already uploaded. Or it can just read the first part and through that away to
the point where it should start uploading data. To the application there's no
difference then if it resumes or start from the beginning.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-04-20