nlf/riakpbc — pull request #86 by colinmutter (2014-10-24 22:25:42+00:00)
Title: Fix for range error when attempting to read from buffer

This should address and fix https://github.com/nlf/riakpbc/issues/81. It seems that in some cases your remaining data chunk (after translating the leading X bytes with protobuf) will contain fewer than the 4 bytes needed to constitute the initial `length` value per the protocol. Thus, we need to wait until the following data chunk arrives.

I added some comments around the existing code to clarify what each part is doing. L144-L151 are the only new lines technically introduced in this PR. And as with some of the other similar cases, this one is really hard to reproduce in a test case.