cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curlpp mailing list Archives

Re: [cURLpp] Seek and read file download

From: Michael Linck <mgl_at_absolute-performance.com>
Date: Tue, 13 May 2008 09:34:28 -0600

Whoops, the first one was wrong. I quoted the call to my wrapper
template instead of the curl function call itself. The actual curl call
looks like this:

curl_easy_setopt(aCurlEasy, CURLOPT_HTTPHEADER,
aHTTPFormattedHeaderCurlSList);

You have to do some curl-fu to get httpheaders to work since curl's a C
interface so you have to keep a pointer but let curl manage it via calls
to add headers and clean up headers. Very annoying. If you need more
detail on that, I'd recommend moving the discussion to the curl mailing
list. Someone there will be able to help you. If you're using the
curlpp style, you don't have to worry about any of that. Just keep your
own std::list<std::string> and hand it to setOpt.

mike

Mark Chandler wrote:
> Thanks for the code, ill give it a try tonight.
>
> Mark
>
> -----Original Message-----
> From: curlpp-bounces_at_rrette.com [mailto:curlpp-bounces_at_rrette.com] On Behalf
> Of Michael Linck
> Sent: Tuesday, May 13, 2008 5:21 AM
> To: cURLpp's mailing-list
> Subject: Re: [cURLpp] Seek and read file download
>
> Mark Chandler wrote:
>
>> Yep, and looking at the code I have no idea where to start.
>>
>>
>>
>>
>
> in curl:
> ...
> setCurlOption(CURLOPT_HTTPHEADER, tHTTPFormattedHeaderCurlsist);
> ...
>
> in curlpp:
> YourCurlPPEasy.setOpt(curlpp::options::HttpHeader,
> listOfHTTPFormattedHeaders);
>
>
> you can find the relefant interface in the headers in the curlpp
> directory. It's fairly straightforward. You should also try to
> familiarize yourself with how curl works, since HTTP really can't be
> simplified into a simple get- and set-, so you have to think of it as a
> configurable sessions (curl handles) instead.
>
> mike
>
>> -----Original Message-----
>> From: curlpp-bounces_at_rrette.com [mailto:curlpp-bounces_at_rrette.com] On
>>
> Behalf
>
>> Of Michael Linck
>> Sent: Monday, May 12, 2008 11:54 PM
>> To: cURLpp's mailing-list
>> Subject: Re: [cURLpp] Seek and read file download
>>
>> Can't you just tell curl to provide that header? Interpreting the
>> header and returning the appropriate chunk of file, would seem to be
>> handled by the server, given the interface you describe.
>>
>> mike
>>
>> Mark Chandler wrote:
>>
>>
>>> That's only for file upload.
>>>
>>> I have managed to do it directly with another library (by providing the
>>> header "Range: bytes=x-y") but I have to buy that library.
>>>
>>> Would like to see this in libcur but source code is new for me to add
>>> something like this.
>>>
>>> Mark
>>>
>>> -----Original Message-----
>>> From: curlpp-bounces_at_rrette.com [mailto:curlpp-bounces_at_rrette.com] On
>>>
>>>
>> Behalf
>>
>>
>>> Of Jean-Philippe Barrette-LaPierre
>>> Sent: Monday, May 12, 2008 8:44 PM
>>> To: cURLpp's mailing-list
>>> Subject: Re: [cURLpp] Seek and read file download
>>>
>>> On Monday 12 May 2008 1:23 am, Mark Chandler wrote:
>>>
>>>
>>>
>>>> Well im in need of a http library which will allow me to part download
>>>> files. Now is there any easy way to use libcur to do this. I would like
>>>>
>>>>
>> to
>>
>>
>>>> be able to use it like fseek and fread for files.
>>>>
>>>>
>>>>
>>>>
>>> libcURL has those following options:
>>>
>>> CURLOPT_SEEKFUNCTION
>>>
>>> Function pointer that should match the following prototype: int
>>> function(void
>>> *instream, curl_off_t offset, int origin); This function gets called by
>>> libcurl to seek to a certain position in the input stream and can be used
>>>
>>>
>> to
>>
>>
>>> fast forward a file in a resumed upload (instead of reading all uploaded
>>> bytes with the normal read function/callback). It is also called to
>>>
> rewind
>
>>>
>>>
>> a
>>
>>
>>> stream when doing a HTTP PUT or POST with a multi-pass authentication
>>> method.
>>> The function shall work like "fseek" or "lseek" and accepted SEEK_SET,
>>> SEEK_CUR and SEEK_END as argument for origin, although (in 7.18.0)
>>>
> libcurl
>
>>>
>>>
>>
>>
>>> only passes SEEK_SET. The callback must return 0 on success as returning
>>> non-zero will cause the upload operation to fail.
>>>
>>> If you forward the input arguments directly to "fseek" or "lseek", note
>>>
>>>
>> that
>>
>>
>>> the data type for offset is not the same as defined for curl_off_t on
>>>
> many
>
>>>
>>>
>>
>>
>>> systems! (Option added in 7.18.0)
>>>
>>> CURLOPT_SEEKDATA
>>>
>>> Data pointer to pass to the file read function. If you use the
>>> CURLOPT_SEEKFUNCTION option, this is the pointer you'll get as input. If
>>>
>>>
>> you
>>
>>
>>> don't specify a seek callback, NULL is passed. (Option added in 7.18.0)
>>>
>>> ----
>>> Currently, there's no wrapper around those options in cURLpp. I'll try to
>>> add
>>> those for the next version. However it shouldn't be there until a month.
>>>
>>>
>>>
>>>
>>>> Any help (or other librarys that can) would be appreciated.
>>>>
>>>>
>>>>
>>>> Mark
>>>>
>>>>
>>>>
>>>
>>>
>>>
>>
>>
>
>
>

-- 
ÐÏࡱá
_______________________________________________
cURLpp mailing list
cURLpp_at_rrette.com
http://www.rrette.com/mailman/listinfo/curlpp
Received on 2008-05-13

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET