HT_WOULD_BLOCK and streams

I'm implementing an application level-stream on top of the libwww
interface.  I've found that if I return HT_WOULD_BLOCK from the
put_block method, then the stream will not be sent any more data.

In particular, I am initializing the request like this:

    request = HTRequest_new();
    HTRequest_addRange(request, "bytes", "0-1,1-2,2-3,3-4,4-5,5-6,6-7");
    HTRequest_setOutputFormat(request,
                              WWW_SOURCE);
    HTRequest_setPreemptive(request, YES);

    rc = HTLoadToStream(url, stream, request);


The test_stream alternately returns HT_WOULD_BLOCK and HT_OK.

I've tried modifying the HTReader_read method to continue through
the loop if the net->readStream->isa->put_block returns HT_WOULD_BLOCK.
This has the effect of making all of the byte ranges get sent to my
stream, respecting my HT_WOULD_BLOCK responses.

However, if I do block, then I have a problem after I receive the last
byte range. The HTReader_read loops through one extra time through
the read loop, causing it to block until the http server closes the
socket.

Is there a way to have a stream block and still get all of the data
aimed at it?

Thanks for any help,
eoJ
--
Joseph Bester                               Phone: (630) 252-1496
Mathematics & Computer Science                Fax: (630) 252-5986
Argonne National Laboratory             Email: bester@mcs.anl.gov
Argonne, IL 60439

Received on Saturday, 25 September 1999 15:59:41 UTC