Replies: 3 comments 5 replies
-
|
I understand the frustration with the short read. However, The behavior implemented in the library should match the Go standard library's If you require filled buffers, I recommend ~wrapping the connection in buf := make([]byte, 16384)
for totalRead < payloadSize {
n, err := conn.Read(buf[totalRead:])
if err != nil {
break // or handle errors but io.EOF
}
totalRead += n
} |
Beta Was this translation helpful? Give feedback.
-
That said, I wonder if we could avoid creating a a |
Beta Was this translation helpful? Give feedback.
-
|
what about the following: bufReader is being sized dynamically, and is set to max(256,len(b)), where b is the buffer passed by the user in conn.Read(b) ? that way if someone just wants to parse the proxy protocol header they can use conn.ProxyHeader() and the default (256) bufReader buffer size will be used. and if the caller provides a larger buffer size (because they likely expect more data than just 256 bytes to be delivered), then that size is used as the bufReader size. that's what I implemented in #162 😄 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Currently,
Conn.Read(p []byte)returns any data available. Consumers are expected to continue callingRead(p)until they either get the data they need or an error is returned. This follows idiomatic Go, namely theio.Reader.Read(b)documented behavior:However, some users of this library have different expectations. As per @clementnuss in #148 (comment):
So the question is should
Conn.Read(b)respectio.Readercontract strictly or not?Refs #142 #148
Potentially interested contributors: @bollenberger @mmatczuk @emersion @clementnuss @AlexanderYastrebov
Beta Was this translation helpful? Give feedback.
All reactions