Re: Range requests to/from memory

>Jim_Ravan@avid.com wrote:
>
> I need to do range GETs and PUTs to/from memory. For example, someone
asks
> me to read bytes 300-500 of "http://www.abc.com/xyz.xml" to buffer foo.
> After they modify the buffer, they will then ask me to write the buffer
> back to the XML document. Range requests don't seem to work when added to
a
> request that is then processed by HTLoadAnchorToChunk(). Am I just going
> something wrong?

>Henrik kindly replied:
>
>Have you looked at
>
>    http://www.w3.org/Library/Examples/range.c

FYI, I am using libwww 5.2 with CWGUSI on a Macintosh.

Well, I think I understand why ranges didn't work. But if I'm correct, I
can't understand how the example program, range.c, works. HTTPReq.c formats
the HTTP stream for output. In routine HTTPMakeRequest(), the relevant code
reads:

     if (request_mask & HT_C_RANGE) { /* Format range requests */ }

But the associated routine to add a range to the request,
HTRequest_addRange() does *not* set the HT_C_RANGE bit in the request mask.
Thus, although a range list exists, HTTPMakeRequest() will not attempt to
format it. I *think* the fix is either to add an explicit set of HT_C_RANGE
in range.c as follows:

     /* Set the ranges */
     HTRequest_addRange(request, range_unit, HTChunk_data(ranges));
     HTRequest_addRqHd(HT_C_RANGE);

or to change HTRequest_addRange() to set HT_C_RANGE.

I added HTRequest_addRqHd(HT_C_RANGE) to my application and range headers
began to appear. I also noted that HTLine.c sets HT_C_RANGE directly.
Should it?

regards
-jim

Received on Wednesday, 16 December 1998 12:31:03 UTC