cURL / Mailing Lists / curl-library / Single Mail

curl-library

CURLOPT_RANGE -> chunks -> how to remove MIME-Header-Foo ?

From: Rieker Flaik <rieker_flaik_at_arcor.de>
Date: Tue, 14 Jun 2011 12:36:08 +0200

On Sat, 2011-06-11 at 11:03 -0700, Dan Fandrich wrote:
> On Sat, Jun 11, 2011 at 07:35:26PM +0200, Rieker Flaik wrote:
> > I just want to download the first 100 bytes from a URL. What would be
> > the best way to do so?
> >
> > I tried to achieve this with a WriteMemoryCallback
> > (CURLOPT_WRITEFUNCTION) but realized that this is just for "where to
> > write out the data".
>
> That's the right approach. Presumably, you want to do something with those
> first 100 bytes, and that's the function to do it in. Once you've received
> all you want, just return 0 from that function and the transfer will
> stop. You can also set a CURLOPT_RANGE that will work on certain protocols
> with certain servers with certain URLs, but since there's no guarantee it
> will work, you'll still need to count bytes in the writefunction.

Thanks a lot. CURLOPT_RANGE is basically that what I want ;-)

But if it succeeds with the server to download chunk by chunk (for
example first 5 bytes then the rest) - it is "using standard MIME
separation techniques" which means it adds a kind of header to every
chunk.
But I don't want and need this! Or should I?

What is the best way to strip this MIME-Header-Foo off? Just remove the
first 8 lines of every chunk? Here is an example of what it looks like:

--4a5a936502fad6bcc

Content-type: text/xml;charset=iso-8859-1

Content-range: bytes 0-5/2463

<?xml

--4a5a936502fad6bcc

Content-type: text/xml;charset=iso-8859-1

Content-range: bytes 5-2462/2463

 version="1.0" encoding="UTF-8"?>
<testfile
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:noNamespaceSchemaLocation="testfile.xsd">

-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2011-06-14