Closed Bug 1294446 Opened 9 years ago Closed 7 years ago

allow nsInputStreams to expose concept of "completion"

Categories

(Core :: XPCOM, defect, P3)

defect

Tracking

()

RESOLVED DUPLICATE of bug 1434553

People

(Reporter: bkelly, Unassigned)

References

Details

We should consider defining and exposing the concept of nsIInputStream "completion". This would mean: 1) All the data that could be read from the stream is known about. 2) The data has not necessarily been read out of the stream yet. 3) The stream may not be closed yet. The following are examples of completed streams: a) Any fixed length stream like string streams or file streams. b) Variable length streams that won't receive new data. This includes storage and pipe streams where the writing side's nsIOutputStream has been closed. We can also define whether a stream is expected to passively complete or will require active reading to complete: i) A pipe with infinite capacity should be able to complete without any data being read out. ii) A pipe with limited capacity will block writing until data is read out. So these streams are not passively completable. We can then provide a "on completed" callback that fires when the stream is complete. This would let code that currently uses NS_AsyncCopy() to accumulate and buffer the entire stream to possibly just wait for the original stream to complete. This would allow us to avoid copying. An immediate use case for this would be in necko upload streams. There we need to know if the stream is complete in order to call Available() and set a Content-Length header. See bug 1277681 comment 17.
Priority: -- → P3
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.