-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
make it possible to parse a varint at the end of a reader #3428
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3428 +/- ##
=======================================
Coverage 85.44% 85.44%
=======================================
Files 136 136
Lines 9946 9948 +2
=======================================
+ Hits 8498 8500 +2
Misses 1066 1066
Partials 382 382
Continue to review full report at Codecov.
|
An io.Reader can read into the buffer and return the io.EOF in the same call. In fact, that's how the quic.Stream is implemented. In that case, we shouldn't return an error from quicvarint.Read, otherwise the caller won't be able to parse a varint sent just before a stream was closed.
eca9b31
to
d7622a2
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
@@ -31,7 +31,10 @@ func NewReader(r io.Reader) Reader { | |||
|
|||
func (r *byteReader) ReadByte() (byte, error) { | |||
var b [1]byte | |||
_, err := r.Reader.Read(b[:]) | |||
n, err := r.Reader.Read(b[:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is obvious and good as is, but as a general note ReadAtLeast
follows the same semantics here (not suggesting we change this here).
An io.Reader can read into the buffer and return the io.EOF in the same call. In fact, that's how the quic.Stream is implemented. In that case, we shouldn't return an error from quicvarint.Read, otherwise the caller won't be able to parse a varint sent just before a stream was closed.
An io.Reader can read into the buffer and return the io.EOF in the same call. In fact, that's how the quic.Stream is implemented. In that case, we shouldn't return an error from quicvarint.Read, otherwise the caller won't be able to parse a varint sent just before a stream was closed.
An
io.Reader
can read into the buffer and return theio.EOF
in the same call. In fact, that's how thequic.Stream
is implemented.In that case, we shouldn't return an error from
quicvarint.Read
, otherwise the caller won't be able to parse a varint sent just before a stream was closed.