HPInc / jipp

A Java-compatible implementation of IPP
MIT License
153 stars 42 forks source link

Don't use BufferedInputStream when parsing #44

Closed GladeDiviney closed 6 years ago

GladeDiviney commented 6 years ago

Currently IppInputStream is defined as a subclass of DataInputStream(BufferedInputStream(inputStream)). The effect is to draw off an 8k buffer from inputStream, most of which won't be read as IPP packets are usually smaller. This makes it difficult to recover the remainder of the stream when it contains a document.

GladeDiviney commented 6 years ago

After further review it's required to use BufferedInputStream due to the need to mark/reset.

But what we can do is move the key packet parsing code to IppPacketStream which can be used by transports to extract a packet. The remainder of unread data can then be accessed from the original stream.