On 3/4/06, Christian Biesinger <[EMAIL PROTECTED]> wrote:
> > Is there any way to peek at the data? If I can't peek at the data I
> > need to implement my own buffering. With a peek function I can leave
> > it in the stream buffer. I'm looking for the \n\n\ at the end of the
> > headers so that I can start header parsing.
>
> Use ReadSegments, and return a zero read count. That said, that is not
> guaranteed to get you all the available data...
That goes against this comment in nsIInputStream.h...
* NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
/**
* The signature of the writer function passed to ReadSegments. This
* is the "consumer" of data that gets read from the stream's buffer.
*
* @param aInStream stream being read
* @param aClosure opaque parameter passed to ReadSegments
* @param aFromSegment pointer to memory owned by the input stream
* @param aToOffset amount already read (since ReadSegments was called)
* @param aCount length of fromSegment
* @param aWriteCount number of bytes read
*
* Implementers should return the following:
*
* @return NS_OK and (*aWriteCount > 0) if consumed some data
* @return <any-error> if not interested in consuming any data
*
* Errors are never passed to the caller of ReadSegments.
*
* NOTE: returning NS_OK and (*aWriteCount = 0) has undefined behavior.
*
* @status FROZEN
*/
typedef NS_CALLBACK(nsWriteSegmentFun)(nsIInputStream *aInStream,
void *aClosure,
const char *aFromSegment,
PRUint32 aToOffset,
PRUint32 aCount,
PRUint32 *aWriteCount);
--
Jon Smirl
[EMAIL PROTECTED]
_______________________________________________
dev-tech-network mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-network