Open
Description
It looks like flate tries to fill 32 bits from the input and blocks trying to get it, even if data is ready to return.
Example program, no data is returned until the pipe is closed:
package main
import (
"net"
"log"
"time"
"github.com/mjl-/flate"
)
func main() {
// A sync flush:
// const s = "\xf26Rp\xf5st\xf2qU\b\rq\xb3\xb0utvv\r\b\xe1\xe5\x02\x00\x00\x00\xff\xff"
a, b := net.Pipe()
go func() {
defer b.Close()
// A partial flush that can be concatenated and reads fine:
// const s = "2V\xf0tQ\xd0P\xcaK\xccMURP\xf2ֵT\xf0M\xcc\xcc\x012\xcbR\x8b\x8a3\xf3\xf3\x80,\v=#%M^.\x80\x00"
// A partial flush that blocks until EOF.
const s = "r4Q\xf0s\xf4u\r\x0eptv\xe5\xe5r4U\xf0\xf1\f\x0eQPRRP\xd2RR\br\r\t\r\xf2S\xd0\b\x0eq\f\t\rV\xd0\x00\xaa\vvtw\rV\b\xf5t\xf1s\x8d\b\x01\xd1a\x8e>\x9e.\x9e!\x91\n\xa1~\xc1\xae\xae~\n\x1e\x9e\xee\x1e\xae\xc1!\xbe\xfe.\xc1\xae\x81\x9a\n\xc1\x01\xaeΞ\x8e>\xba\xa1\xc1\xae\x9a\xbc\\\x00\x01"
b.Write([]byte(s))
time.Sleep(time.Second)
}()
fr := flate.NewReaderPartial(a)
for {
buf := make([]byte, 1024)
log.Printf("read...")
n, err := fr.Read(buf)
if n > 0 {
log.Printf("read %q", buf[:n])
}
if err != nil {
log.Fatalf("read: %v", err)
}
}
}
Metadata
Metadata
Assignees
Labels
No labels